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

recording migrants with sweep model #2190

Closed
GertjanBisschop opened this issue Jul 21, 2023 · 3 comments
Closed

recording migrants with sweep model #2190

GertjanBisschop opened this issue Jul 21, 2023 · 3 comments

Comments

@GertjanBisschop
Copy link
Member

I was trying to record msprime.NodeType.MIGRANT in the SweepGenicModel. In theory, this should allow us to record lineages that recombine away from the selected background (= changing labels in the structured coalescent).

Ne = 10_000
model = msprime.SweepGenicSelection(position=10, start_frequency=0.1, end_frequency=0.9, s=0.01, dt=1/(40 * Ne))
msprime.sim_ancestry(
    samples=4,
    model=model, 
    recombination_rate=1e-8, 
    sequence_length=1000, 
    coalescing_segments_only=False, 
    additional_nodes=msprime.NodeType.MIGRANT,
    population_size=Ne
)

This returns the following error:
msprime._msprime.LibraryError: The simulation model supplied resulted in a parent node having a time value <= to its child. This can occur as a result of multiple bottlenecks happening at the same time, multiple census events at the same time or numerical imprecision with very smallpopulation sizes.

This is due to how the sweep is set up: msp_sweep_initialise. The move individuals function is applied here to the sampled lineages. We shouldn't be registering an additional node here. The same error will happen when the sweep is finalised I think.

@molpopgen
Copy link
Member

In the long run, recording events this way may cause some issues. Arguably, one goal is for msprime to replace, e.g., discoal, in terms of functionality. If that happens, then the notion of a "migration" will get overloaded: between fitness classes and between "real" demes.

@GertjanBisschop
Copy link
Member Author

Yes, agreed. We need a new msprime.NodeType, or a way of recording fitness classes in a flexible way. In the mean time I will make sure we throw an error when trying to record MIGRANTS for the SweepGenicModel.

@GertjanBisschop
Copy link
Member Author

Solved in #2199.

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

No branches or pull requests

2 participants