Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h-s relationship (closes #1488) #1498

Merged
merged 12 commits into from Aug 9, 2023

Conversation

petrelharp
Copy link
Contributor

@petrelharp petrelharp commented Jun 27, 2023

Here's an implementation of the "discretized h-s relationship" discussed at #1488. There is a small backwards incompatibility here; that is that the "slim_mutation_id" entry we record in the top-level metadata is now a list instead of a single value. I think this is okay because we'll be doing a new release (and so can mention this), and our storing of things in metadata is not documented yet anyhow.

Note in particular that with this, we will be decoupling the "mutation type" of SLiM from the "mutation type" of stdpopsim (ie a single stdpopsim mutation type may produce mutations of many SLiM mutation types). This is why it was perhaps a lack of foresight to model the DFE machinery after SLiM's mechanics rather than motivating biology.

To understand what's going on here, read "10.6 Varying the dominance coefficient among mutations" of the SLiM manual.

@petrelharp
Copy link
Contributor Author

Perhaps you could have a look at this @ckyriazis?

@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (e9c9b1e) 99.85% compared to head (df64ec1) 99.85%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1498   +/-   ##
=======================================
  Coverage   99.85%   99.85%           
=======================================
  Files         121      121           
  Lines        4099     4154   +55     
  Branches      568      586   +18     
=======================================
+ Hits         4093     4148   +55     
  Misses          3        3           
  Partials        3        3           
Files Changed Coverage Δ
stdpopsim/dfe.py 100.00% <100.00%> (ø)
stdpopsim/slim_engine.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@petrelharp
Copy link
Contributor Author

Uh oh, we need some CI love. However, we seem to be passing the tests.

@petrelharp petrelharp marked this pull request as ready for review June 27, 2023 18:24
Copy link
Contributor

@ckyriazis ckyriazis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really great Peter! My python is a bit rusty so I am maybe not the best person for reviewing your code in great detail, but the approach you took here seems like it should work great.

@petrelharp
Copy link
Contributor Author

Closes #1499. (unless someone objects before this goes in)

stdpopsim/dfe.py Outdated
Instead of a single dominance coefficient, a discretized relationship
between dominance and selection coefficient can be implemented:
if dominance_coeff_list is provided, then there is a mutations with selection
coefficient s with dominance_coeff_breaks[k-] <= s <= dominance_coeff_breaks[k] will
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a 1

@petrelharp
Copy link
Contributor Author

@chriscrsmith
Copy link
Contributor

Hey @petrelharp want me to look at this PR? Or waiting on ADK?

@petrelharp
Copy link
Contributor Author

Sorry, a bit overwhelmed by github notifications - sure, that'd be great!

@chriscrsmith
Copy link
Contributor

I think this looks good! Runs good too. (Although I haven't worried about possible interactions with the rest of the code base, since I'm not too familiar with it)

Copy link
Contributor

@chriscrsmith chriscrsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offered edits on the code-comments that would clarify things for me

// For each stdpopsim mutation type with an h-s relationship
// we have a sequence of assigned SLiM mutation types;
// the first is the one that gets produced by mutation,
// and the remainder are assigned by a mutation callback.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// and the remainder are assigned by a mutation callback.
// and the remainder are assigned by a mutation callback.
// This sequence of mutation types is a subset of the combined
// mutation types list, e.g., including neutral mutations, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually understand what your clarifying sentence means - which is "this sequence"? What are you trying to clarify?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"this sequence [of mutation types]" is "a sequence of assigned SLiM mutation types; the first is the one that gets produced by mutation, and the remainder are assigned by a mutation callback".

The sentence I offered explains that the sequence you wrote about is a subset of a greater sequence, if other types are present.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried rewriting this to clarify a few times, but it didn't work - I don't think this is the place to explain that basic concept - it's a thing that we explain elsewhere, and this minor comment in the SLiM code isn't the place to go into a detailed description of which things get slim mutation types.

stdpopsim/slim_engine.py Outdated Show resolved Hide resolved
stdpopsim/slim_engine.py Outdated Show resolved Hide resolved
if mt.dominance_coeff_list is None:
h_list = [mt.dominance_coeff]
else:
h_list = [0.5] # this value will not matter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is None or -1 or something better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None will cause an error. And, if it's like -1 or something weird then I can imagine people looking at that value and thinking "whoa something is wrong" even though it's not? (Since the value will appear in the SLiM script, just for mutations that are never kept around.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a more clarifying comment.

stdpopsim/dfe.py Outdated Show resolved Hide resolved
stdpopsim/dfe.py Outdated Show resolved Hide resolved
@petrelharp
Copy link
Contributor Author

OK - I did most of your suggestions; see my comments for those I didn't. How's it look now, @chriscrsmith ?

@petrelharp
Copy link
Contributor Author

Huh, what happened? The tests were passing: https://github.com/popsim-consortium/stdpopsim/actions/runs/5602731956

@chriscrsmith
Copy link
Contributor

OK - I did most of your suggestions; see my comments for those I didn't. How's it look now, @chriscrsmith ?

Looks great!

@petrelharp petrelharp merged commit d923127 into popsim-consortium:main Aug 9, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants