def Model_A ((Na2, N6, N1_5, N7, M15_6, M7_15, T0, T1, T2), ns, pts):
#Define the grid we'll use
xx = dadi.Numerics.default_grid(pts)
#phi for the equilibrium ancestral population
phi = dadi.PhiManip.phi_1D(xx)
#Na1 population split
phi = dadi.PhiManip.phi_1D_to_2D(xx, phi)
#Time delay before the second population split
Integration.two_pops(phi, xx, T0, nu1=N6, nu2=Na2, m12=0, m21=0)
#Na2 population split
phi = dadi.PhiManip.phi_2D_to_3D_split_2(xx, phi)
#Time delay before admixture events
phi = Integration.three_pops (phi, xx, T1,
nu1=N6, nu2=N1_5, nu3=N7,
m12=0, m13=0, m21=0,
m23=0, m31=0, m32=0)
#Admixture events
phi = Integration.three_pops (phi, xx, T2,
nu1=N6, nu2=N1_5, nu3=N7,
m12=0, m13=0, m21=M15_6,
m23=0, m31=0, m32=M7_15)
fs = Spectrum.from_phi(phi,ns,(xx,xx,xx))
return fsdef Model_B ((Na2, N6, N1_5T1, N1_5T2, N1_5, N7, M15_6, M7_15, T0, T1, T2), ns, pts):
#Define the grid we'll use
xx = dadi.Numerics.default_grid(pts)
#phi for the equilibrium ancestral population
phi = dadi.PhiManip.phi_1D(xx)
#Na1 population split
phi = dadi.PhiManip.phi_1D_to_2D(xx, phi)
#Time delay before the second population split
Integration.two_pops(phi, xx, T0, nu1=N6, nu2=Na2, m12=0, m21=0)
#Na2 population split
phi = dadi.PhiManip.phi_2D_to_3D_split_2(xx, phi)
#Time delay before admixture events
N1_5_func1 = lambda t: N1_5T1 + (N1_5T2 - N1_5T1)*t/T1
phi = Integration.three_pops (phi, xx, T1,
nu1=N6, nu2=N1_5_func1, nu3=N7,
m12=0, m13=0, m21=0,
m23=0, m31=0, m32=0)
#Admixture events
N1_5_func2 = lambda t: N1_5T2 + (N1_5 - N1_5T2)*t/T2
phi = Integration.three_pops (phi, xx, T2,
nu1=N6, nu2=N1_5_func2, nu3=N7,
m12=0, m13=0, m21=M15_6,
m23=0, m31=0, m32=M7_15)
fs = Spectrum.from_phi(phi,ns,(xx,xx,xx))
return fsdd = Misc.make_data_dict('dadi_input_100.txt')
count_dict = dadi.Misc.count_data_dict(dd, pop_ids=['clade1_5', 'cluster6', 'cluster7'])
pts_l = [300,320,330]
funcA = dadi_models.Model_A
funcB = dadi_models.Model_B
# Parameters model A are: (Na1, Na2, N6, N1_5, N7, M15_6, M7_15, T0, T1, T2)
upper_boundA = [100, 100, 100, 100, 2, 2, 0.18, 0.18, 0.18]
lower_boundA = [1e-2, 1e-2, 1e-2, 1e-2, 0, 0, 5.3e-4, 5.3e-4, 5.3e-4]
# Parameters model B are: (Na1, Na2, N6, N1_50, N1_5, N7, M15_6, M7_15, T0, T1, T2)
upper_boundB = [100, 100, 100, 100, 100, 100, 2, 2, 0.18, 0.18, 0.18]
lower_boundB = [1e-2, 1e-2, 1e-2, 1e-2, 1e-2, 1e-2, 0, 0, 5.3e-4, 5.3e-4, 5.3e-4]
# This is our initial guess for the parameters, which is somewhat arbitrary.
p0A = [1,1,1,1,1,1,1e-2,1e-2,1e-2]
p0B = [1,1,1,1,1,1,1,1,1e-2,1e-2,1e-2]
# Make the extrapolating version of our demographic model function.
funcA_ex = dadi.Numerics.make_extrap_log_func(funcA)
funcB_ex = dadi.Numerics.make_extrap_log_func(funcB)
# Perturb our parameters before optimization. This does so by taking each
# parameter a up to a factor of two up or down.
p0A1 = dadi.Misc.perturb_params(p0A, fold=1, upper_bound=upper_boundA,
lower_bound=lower_boundA)
p0B1 = dadi.Misc.perturb_params(p0B, fold=1, upper_bound=upper_boundB,
lower_bound=lower_boundB)
poptA1 = dadi.Inference.optimize(p0A1, data, funcA_ex, pts_l,
lower_bound=lower_boundA,
upper_bound=upper_boundA,
verbose=1, maxiter=20)
poptB1 = dadi.Inference.optimize(p0B1, data, funcB_ex, pts_l,
lower_bound=lower_boundB,
upper_bound=upper_boundB,
verbose=1, maxiter=20)--
You received this message because you are subscribed to the Google Groups "dadi-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dadi-user+...@googlegroups.com.
To post to this group, send email to dadi...@googlegroups.com.
Visit this group at https://groups.google.com/group/dadi-user.
For more options, visit https://groups.google.com/d/optout.
Hello Jose,
Try linear rather than logarithmic extrapolation. That can be more stable.
Best,Ryan
Hi Ryan,
Thanks for your response.
This was happening on all steps, but if I let the analysis run for a few days with the warning messages suddenly stop at some point as shown in the picture below.
It seems that the optimizer founds a parameter space with non problematic values. But I think the optimizer is taking too long to stabilize. Is there a way to make the optimizer find this stable model parameters faster?.
José
--
You received this message because you are subscribed to the Google Groups "dadi-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dadi-user+...@googlegroups.com.
To post to this group, send email to dadi...@googlegroups.com.
Visit this group at https://groups.google.com/group/dadi-user.
For more options, visit https://groups.google.com/d/optout.