forked from timbeissinger/Maize-Teo-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrealisticBottleneck.py
43 lines (31 loc) · 1.32 KB
/
realisticBottleneck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Realistic bottleneck model, no migration.
"""
"""
In words:
At time TF in the past, an equilibrium teosinte population will split into
a maize population and a teosinte population. The maize population will immediately go
through a bottleneck of size nuMB. Then, it will grow exponentially at
time TF. The Teosinte population will not go through a bottleneck. It will grow linearly to
end at size nuTeoF.
"""
import numpy
import dadi
def maizeBottleneck (params, ns, pts):
nuMB , nuMF , nuTeoF , TF , m12, m21 = params
# define the grid
xx = dadi.Numerics.default_grid(pts)
# phi for the equilibrium ancestral population
phi = dadi.PhiManip.phi_1D(xx)
# now do the population split
phi = dadi.PhiManip.phi_1D_to_2D(xx, phi)
# Send maize population through a bottleneck
#phi = dadi.Integration.two_pops(phi, xx, T = TMB , nu1 = 1, nu2 = nuMB)
# define the maize exponential growth function
nu_funcM = lambda t: nuMB*(nuMF/nuMB) ** (t/TF)
# Option 1: define the teosinte exponential growth function
nu_funcTeo = lambda t: 1*(nuTeoF/1) ** (t/TF)
# Recover maize population exponentially, allow migration
phi = dadi.Integration.two_pops(phi, xx, T = TF, nu1 = nu_funcTeo, nu2 = nu_funcM, m12 = m12, m21 = m21)
fs = dadi.Spectrum.from_phi(phi, ns, (xx,xx))
return fs