Closed yzliu01 closed 6 months ago
When using num_replicates, you get an iterator over tree sequences rather than, say, a list of simulated outputs. You must consume the iterator in order to start adding mutations:
import msprime
for ts in msprime.sim_ancestry(10, num_replicates=5):
mts = msprime.sim_mutations(ts, rate=1e-4)
Regarding the question about demography, it is probably easier to write the demographic model in demes format. To get a growth rate at time 0, you write the most recent epoch for a deme with start_size != end_size. There are examples here
Regarding the question about demography, it is probably easier to write the demographic model in demes format. To get a growth rate at time 0, you write the most recent epoch for a deme with start_size != end_size. There are examples here
Hi, many thanks. It's great to know this method. It seems I need to create yaml file? I am not so clear how to incorporate this deme format in my msprime codes. Can you post a simple example?
You can convert the demes yaml file like this:
graph = demes.load("model.yaml")
demography = msprime.Demography.from_demes(graph)
(see here)
and then run your simulation as before:
ts = msprime.sim_ancestry(*, demography=demography)
Dear GertjanBisschop and all,
I am writing to ask if you can advise me on this problem I got using
num_replicates
in the following codes. Error I got withmts_5rep = msprime.sim_mutations(ts_5rep, rate=8.9e-8, random_seed=1)
is ValueError: First argument must be a TreeSequence instance.. I know there might be a problem in the previous stepts_5rep = msprime.sim_ancestry()
but I could not figure it out since it did not report anything with my codes below.Another question. Here
How can I set the current time with a
growth_rate
as the beginning time? I triedtime=0
and this did not work. I had to use a non-zero number (0.1 etc.).Thank you very much in advance. Best,
Used codes
Error I got with
mts_5rep = msprime.sim_mutations(ts_5rep, rate=8.9e-8, random_seed=1)
. ValueError: First argument must be a TreeSequence instance.Other codes after the above steps.