def bottleneck(params, ns, pts): 
    nuB,nuF,TB,TF = params
    xx = Numerics.default_grid(pts) # sets up grid
    phi = PhiManip.phi_1D(xx) # sets up initial phi for population 
    phi = Integration.one_pop(phi, xx, TB, nuB)  # bottleneck
    phi = Integration.one_pop(phi, xx, TF, nuF) # recovery 
    fs = Spectrum.from_phi(phi, ns, (xx,)) 
    return fs
def bottleneck_fixedDur(params, ns, pts):
    TB, TF = params  # removed TB because that is fixed at fixed DUR
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(
        phi, xx, TB, 0.01)  # replace TB with fixed duration fors bottleneck
    phi = Integration.one_pop(phi, xx, TF, 0.1)  # recovery
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
Exemplo n.º 3
0
def fourEpoch(params, ns, pts):
    nuREC, nuCUR, tREC, tCUR = params
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(phi, xx, 0.015, 0.23)
    phi = Integration.one_pop(phi, xx, tREC, nuREC)
    phi = Integration.one_pop(phi, xx, tCUR, nuCUR)
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
Exemplo n.º 4
0
def fourEpoch(params, ns, pts):
    nuBOT, nuREC, nuCUR = params
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(phi, xx, 0.013, nuBOT)  # bottleneck 1
    phi = Integration.one_pop(phi, xx, 0.024, nuREC)  # recovery 1
    phi = Integration.one_pop(phi, xx, 0.0013, nuCUR)  # contraction
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
def fourEpoch(params, ns, pts):
    t3, nu3 = params
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(phi, xx, 0.00675, 0.05)
    phi = Integration.one_pop(phi, xx, 0.045, 26)
    phi = Integration.one_pop(phi, xx, t3, nu3)
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
def fourEpoch(params, ns, pts):
    nu2, t2 = params
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(phi, xx, 0.25, 2)
    phi = Integration.one_pop(phi, xx, t2, nu2)
    phi = Integration.one_pop(phi, xx, 0.036, 8)
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
def fiveEpoch(params, ns, pts): 
    nu3,t4,nu4 = params
    xx = Numerics.default_grid(pts) # sets up grid
    phi = PhiManip.phi_1D(xx,theta0 = theta1) # sets up initial phi for population 
    phi = Integration.one_pop(phi, xx, 0.26, 1.87, theta0 = theta1)  
    phi = Integration.one_pop(phi, xx, 0.0055, 0.04, theta0 = theta1) 
    phi = Integration.one_pop(phi, xx, 0.037,nu3, theta0 = theta1)  
    phi = Integration.one_pop(phi, xx, t4, nu4, theta0 = theta1)
    fs = Spectrum.from_phi(phi, ns, (xx,)) 
    return fs
def fourEpoch(params, ns, pts):
    nuBOT, nuREC, nuCUR = params
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(phi, xx, 0.00002,
                              nuBOT)  # NA colonization bottleneck
    phi = Integration.one_pop(phi, xx, 0.03, nuREC)  # recovery
    phi = Integration.one_pop(phi, xx, 0.0006, nuCUR)  # IR founding bottleneck
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
Exemplo n.º 9
0
def double_bottleneck(params, ns, pts):
    nuB1, nuF1, nuB2, nuF2, TB1, TF1, TB2, TF2 = params
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(phi, xx, 0.005, nuB1)  # bottleneck 1
    phi = Integration.one_pop(phi, xx, TF1, nuF1)  # recovery 1
    phi = Integration.one_pop(phi, xx, 0.005, nuB2)  # bottleneck 2
    phi = Integration.one_pop(phi, xx, TF2, nuF2)  # recovery 2
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
Exemplo n.º 10
0
def sandbox(params, ns, pts):
    nuBOT, nuREC = params
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(phi, xx, 0.0005, nuBOT)  # contraction 1
    phi = Integration.one_pop(phi, xx, 0.02, nuREC)  # recovery
    phi = Integration.one_pop(
        phi, xx, 0.0005, 0.005)  # contraction  2 -fix at 20 inds for 4 gen
    # no recovery in between
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
Exemplo n.º 11
0
def custom_model(params, ns, pts):
    nu1, nu2, T1, T2 = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)

    phi = Integration.one_pop(phi, xx, T1, nu1)
    phi = Integration.one_pop(phi, xx, T2, nu2)

    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
