tskit-dev / pyslim

Tools for dealing with tree sequences coming to and from SLiM.
MIT License
27 stars 23 forks source link

Recapitation with recent demographic events + historical sampling ? #264

Closed ChrystelleDelord closed 2 years ago

ChrystelleDelord commented 2 years ago

Dear all,

I just had two curiosity questions:

Thank you very much!! Kind regards

Chrys

petrelharp commented 2 years ago

I would like to confirm; if I simulate some demographic changes (e.g. a bottleneck) during a simulation with SLiM, and then want to recapitate the tree output: do I have to model the bottleneck as well in pyslim? I would sense that the answer to that question is yes, so for example when building a msprime.Demography() object, my initial_size would be the size of the population at the most recent time (i.e., the "bottlenecked" population), and then I would have to set a demography.add_population_parameters_change() or so, to model the change and set the population size before the bottleneck. Is that correct?

Well, let's see: say the end of the SLiM simulation is "today" and the start of the SLiM simulation was "time T ago". Then, msprime will finish coalescing any uncoalesced lineages; and all uncoalesced linages will start at time T ago, and so msprime will only use information in the demographic model starting at time T ago. So, the intiial size doesn't actually matter as long as the population has the size you want it to from time T ago and further back.

-

I was also wondering: is there a way to draw historical samples during recapitation, i.e., at more ancient timesteps than those simulated in SLiM? I have seen that, in pyslim/msprime, you may provide either an argument samples= or initial_state=. In pyslim.recapitate(), initial_state= correspond to the tree to be recapited, and I have seen that samples= or initial_state= were mutually exclusive arguments. I suppose, combining both samples= and initial_state= would be extremely difficult or even impossible, but I just wanted to make sure this was correct?

Oh, good question. You could do this by adding some more samples to the tree sequence that started at these old times before handing it to msprime; that would be a good question to ask here: https://github.com/tskit-dev/msprime/discussions if you want to do it.

ChrystelleDelord commented 2 years ago

Thanks a lot Peter for your answer! It will be easier than I thought then, to recapitate a tree with recent events already modelled in SLiM, great!

I will remember to open a Discussion about historical sampling during recapitation, if this could be of interest for others as well. Many thanks!!

Have a great week, Chrys