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

add pos & neg DFE from Rodrigues et al (PosNeg_R24 in HomSap) #1657

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

petrelharp
Copy link
Contributor

Motivation: we'd like to have a DFE containing positive mutations that aren't all at one fixed value of s.

Rodrigues, Kern & Ralph doesn't exactly infer such a DFE, in the sense of using a validated inference procedure, but does explore parameter space and find a best-fitting DFE - so, I think it counts, and since it is simulation-based, we know it produces roughly reasonable simulations. The targets of inference are only the proportions of positive and negative selection; the negative part of the DFE is from Castellano et al, which I also cite here; the positive part is based on "expert knowledge" (i.e., something that seems reasonable).

So, in the popsim spirit of "best guess based on current state of knowledge", I think this is a good one to put in. Other opinions welcome (esp if they propose a better alternative such DFE?).

Note that the method uses all the great apes, and so could reasonably be applied to any of them.

@petrelharp petrelharp requested review from mufernando and removed request for mufernando January 19, 2025 16:51
@petrelharp
Copy link
Contributor Author

(Actually I was hoping @mufernando would QC this - I'll get a code review from someone else?)

Copy link

codecov bot commented Jan 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.85%. Comparing base (6218f3d) to head (025da27).
Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1657    +/-   ##
========================================
  Coverage   99.84%   99.85%            
========================================
  Files         132      136     +4     
  Lines        4584     4690   +106     
  Branches      467      470     +3     
========================================
+ Hits         4577     4683   +106     
  Misses          3        3            
  Partials        4        4            

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

@petrelharp
Copy link
Contributor Author

I've removed you from the assignee list, @mufernando, since I'm hoping you'll QC this? Say if you are actually going to review this PR instead.

@mufernando
Copy link
Member

mufernando commented Jan 21, 2025 via email

@silastittes
Copy link
Contributor

Did the following locally with the PR

import stdpopsim
import numpy as np

species = stdpopsim.get_species("HomSap")
dfe = species.get_dfe("PosNeg_R24")
contig = species.get_contig(length=30000)
model = species.get_demographic_model("OutOfAfrica_3G09")
samples = {"YRI": 50, "CEU": 50, "CHB": 50}

gene_interval = np.array([[10000, 20000]])
contig.add_dfe(intervals=gene_interval, DFE=dfe)

engine = stdpopsim.get_engine("slim")
ts = engine.simulate(
    model,
    contig,
    samples,
    seed=236,
    slim_scaling_factor=10,
    slim_burn_in=10,
)
print(ts)
print(ts.diversity())
print(ts.allele_frequency_spectrum())
╔═══════════════════════════╗
║TreeSequence               ║
╠═══════════════╤═══════════╣
║Trees          │         61║
╟───────────────┼───────────╢
║Sequence Length│      30000║
╟───────────────┼───────────╢
║Time Units     │generations║
╟───────────────┼───────────╢
║Sample Nodes   │        300║
╟───────────────┼───────────╢
║Total Size     │  164.2 KiB║
╚═══════════════╧═══════════╝
╔═══════════╤════╤════════╤════════════╗
║Table      │Rows│Size    │Has Metadata║
╠═══════════╪════╪════════╪════════════╣
║Edges      │ 819│25.6 KiB│          No║
╟───────────┼────┼────────┼────────────╢
║Individuals│ 150│16.4 KiB│         Yes║
╟───────────┼────┼────────┼────────────╢
║Migrations │   0│ 8 Bytes│          No║
╟───────────┼────┼────────┼────────────╢
║Mutations  │ 258│14.9 KiB│         Yes║
╟───────────┼────┼────────┼────────────╢
║Nodes      │ 639│24.4 KiB│         Yes║
...
╟───────────┼────┼────────┼────────────╢
║Sites      │ 255│ 6.2 KiB│          No║
╚═══════════╧════╧════════╧════════════╝


0.00010336900780379047
[0.00000000e+00 1.30000000e-03 1.66666667e-04 1.33333333e-04
 0.00000000e+00 6.66666667e-05 6.66666667e-05 0.00000000e+00
 6.66666667e-05 3.33333333e-05 6.66666667e-05 1.33333333e-04 
...
 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
 0.00000000e+00]

The rationale makes sense and all looks good to me!

Copy link
Contributor

@silastittes silastittes left a comment

Choose a reason for hiding this comment

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

All seems good!

@petrelharp petrelharp merged commit bf1fb81 into popsim-consortium:main Jan 29, 2025
11 checks passed
AprilYUZhang pushed a commit to AprilYUZhang/stdpopsim that referenced this pull request Feb 20, 2025
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.

3 participants