def split_4epoch_nomig(params, ns, pts):
    nu1, nu2, t1, t2, nuIR, nuMN = params
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(phi, xx, t1, nu1)
    phi = Integration.one_pop(phi, xx, t2, nu2)
    phi = PhiManip.phi_1D_to_2D(xx, phi)  # split into two pops
    phi = Integration.two_pops(
        phi, xx, 0.0008, nuIR, nuMN, m12=0,
        m21=0)  # two pops at diff sizes with symmetric migration
    fs = Spectrum.from_phi(phi, ns, (xx, xx))
    return fs
Exemplo n.º 13
0
def No_mig(params, ns, pts):
    """
    params = (nuPre,TPre,s,nu1,nu2,T)
    ns = (n1,n2)

    Isolation-with-migration model with exponential pop growth and a size change
    prior to split.

    nuPre: Size after first size change
    TPre: Time before split of first size change.
    s: Fraction of nuPre that goes to pop1. (Pop 2 has size nuPre*(1-s).)
    nu1: Final size of pop 1.
    nu2: Final size of pop 2.
    T: Time in the past of split (in units of 2*Na generations)
    n1,n2: Sample sizes of resulting Spectrum
    pts: Number of grid points to use in integration.
    """
    nuPre, TPre, s, nu1, nu2, T = params

    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, TPre, nu=nuPre)
    phi = PhiManip.phi_1D_to_2D(xx, phi)

    nu1_0 = nuPre * s
    nu2_0 = nuPre * (1 - s)
    nu1_func = lambda t: nu1_0 * (nu1 / nu1_0)**(t / T)
    nu2_func = lambda t: nu2_0 * (nu2 / nu2_0)**(t / T)
    phi = Integration.two_pops(phi, xx, T, nu1_func, nu2_func, m12=0, m21=0)

    fs = Spectrum.from_phi(phi, ns, (xx, xx))
    return fs
Exemplo n.º 14
0
def priorsize_asym_mig(params, ns, pts):
    """
    Size change followed by split with asymmetric migration

    nua: First Size of population before split.
    T1: Duration of first time before split
    nu1b: Size of population 1 after split.
    nu2b: Size of population 2 after split.
    T2: Time in the past of split (units of 2*Na generations)
    m12: Migration from pop 2 to pop 1 (2*Na*m12)
    m21: Migration from pop 1 to pop 2
    """
    nua, T1,nu1b, nu2b, T2, m12, m21 = params
    xx = Numerics.default_grid(pts)
    
    phi = PhiManip.phi_1D(xx)

    phi = Integration.one_pop(phi, xx, T1, nua)

    phi = PhiManip.phi_1D_to_2D(xx, phi)
    
    phi = Integration.two_pops(phi, xx, T2, nu1b, nu2b, m12=m12, m21=m21)
    
    fs = Spectrum.from_phi(phi, ns, (xx,xx))
    
    return fs
def bottlegrowth_split_mig(params, ns, pts):
    """
    params = (nuB,nuF,m,T,Ts)
    ns = (n1,n2)

    Instantanous size change followed by exponential growth then split with
    migration.

    nuB: Ratio of population size after instantanous change to ancient
         population size
    nuF: Ratio of contempoary to ancient population size
    m: Migration rate between the two populations (2*Na*m).
    T: Time in the past at which instantaneous change happened and growth began
       (in units of 2*Na generations) 
    Ts: Time in the past at which the two populations split.
    n1,n2: Sample sizes of resulting Spectrum
    pts: Number of grid points to use in integration.
    """
    nuB, nuF, m, T, Ts = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)

    nu_func = lambda t: nuB * numpy.exp(numpy.log(nuF / nuB) * t / T)
    phi = Integration.one_pop(phi, xx, T - Ts, nu_func)

    phi = PhiManip.phi_1D_to_2D(xx, phi)
    nu0 = nu_func(T - Ts)
    nu_func = lambda t: nu0 * numpy.exp(numpy.log(nuF / nu0) * t / Ts)
    phi = Integration.two_pops(phi, xx, Ts, nu_func, nu_func, m12=m, m21=m)

    fs = Spectrum.from_phi(phi, ns, (xx, xx))
    return fs
Exemplo n.º 16
0
def simple_iso(params, ns, pts):
    """
    params = (nuPre,TPre,nu1,nu2,T)
    ns = (n1,n2)

    Simple migration model, the population size is constant

    nuPre: Size after first size change
    TPre: Time before split of first size change.
    nu1: size of pop 1.
    nu2: size of pop 2.
    T1: Time from divergence to migration end (in units of 2*Na generations)
    T2: Time from migration end to present
    n1,n2: Sample sizes of resulting Spectrum
    pts: Number of grid points to use in integration.
    """
    nuPre,TPre,nu1,nu2,T = params

    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, TPre, nu=nuPre)
    phi = PhiManip.phi_1D_to_2D(xx, phi)

    phi = Integration.two_pops(phi, xx, T, nu1, nu2, m12=0, m21=0)

    fs = Spectrum.from_phi(phi, ns, (xx,xx))
    return fs
