## First, let's compute the SFS for a single population with a three-epoch history n = 20 ## sample size ## specify the epochs backwards in time from the present epochs = [ ExponentialTruncatedSizeHistory( n_max=n, tau=0.25, N_top=1.0, N_bottom=10.0 ), # an exponential growth period for 0.25 units of time. "top"=past, "bottom"=present ConstantTruncatedSizeHistory(n_max=n, tau=0.1, N=0.1), # a bottleneck for 0.1 units of time ConstantTruncatedSizeHistory(n_max=n, tau=float('inf'), N=1.0), # ancestral population size = 1 ] ## turn the list of epochs into a single population history demo1 = PiecewiseHistory(epochs) ## print the SFS entries print "Printing SFS entries for three epoch history" print[demo1.freq(i, n) for i in range(1, n)] ## Next, print out the "truncated SFS" for just the middle epoch ## i.e., the frequency spectrum for mutations that occur within the middle epoch print "\nPrinting truncated SFS for middle epoch" print[epochs[1].freq(i, n) for i in range(1, n)] ## Finally, let's compute SFS entries for a multipopulation demography # For our demography, we'll have three leaf populations: 'a','b','c', with 10,5,8 sampled alleles respectively ## specify demography via a newick string ## to specify additional population parameters, follow branch length with [&&momi:...]
from momi import Demography, ConstantTruncatedSizeHistory, ExponentialTruncatedSizeHistory, PiecewiseHistory ## First, let's compute the SFS for a single population with a three-epoch history n = 20 ## sample size ## specify the epochs backwards in time from the present epochs = [ExponentialTruncatedSizeHistory(n_max=n, tau=0.25, N_top=1.0, N_bottom=10.0), # an exponential growth period for 0.25 units of time. "top"=past, "bottom"=present ConstantTruncatedSizeHistory(n_max = n, tau=0.1, N=0.1), # a bottleneck for 0.1 units of time ConstantTruncatedSizeHistory(n_max = n, tau=float('inf'), N=1.0), # ancestral population size = 1 ] ## turn the list of epochs into a single population history demo1 = PiecewiseHistory(epochs) ## print the SFS entries print "Printing SFS entries for three epoch history" print [demo1.freq(i, n) for i in range(1,n)] ## Next, print out the "truncated SFS" for just the middle epoch ## i.e., the frequency spectrum for mutations that occur within the middle epoch print "\nPrinting truncated SFS for middle epoch" print [epochs[1].freq(i,n) for i in range(1,n)] ## Finally, let's compute SFS entries for a multipopulation demography # For our demography, we'll have three leaf populations: 'a','b','c', with 10,5,8 sampled alleles respectively ## specify demography via a newick string ## to specify additional population parameters, follow branch length with [&&momi:...] ## where ... contains:
from momi import Demography, ConstantTruncatedSizeHistory, ExponentialTruncatedSizeHistory, PiecewiseHistory ## First, let's compute the SFS for a single population with a three-epoch history n = 20 ## sample size ## specify the epochs backwards in time from the present epochs = [ExponentialTruncatedSizeHistory(n_max=n, tau=0.25, N_top=1.0, N_bottom=10.0), # an exponential growth period for 0.25 units of time. "top"=past, "bottom"=present ConstantTruncatedSizeHistory(n_max = n, tau=0.1, N=0.1), # a bottleneck for 0.1 units of time ConstantTruncatedSizeHistory(n_max = n, tau=float('inf'), N=1.0), # ancestral population size = 1 ] ## turn the list of epochs into a single population history demo1 = PiecewiseHistory(epochs) ## print the SFS entries print "Printing SFS entries for three epoch history" print [demo1.freq(i, n) for i in range(1,n)] ## Next, print out the "truncated SFS" for just the two recent epochs ## i.e., the frequency spectrum for mutations that occur within the two recent epochs epochs_trunc = epochs[:2] demo1_trunc = PiecewiseHistory(epochs_trunc) print "\nPrinting truncated SFS for two recent epochs" print [demo1_trunc.freq(i,n) for i in range(1,n)] ## Finally, let's compute SFS entries for a multipopulation demography # For our demography, we'll have three leaf populations: 'a','b','c', with 10,5,8 sampled alleles respectively