rho_per_locus=100.0 f=qtm.MlocusAdditiveTrait() delmuts=[1e-3]*NLOCI mmodels=[fp.GaussianS(0,1,1,0.25)]*len(delmuts) for i in mmodels: print i nmuts=[theta_neutral/float(4*nlist[0])]*NLOCI recrates=[theta_neutral/float(4*nlist[0])]*NLOCI pfile = gzip.open("pickle_out.p","wb") for i in range(1): x = fp.MlocusPopVec(NREPS,nlist[0],NLOCI) sampler=fp.NothingSampler(len(x)) qtm.evolve_qtraits_mloc_sample_fitness(rnge,x,sampler,f, nlist[:5000], nmuts, delmuts, mmodels, recrates, [0.0]*(NLOCI-1),sample=0, VS=2,optimum=0.) v = fp.view_mutations(x) for i in v: print i for i in x: d=fpio.serialize(i) pickle.dump(d,pfile) pfile.close()
# coding: utf-8 # # Example of taking 'views' from simulated populations # In[1]: from __future__ import print_function import fwdpy as fp import pandas as pd from background_selection_setup import * # Get the mutations that are segregating in each population: # In[2]: mutations = [fp.view_mutations(i) for i in pops] # Look at the raw data in the first element of each list: # In[3]: for i in mutations: print(i[0]) # Let's make that nicer, and convert each list of dictionaries to a Pandas DataFrame object: # In[4]: mutations2 = [pd.DataFrame(i) for i in mutations] # In[5]:
nlist, mutrate_neutral, mutrate_sel, recrate, nregions, sregions, recregions) #Change a mutation's selection coefficient for i in pops: x=csp.change_selection_coeff(i,0.5,10,0.1,0.25) #print out count and position of variant actually changed print (x) #Get the list of mutations in each population views = [pd.DataFrame(i) for i in fp.view_mutations(pops)] for i in views: print (i[i.neutral==False]) #Now, lets use our custom temporal sampler sampler=cts1.SelectedSFSSampler(len(pops)) #Evolve these pops for another 100 generations, #tracking joint frequency,s of all selected mutations fp.evolve_regions_sampler(rng,pops,sampler, nlist[:100], mutrate_neutral, mutrate_sel, recrate, nregions,
# # Example of taking 'views' from simulated populations # In[1]: from __future__ import print_function import fwdpy as fp import pandas as pd from background_selection_setup import * # Get the mutations that are segregating in each population: # In[2]: mutations = [fp.view_mutations(i) for i in pops] # Look at the raw data in the first element of each list: # In[3]: for i in mutations: print(i[0]) # Let's make that nicer, and convert each list of dictionaries to a Pandas DataFrame object: # In[4]: mutations2 = [pd.DataFrame(i) for i in mutations]
rng = fp.GSLrng(101) pops = fp.evolve_regions(rng, #The random number generator 4, #The number of pops to simulate = number of threads to use. N, #Initial population size for each of the 4 demes nlist[0:], #List of population sizes over time. 0.005, #Neutral mutation rate (per gamete, per generation) 0.01, #Deleterious mutation rate (per gamete, per generation) 0.005, #Recombination rate (per diploid, per generation) nregions, #Defined above sregions, #Defined above recregions)#Defined above ##Get fixation views: fixations = [fp.view_fixations(i) for i in pops] ##Get mutation views: mviews = fp.view_mutations(pops) class test_sample_details(unittest.TestCase): def test_CompareUsingView(self): """ Evolve some population, take samples, get details of those samples, make sure those details match up what 'views' think should be in the population. """ samples = [fp.get_samples(rng,i,100) for i in pops] details = [fp.get_sample_details(i[1],j) for i,j in zip(samples,pops)]