Exemplo n.º 17
0
def bottlegrowth(params, ns, pts):
    """
    Instantanous size change followed by exponential growth.

    params = (nuB,nuF,T)
    ns = (n1,)

    nuB: Ratio of population size after instantanous change to ancient
         population size
    nuF: Ratio of contemporary to ancient population size
    T: Time in the past at which instantaneous change happened and growth began
       (in units of 2*Na generations) 
    n1: Number of samples in resulting Spectrum
    pts: Number of grid points to use in integration.
    """
    nuB,nuF,T = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)

    nu_func = lambda t: nuB*numpy.exp(numpy.log(nuF/nuB) * t/T)
    phi = Integration.one_pop(phi, xx, T, nu_func)

    fs = Spectrum.from_phi(phi, ns, (xx,))
    return fs
Exemplo n.º 18
0
def bottlegrowth_split_mig(params, ns, pts):
    """
    params = (nuB,nuF,m,T,Ts)
    ns = (n1,n2)

    Instantanous size change followed by exponential growth then split with
    migration.

    nuB: Ratio of population size after instantanous change to ancient
         population size
    nuF: Ratio of contempoary to ancient population size
    m: Migration rate between the two populations (2*Na*m).
    T: Time in the past at which instantaneous change happened and growth began
       (in units of 2*Na generations) 
    Ts: Time in the past at which the two populations split.
    n1,n2: Sample sizes of resulting Spectrum
    pts: Number of grid points to use in integration.
    """
    nuB,nuF,m,T,Ts = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)

    nu_func = lambda t: nuB*numpy.exp(numpy.log(nuF/nuB) * t/T)
    phi = Integration.one_pop(phi, xx, T-Ts, nu_func)

    phi = PhiManip.phi_1D_to_2D(xx, phi)
    nu0 = nu_func(T-Ts)
    nu_func = lambda t: nu0*numpy.exp(numpy.log(nuF/nu0) * t/Ts)
    phi = Integration.two_pops(phi, xx, Ts, nu_func, nu_func, m12=m, m21=m)

    fs = Spectrum.from_phi(phi, ns, (xx,xx))
    return fs
def twoEpochFixedT(params, ns, pts):
    nu = params
    xx = Numerics.default_grid(pts)  # sets up grid
    phi = PhiManip.phi_1D(xx)  # sets up initial phi for population
    phi = Integration.one_pop(
        phi, xx, 0.001, nu)  # contraction for set duration of ~10 generations
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
def bottleneck_1d(params, n1, pts):
    nuC, T = params
    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, T, nuC)

    model_sfs = Spectrum.from_phi(phi, n1, (xx, ))
    return model_sfs
def bottleneck_1d(params, n1, pts):
    nuC, T = params
    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, T, nuC)

    model_sfs = Spectrum.from_phi(phi, n1, (xx,))
    return model_sfs
Exemplo n.º 22
0
def twopopchanges(params, ns, pts):
    """
    params = (nuB,nuF,TB,TF)

    nuB: Ratio of bottleneck population size to ancient pop size
    nuF: Ratio of contemporary to ancient pop size
    TB: Length of bottleneck (in units of 2*Na generations) 
    TF: Time since bottleneck recovery (in units of 2*Na generations) 

    """
    nuB, nuF, TB, TF = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)

    phi = Integration.one_pop(phi, xx, TB, nuB)
    phi = Integration.one_pop(phi, xx, TF, nuF)

    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
Exemplo n.º 23
0
def custom_model(params, ns, pts):
    nuPre, TPre, nu1, nu2, T, m12, m21 = params

    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, TPre, nu=nuPre)
    phi = PhiManip.phi_1D_to_2D(xx, phi)

    phi = Integration.two_pops(phi, xx, T, nu1, nu2, m12=m12, m21=m21)

    fs = Spectrum.from_phi(phi, ns, (xx, xx))
    return fs
