-
Notifications
You must be signed in to change notification settings - Fork 90
Closed
Description
Hi all,
I wonder if there is a template to simulate multiple bottlenecks for a population over several time points. I have made a simple script to do this but it seems not correct. Can anyone give any advice?
Below is my python script.
growth_r2=-0.0006
T_growth1 = 300 ### last 300 generations of exponential growth
T_growth2 = 1000
Size_before_growth1 = 1e4
Size_before_growth2 = 1e6
### Calculate the population size after exponential growth.
Size_after_growth1 = Size_before_growth1 / math.exp(-growth_r1 * T_growth1)
Size_after_growth2 = Size_before_growth2 / math.exp(-growth_r2 * T_growth2)
yy = msprime.simulate(
Ne=1e4,
recombination_rate=1e-8,
mutation_rate=1e-8,
length = 5e6, # 10MB
population_configurations = [
# POP1 Specify population size at time point 0 to be the calculated size after growth
msprime.PopulationConfiguration(sample_size=30, growth_rate=growth_r1, initial_size=Size_after_growth1),
],
migration_matrix =[
[0],
],
demographic_events = [
### Set population size to 1e4 prior to exponential growth start and set the growth rate prior to this time to 0
msprime.PopulationParametersChange(time=T_growth1, initial_size=Size_before_growth1, growth_rate=0),
msprime.PopulationParametersChange(time=T_growth2, initial_size=Size_before_growth2, growth_rate=-0.006)
],
random_seed=random.seed())```
Thanks a lot in advance.
Best,
yz
Metadata
Metadata
Assignees
Labels
No labels