コード例 #1
0
def fig_plot(model, group, dir, model_name):
    fig = momi.DemographyPlot(model, ["Central", group],
                              figsize=(6, 8),
                              major_yticks=[
                                  1e3, 3e3, 5e3, 7e3, 9e3, 1e4, 3e4, 5e4, 7e4,
                                  9e4, 1e5, 3e5, 5e5, 7e5, 9e5, 1e6
                              ],
                              linthreshy=1e4)
    plt.savefig(dir + "/" + group + "/" + group + "_" + model_name + ".svg",
                format="svg",
                bbox_inches='tight')
    plt.savefig(dir + "/" + group + "/" + group + "_" + model_name + ".png",
                format="png",
                bbox_inches='tight')
    plt.close()
コード例 #2
0
    'tsk_0': 'YRI',
    'tsk_1': 'YRI',
    'tsk_2': 'CEU',
    'tsk_3': 'CEU',
    'tsk_4': 'CHB',
    'tsk_5': 'CHB'
}
data = momi.SnpAlleleCounts.read_vcf('../out_of_africa_chr22_sim.vcf',
                                     ind2pop=ind2pop).extract_sfs(n_blocks=100)
data = data.subset_populations(['YRI', 'CEU', 'CHB'])

params = [
    15004.596619670217, 7223.225653867972, 270.24291209230444,
    0.0690831942210091, 0.0009024496699107315, 1820.3282780957186,
    -0.000874306156876506, 360037.9623043344, 2424.316004053876,
    36.219376382869015
]
model = model_func(params)
model.gen_time = 1
model.muts_per_gen = 1.29e-08
model.set_data(data, length=51304566)
ll_model = model.log_likelihood()
print(f'Value of log-likelihood: {ll_model}')
from matplotlib import pyplot as plt
momi.DemographyPlot(model,
                    pop_x_positions=data.sampled_pops,
                    figsize=(6, 8),
                    linthreshy=None,
                    pulse_color_bounds=(0, .25))
plt.savefig('model_from_GADMA.png')
コード例 #3
0
pure_isolation_model.move_lineages("SON", "CHI", t="tdiv_sc")
## randomize parameters and check them

pure_isolation_model.set_params(randomize=True)
print(pure_isolation_model.get_params())


# In[ ]:


## check that the model is what you want 
yticks = [1e4, 2.5e4, 5e4, 7.5e4, 1e5, 2.5e5, 5e5, 7.5e5,1e6,3e6]
fig = momi.DemographyPlot(
	pure_isolation_model, 
	["CHI","SON"],
	figsize=(6,8),
	major_yticks=yticks,
	#linthreshy=2.5e6
)


# In[ ]:


## STOCH OPT WITH SNPS
## SNPS IS FASTER?

pure_isolation_model.stochastic_optimize(num_iters=10, snps_per_minibatch=1000, save_to_checkpoint="momi_checkpoint_isol.txt", svrg_epoch=-1)
print(pure_isolation_model.get_params())

コード例 #4
0
## set up effective population size
pure_isolation_model.add_size_param("ne_s",lower=1000,upper=2000000) ## this is from Brian's paper on cardinals
pure_isolation_model.add_size_param("ne_c",lower=1000,upper=2000000) 
## set up populations and phylogeny
pure_isolation_model.add_leaf("Son",N="ne_s")
pure_isolation_model.add_leaf("Chi",N="ne_c")
pure_isolation_model.move_lineages("Son", "Chi", t="tdiv_sc")
## randomize parameters and check them
pure_isolation_model.set_params(randomize=True)
print(pure_isolation_model.get_params())
## check that the model is what you want 
yticks = [1e4, 2.5e4, 5e4, 7.5e4, 1e5, 2.5e5, 5e5, 7.5e5,1e6,3e6]
fig = momi.DemographyPlot(
	pure_isolation_model, 
	["Chi","Son"],
	figsize=(6,8),
	major_yticks=yticks,
	#linthreshy=2.5e6
)

## set up the rest of the models 

##### UNIDIRECTIONAL CHI TO SON MIGRATION #####
print("Uni Chi2Son model")
uni_chi_to_son_model = pure_isolation_model.copy() ## copies the Pure Isolation model 
## add additional parameters 
uni_chi_to_son_model.add_pulse_param("mig_c2s",lower=0,upper=0.1)
uni_chi_to_son_model.add_time_param("tmig_c2s",lower=0,upper=1000000,upper_constraints=["tdiv_sc"])
uni_chi_to_son_model.move_lineages("Son","Chi",t="tmig_c2s",p="mig_c2s")
## randomize parameters and check them
uni_chi_to_son_model.set_params(randomize=True)