Exemplo n.º 24
0
def three_epoch(params, ns, pts):
    """
    params = (nuB,nuF,TB,TF)
    ns = (n1,)

    nuB: Ratio of bottleneck population size to ancient pop size
    nuF: Ratio of contemporary to ancient pop size
    TB: Length of bottleneck (in units of 2*Na generations) 
    TF: Time since bottleneck recovery (in units of 2*Na generations) 

    n1: Number of samples in resulting Spectrum
    pts: Number of grid points to use in integration.
    """
    nuB,nuF,TB,TF = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)

    phi = Integration.one_pop(phi, xx, TB, nuB)
    phi = Integration.one_pop(phi, xx, TF, nuF)

    fs = Spectrum.from_phi(phi, ns, (xx,))
    return fs
Exemplo n.º 25
0
def growthplusbottle(params, ns, pts):
    """
    Exponential growth beginning some time ago followed by a bobbleneck.

    params = (nuB,nuF,TB,TF)

    nuB: Ratio of population to ancient population size after exponential growth
    nuF: Ratio of contemporary to ancient population size
    TB: Time in the past at which growth began (in units of 2*Na 
       generations) 
    TF: Time in the past at which instantaneous change happened
    """
    nuB, nuF, TB, TF = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)

    nu_func = lambda t: numpy.exp(numpy.log(nuB) * t / TB)
    phi = Integration.one_pop(phi, xx, TB, nu_func)

    phi = Integration.one_pop(phi, xx, TF, nuF)

    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
Exemplo n.º 26
0
def custom_model(params, ns, pts):
    nuPre, TPre, nu1, nu2, T1, T2, f = params

    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, TPre, nu=nuPre)
    phi = PhiManip.phi_1D_to_2D(xx, phi)

    phi = Integration.two_pops(phi, xx, T1, nu1, nu2, m12=0, m21=0)

    phi = PhiManip.phi_2D_admix_2_into_1(phi, f, xx, xx)

    phi = Integration.two_pops(phi, xx, T2, nu1, nu2, m12=0, m21=0)

    fs = Spectrum.from_phi(phi, ns, (xx, xx))
    return fs
Exemplo n.º 27
0
def custom_model(params, ns, pts):
    nuPre, TPre, s, nu1, nu2, T = params

    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, TPre, nu=nuPre)
    phi = PhiManip.phi_1D_to_2D(xx, phi)

    nu1_0 = nuPre * s
    nu2_0 = nuPre * (1 - s)
    nu1_func = lambda t: nu1_0 * (nu1 / nu1_0)**(t / T)
    nu2_func = lambda t: nu2_0 * (nu2 / nu2_0)**(t / T)
    phi = Integration.two_pops(phi, xx, T, nu1_func, nu2_func, m12=0, m21=0)

    fs = Spectrum.from_phi(phi, ns, (xx, xx))
    return fs
Exemplo n.º 28
0
def growth(params, ns, pts):
    """
    Exponential growth beginning some time ago.

    params = (nu,T)
    
    nu: Ratio of contemporary to ancient population size
    T: Time in the past at which growth began (in units of 2*Na 
       generations) 
    """
    nu, T = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)

    nu_func = lambda t: numpy.exp(numpy.log(nu) * t / T)
    phi = Integration.one_pop(phi, xx, T, nu_func)

    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
Exemplo n.º 29
0
def two_epoch(params, ns, pts):
    """
    Instantaneous size change some time ago.

    params = (nu,T)
    ns = (n1,)

    nu: Ratio of contemporary to ancient population size
    T: Time in the past at which size change happened (in units of 2*Na 
       generations) 
    n1: Number of samples in resulting Spectrum
    pts: Number of grid points to use in integration.
    """
    nu,T = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)
    
    phi = Integration.one_pop(phi, xx, T, nu)

    fs = Spectrum.from_phi(phi, ns, (xx,))
    return fs
Exemplo n.º 30
0
def growth(params, ns, pts):
    """
    Exponential growth beginning some time ago.

    params = (nu,T)
    ns = (n1,)

    nu: Ratio of contemporary to ancient population size
    T: Time in the past at which growth began (in units of 2*Na 
       generations) 
    n1: Number of samples in resulting Spectrum
    pts: Number of grid points to use in integration.
    """
    nu,T = params

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx)

    nu_func = lambda t: numpy.exp(numpy.log(nu) * t/T)
    phi = Integration.one_pop(phi, xx, T, nu_func)

    fs = Spectrum.from_phi(phi, ns, (xx,))
    return fs
