# split-bidirectional-migration model used in δaδi. # The defined model inserted into a modified Demographics2D.py file: def split_bidirmig(params, ns, pts): """ params = (nu1,nu2,T,m12,m21) ns = (n1,n2) Split into two populations of specified size, with bidirectional migration. nu1: Size of population 1 after split. nu2: Size of population 2 after split. T: Time in the past of split (in units of 2*Na generations) m12: Migration rate 2>>1 m21: Migration rate 1>>2 n1,n2: Sample sizes of resulting Spectrum pts: Number of grid points to use in integration. """ # modify params to include bidirectional gene flow nu1,nu2,T,m12,m21 = params # use grid xx = Numerics.default_grid(pts) # use the grid and split pops phi = PhiManip.phi_1D(xx) phi = PhiManip.phi_1D_to_2D(xx, phi) # allow for gene flow between the pops bidirectional m12,m21 phi = Integration.two_pops(phi, xx, T, nu1, nu2, m12=m12, m21=m21) #calculate and return the spectra fs = Spectrum.from_phi(phi, ns, (xx,xx)) return fs def split_bidirmig_mscore(params): """ ms core command for split_bidirmig. """ nu1,nu2,T,m12,m21 = params command = "-n 1 %(nu1)f -n 2 %(nu2)f "\ "-ma x %(m12)f %(m21)f x "\ "-ej %(T)f 2 1 -en %(T)f 1 1" sub_dict = {'nu1':nu1, 'nu2':nu2, 'm12':m12, 'm21':m21, 'T': T/2} return command % sub_dict