Here is my script:
import dadi
import numpy
dd = dadi.Misc.make_data_dict("c:\Python27\input_dadi.txt")
fs2 = dadi.Spectrum.from_data_dict(dd, pop_ids=['ama1','ama2'], projections=[16,14], polarized=False)
def IM(params, ns, pts):
s,nu1,nu2,T,m = params
xx = dadi.Numerics.default_grid(pts)
phi = dadi.PhiManip.phi_1D(xx)
phi = dadi.PhiManip.phi_1D_to_2D(xx, phi)
nu1_func = lambda t: s * (nu1/s)**(t/T)
nu2_func = lambda t: (1-s) * (nu2/(1-s))**(t/T)
phi = dadi.Integration.two_pops(phi, xx, T, nu1_func, nu2_func,
m12=m, m21=m)
fs = dadi.Spectrum.from_phi(phi, ns, (xx,xx))
return fs
def IM_nomig(params, ns, pts):
s,nu1,nu2,T = params
return IM((s,nu1,nu2,T,0),ns,pts)
my_extrap_func = dadi.Numerics.make_extrap_log_func( IM_nomig )
params = ["s","nu1","nu2","T"]
ns = [16,14]
pts_1 = [30,40,50]
upper_bound = [100,100, 100, 5]
lower_bound = [1e-2, 1e-2, 1e-2, 0]
p0 = [1, 1, 2, 0.3]
p0 = dadi.Misc.perturb_params(p0, fold=1, upper_bound=upper_bound,lower_bound=lower_bound)
popt = dadi.Inference.optimize_log(p0, fs2, my_extrap_func, pts_1,
lower_bound=lower_bound,
upper_bound=upper_bound,
verbose=len(p0), maxiter=20)
print('Best-fit parameters: {0}'.format(popt))
model = my_extrap_func(popt, ns, pts_1)
ll_model = dadi.Inference.ll_multinom(model, fs2)
print('Maximum log composite likelihood: {0}'.format(ll_model))
theta = dadi.Inference.optimal_sfs_scaling(model, fs2)
print('Optimal value of theta: {0}'.format(theta))
Na here is the end of my result:
WARNING:Inference:Number of affected entries is 134. Sum of data in those entries is 1048.37:
196 , nan , array([ 1.32184 , 1.89026 , 1.19633 , 0.172601 ])
Best-fit parameters: [ 1.3218422 1.890255 1.19633365 0.17242872]WARNING:Inference:Model is nan in some entries where data is not masked.
WARNING:Inference:Number of affected entries is 134. Sum of data in those entries is 1048.37:
Maximum log composite likelihood: --
Optimal value of theta: nan
I tried different bounds and pts and I always get that. I'm not seeing my mistake here.
Thank you!! :)
Dani