Exemplo n.º 31
0
def IM_pre(params, ns, pts):
    """
    params = (nuPre,TPre,s,nu1,nu2,T,m12,m21)
    ns = (n1,n2)

    Isolation-with-migration model with exponential pop growth and a size change
    prior to split.

    nuPre: Size after first size change
    TPre: Time before split of first size change.
    s: Fraction of nuPre that goes to pop1. (Pop 2 has size nuPre*(1-s).)
    nu1: Final size of pop 1.
    nu2: Final size of pop 2.
    T: Time in the past of split (in units of 2*Na generations) 
    m12: Migration from pop 2 to pop 1 (2*Na*m12)
    m21: Migration from pop 1 to pop 2
    n1,n2: Sample sizes of resulting Spectrum
    pts: Number of grid points to use in integration.
    """
    nuPre,TPre,s,nu1,nu2,T,m12,m21 = params

    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, TPre, nu=nuPre)
    phi = PhiManip.phi_1D_to_2D(xx, phi)

    nu1_0 = nuPre*s
    nu2_0 = nuPre*(1-s)
    nu1_func = lambda t: nu1_0 * (nu1/nu1_0)**(t/T)
    nu2_func = lambda t: nu2_0 * (nu2/nu2_0)**(t/T)
    phi = Integration.two_pops(phi, xx, T, nu1_func, nu2_func,
                               m12=m12, m21=m21)

    fs = Spectrum.from_phi(phi, ns, (xx,xx))
    return fs
Exemplo n.º 32
0
          0.00320305953600002, 0.00392030906399995, 0.00505418013100008,
          0.00712323213699992, 0.012177548731)


def nso_model_trim_39(
    (nu38, nu37, nu36, nu35, nu34, nu33, nu32, nu31, nu30, nu29, nu28, nu27,
     nu26, nu25, nu24, nu23, nu22, nu21, nu20, nu19, nu18, nu17, nu16, nu15,
     nu14, nu13, nu12, nu11, nu10, nu9, nu8, nu7, nu6, nu5, nu4, nu3, nu2, nu1,
     nu0, T38, T37, T36, T35, T34, T33, T32, T31, T30, T29, T28, T27, T26, T25,
     T24, T23, T22, T21, T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10,
     T9, T8, T7, T6, T5, T4, T3, T2, T1, T0), ns, pts):
    xx = Numerics.default_grid(pts)
    # intialize phi with ancestral pop: (nu0 = 1)
    phi = PhiManip.phi_1D(xx, nu=nu0)
    # stays at nu0 for T0 duration of time:
    phi = Integration.one_pop(phi, xx, T0, nu0)
    # followed by a number of time steps, with associated pop changes:
    phi = Integration.one_pop(phi, xx, T0, nu0)
    phi = Integration.one_pop(phi, xx, T1, nu1)
    phi = Integration.one_pop(phi, xx, T2, nu2)
    phi = Integration.one_pop(phi, xx, T3, nu3)
    phi = Integration.one_pop(phi, xx, T4, nu4)
    phi = Integration.one_pop(phi, xx, T5, nu5)
    phi = Integration.one_pop(phi, xx, T6, nu6)
    phi = Integration.one_pop(phi, xx, T7, nu7)
    phi = Integration.one_pop(phi, xx, T8, nu8)
    phi = Integration.one_pop(phi, xx, T9, nu9)
    phi = Integration.one_pop(phi, xx, T10, nu10)
    phi = Integration.one_pop(phi, xx, T11, nu11)
    phi = Integration.one_pop(phi, xx, T12, nu12)
    phi = Integration.one_pop(phi, xx, T13, nu13)
Exemplo n.º 33
0
def psmc_100steps(params, ns, pts_l):

    nu99, nu98, nu97, nu96, nu95, nu94, nu93, nu92, nu91, nu90, nu89, nu88, nu87, nu86, nu85, nu84, nu83, nu82, nu81, nu80, nu79, nu78, nu77, nu76, nu75, nu74, nu73, nu72, nu71, nu70, nu69, nu68, nu67, nu66, nu65, nu64, nu63, nu62, nu61, nu60, nu59, nu58, nu57, nu56, nu55, nu54, nu53, nu52, nu51, nu50, nu49, nu48, nu47, nu46, nu45, nu44, nu43, nu42, nu41, nu40, nu39, nu38, nu37, nu36, nu35, nu34, nu33, nu32, nu31, nu30, nu29, nu28, nu27, nu26, nu25, nu24, nu23, nu22, nu21, nu20, nu19, nu18, nu17, nu16, nu15, nu14, nu13, nu12, nu11, nu10, nu9, nu8, nu7, nu6, nu5, nu4, nu3, nu2, nu1, nuA, T99, T98, T97, T96, T95, T94, T93, T92, T91, T90, T89, T88, T87, T86, T85, T84, T83, T82, T81, T80, T79, T78, T77, T76, T75, T74, T73, T72, T71, T70, T69, T68, T67, T66, T65, T64, T63, T62, T61, T60, T59, T58, T57, T56, T55, T54, T53, T52, T51, T50, T49, T48, T47, T46, T45, T44, T43, T42, T41, T40, T39, T38, T37, T36, T35, T34, T33, T32, T31, T30, T29, T28, T27, T26, T25, T24, T23, T22, T21, T20, T19, T18, T17, T16, T15, T14, T13, T12, T11, T10, T9, T8, T7, T6, T5, T4, T3, T2, T1, T0 = params

    xx = Numerics.default_grid(pts_l)
    # initial phi with ancestral pop: (nuA = 1)
    phi = PhiManip.phi_1D(xx, nu=nuA)
    # stays at nuA for T0 duration of time:
    phi = Integration.one_pop(phi, xx, T0, nuA)
    # followed by a number of time steps, with associated pop changes:
    phi = Integration.one_pop(phi, xx, T1, nu1)
    phi = Integration.one_pop(phi, xx, T2, nu2)
    phi = Integration.one_pop(phi, xx, T3, nu3)
    phi = Integration.one_pop(phi, xx, T4, nu4)
    phi = Integration.one_pop(phi, xx, T5, nu5)
    phi = Integration.one_pop(phi, xx, T6, nu6)
    phi = Integration.one_pop(phi, xx, T7, nu7)
    phi = Integration.one_pop(phi, xx, T8, nu8)
    phi = Integration.one_pop(phi, xx, T9, nu9)
    phi = Integration.one_pop(phi, xx, T10, nu10)
    phi = Integration.one_pop(phi, xx, T11, nu11)
    phi = Integration.one_pop(phi, xx, T12, nu12)
    phi = Integration.one_pop(phi, xx, T13, nu13)
    phi = Integration.one_pop(phi, xx, T14, nu14)
    phi = Integration.one_pop(phi, xx, T15, nu15)
    phi = Integration.one_pop(phi, xx, T16, nu16)
    phi = Integration.one_pop(phi, xx, T17, nu17)
    phi = Integration.one_pop(phi, xx, T18, nu18)
    phi = Integration.one_pop(phi, xx, T19, nu19)
    phi = Integration.one_pop(phi, xx, T20, nu20)
    phi = Integration.one_pop(phi, xx, T21, nu21)
    phi = Integration.one_pop(phi, xx, T22, nu22)
    phi = Integration.one_pop(phi, xx, T23, nu23)
    phi = Integration.one_pop(phi, xx, T24, nu24)
    phi = Integration.one_pop(phi, xx, T25, nu25)
    phi = Integration.one_pop(phi, xx, T26, nu26)
    phi = Integration.one_pop(phi, xx, T27, nu27)
    phi = Integration.one_pop(phi, xx, T28, nu28)
    phi = Integration.one_pop(phi, xx, T29, nu29)
    phi = Integration.one_pop(phi, xx, T30, nu30)
    phi = Integration.one_pop(phi, xx, T31, nu31)
    phi = Integration.one_pop(phi, xx, T32, nu32)
    phi = Integration.one_pop(phi, xx, T33, nu33)
    phi = Integration.one_pop(phi, xx, T34, nu34)
    phi = Integration.one_pop(phi, xx, T35, nu35)
    phi = Integration.one_pop(phi, xx, T36, nu36)
    phi = Integration.one_pop(phi, xx, T37, nu37)
    phi = Integration.one_pop(phi, xx, T38, nu38)
    phi = Integration.one_pop(phi, xx, T39, nu39)
    phi = Integration.one_pop(phi, xx, T40, nu40)
    phi = Integration.one_pop(phi, xx, T41, nu41)
    phi = Integration.one_pop(phi, xx, T42, nu42)
    phi = Integration.one_pop(phi, xx, T43, nu43)
    phi = Integration.one_pop(phi, xx, T44, nu44)
    phi = Integration.one_pop(phi, xx, T45, nu45)
    phi = Integration.one_pop(phi, xx, T46, nu46)
    phi = Integration.one_pop(phi, xx, T47, nu47)
    phi = Integration.one_pop(phi, xx, T48, nu48)
    phi = Integration.one_pop(phi, xx, T49, nu49)
    phi = Integration.one_pop(phi, xx, T50, nu50)
    phi = Integration.one_pop(phi, xx, T51, nu51)
    phi = Integration.one_pop(phi, xx, T52, nu52)
    phi = Integration.one_pop(phi, xx, T53, nu53)
    phi = Integration.one_pop(phi, xx, T54, nu54)
    phi = Integration.one_pop(phi, xx, T55, nu55)
    phi = Integration.one_pop(phi, xx, T56, nu56)
    phi = Integration.one_pop(phi, xx, T57, nu57)
    phi = Integration.one_pop(phi, xx, T58, nu58)
    phi = Integration.one_pop(phi, xx, T59, nu59)
    phi = Integration.one_pop(phi, xx, T60, nu60)
    phi = Integration.one_pop(phi, xx, T61, nu61)
    phi = Integration.one_pop(phi, xx, T62, nu62)
    phi = Integration.one_pop(phi, xx, T63, nu63)
    phi = Integration.one_pop(phi, xx, T64, nu64)
    phi = Integration.one_pop(phi, xx, T65, nu65)
    phi = Integration.one_pop(phi, xx, T66, nu66)
    phi = Integration.one_pop(phi, xx, T67, nu67)
    phi = Integration.one_pop(phi, xx, T68, nu68)
    phi = Integration.one_pop(phi, xx, T69, nu69)
    phi = Integration.one_pop(phi, xx, T70, nu70)
    phi = Integration.one_pop(phi, xx, T71, nu71)
    phi = Integration.one_pop(phi, xx, T72, nu72)
    phi = Integration.one_pop(phi, xx, T73, nu73)
    phi = Integration.one_pop(phi, xx, T74, nu74)
    phi = Integration.one_pop(phi, xx, T75, nu75)
    phi = Integration.one_pop(phi, xx, T76, nu76)
    phi = Integration.one_pop(phi, xx, T77, nu77)
    phi = Integration.one_pop(phi, xx, T78, nu78)
    phi = Integration.one_pop(phi, xx, T79, nu79)
    phi = Integration.one_pop(phi, xx, T80, nu80)
    phi = Integration.one_pop(phi, xx, T81, nu81)
    phi = Integration.one_pop(phi, xx, T82, nu82)
    phi = Integration.one_pop(phi, xx, T83, nu83)
    phi = Integration.one_pop(phi, xx, T84, nu84)
    phi = Integration.one_pop(phi, xx, T85, nu85)
    phi = Integration.one_pop(phi, xx, T86, nu86)
    phi = Integration.one_pop(phi, xx, T87, nu87)
    phi = Integration.one_pop(phi, xx, T88, nu88)
    phi = Integration.one_pop(phi, xx, T89, nu89)
    phi = Integration.one_pop(phi, xx, T90, nu90)
    phi = Integration.one_pop(phi, xx, T91, nu91)
    phi = Integration.one_pop(phi, xx, T92, nu92)
    phi = Integration.one_pop(phi, xx, T93, nu93)
    phi = Integration.one_pop(phi, xx, T94, nu94)
    phi = Integration.one_pop(phi, xx, T95, nu95)
    phi = Integration.one_pop(phi, xx, T96, nu96)
    phi = Integration.one_pop(phi, xx, T97, nu97)
    phi = Integration.one_pop(phi, xx, T98, nu98)
    phi = Integration.one_pop(phi, xx, T99, nu99)

    # get sfs:
    fs = Spectrum.from_phi(phi, ns, (xx, ))
    return fs
fs=dadi.Spectrum.from_file(sfs) # this is folded from easy SFS
# check if it's folded, if not folded, fold it
if fs.folded==False:
    fs=fs.fold()
else:
    fs=fs
############### Set up General Dadi Parameters ########################
ns = fs.sample_sizes # get sample size from SFS (in haploids)
pts_l = [ns[0]+5,ns[0]+15,ns[0]+25] # this should be slightly larger (+5) than sample size and increase by 10
############### Set up Specific Model -- this will change from script to script ########################

def sso_model_trim_22_simplify((nu1, T1),ns,pts):
	xx = Numerics.default_grid(pts)
	# intialize phi with ancestral pop: (nu0 = 1)
	phi = PhiManip.phi_1D(xx,nu=1)
	phi = Integration.one_pop(phi, xx, 0.125, 0.5)
	phi = Integration.one_pop(phi, xx, T1, nu1)
	# get expected SFS:
	fs = Spectrum.from_phi(phi,ns,(xx,))
	return fs
param_names=("nu1","T1")



upper_bound = [10, 2]
lower_bound = [1e-4, 1e-4]
p0 = [0.01,0.1] # initial parameters


func=sso_model_trim_22_simplify # set the function
Exemplo n.º 35
0
    m12: Rate of migration into 1 from 2
    m13: Rate of migration into 1 from 3
    m21: Rate of migration into 2 from 1
    m23: Rate of migration into 2 from 3
    m31: Rate of migration into 3 from 1
    m32: Rate of migration into 3 from 2
    """

    #create grid
    xx = dadi.Numerics.default_grid(pts)

    #phi for equilibrium ancestral population
    phi=PhiManip.phi_1D(xx)

    # Ancestral population growth
    phi = Integration.one_pop(phi, xx, T=T1, nu=nu1F)

    #split of population 2 from 1
    phi=PhiManip.phi_1D_to_2D(xx, phi)

    #bottleneck in population 2
    phi=Integration.two_pops(phi=phi, xx=xx, T=T2B, nu1=nu1F, nu2=nu2B)

    #migration between population 2 and 1
    phi=Integration.two_pops(phi, xx, T=T2, nu1=nu1F, nu2=nu2F, m12=m12, m21=m21)

    #split of population 3 from 1
    phi=PhiManip.phi_2D_to_3D_split_1(xx, phi)

    #bottleneck in population 3
    phi=Integration.three_pops(phi, xx, T=T3B, nu1=nu1F, nu2=nu2F, nu3=nu3B)
Exemplo n.º 36
0
import numpy
from dadi import Numerics, PhiManip, Integration, Spectrum

def OutOfAfrica((nuAf, nuB, nuEu0, nuEu, nuAs0, nuAs, 
                 mAfB, mAfEu, mAfAs, mEuAs, TAf, TB, TEuAs), (n1,n2,n3), pts):
    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, TAf, nu=nuAf)

    phi = PhiManip.phi_1D_to_2D(xx, phi)
    phi = Integration.two_pops(phi, xx, TB, nu1=nuAf, nu2=nuB, 
                               m12=mAfB, m21=mAfB)

    phi = PhiManip.phi_2D_to_3D_split_2(xx, phi)

    nuEu_func = lambda t: nuEu0*(nuEu/nuEu0)**(t/TEuAs)
    nuAs_func = lambda t: nuAs0*(nuAs/nuAs0)**(t/TEuAs)
    phi = Integration.three_pops(phi, xx, TEuAs, nu1=nuAf, 
                                 nu2=nuEu_func, nu3=nuAs_func, 
                                 m12=mAfEu, m13=mAfAs, m21=mAfEu, m23=mEuAs,
                                 m31=mAfAs, m32=mEuAs)

    fs = Spectrum.from_phi(phi, (n1,n2,n3), (xx,xx,xx))
    return fs

def OutOfAfrica_mscore((nuAf, nuB, nuEu0, nuEu, nuAs0, nuAs,
                        mAfB, mAfEu, mAfAs, mEuAs, TAf, TB, TEuAs)):

    alphaEu = numpy.log(nuEu/nuEu0)/TEuAs
    alphaAs = numpy.log(nuAs/nuAs0)/TEuAs
Exemplo n.º 37
0
def simple_canary((nuIb0, nuIb, nuMo0, nuMo, nuCa0, TIbMo, TMoCa, TF),
    ns, pts):
    """
    nuIb0: starting Iberian population size
    nuIb: ending Iberian population size
    nuMo0: starting Moroccan population size
    nuMo: ending Morrocan population size
    nuCa0: starting Canary island population size
    TIbMo: split time for Iberian and Moroccan populations
    TMoCa: split time for Moroccan and Canary island populations
    TF: simulation ending time
    """
    xx = Numerics.default_grid(pts)

    phi = PhiManip.phi_1D(xx)
    phi = Integration.one_pop(phi, xx, TIbMo, nu=nuIb0)

    phi = PhiManip.phi_1D_to_2D(xx, phi)
    phi = Integration.two_pops(phi, xx, TMoCa, nu1=nuIb, nu2=nuMo0)

    phi = PhiManip.phi_2D_to_3D_split_2(xx, phi)
    phi = Integration.three_pops(phi, xx, TF, nu1=nuIb, nu2=nuMo, nu3=nuCa0)


    fs = Spectrum.from_phi(phi, ns, (xx,xx,xx))

    return fs

def simple_canary_migration((nuIb0, nuIb, nuMo0, nuMo, nuCa0, TIbMo, TMoCa, mIbCa, TF),
    ns, pts):
    """