Module dadi.Polyploidy.allo_demographics_sel

Functions

def bottlegrowth_sel(params, ns, pts)
Expand source code
def bottlegrowth_sel(params, ns, pts):
    """
    Bottlegrowth model of allotetraploid formation where the 
    allotetraploid population starts with size nuWGD and 
    grows exponentially to a size of nuF
    
    Parameters:
        params (tuple): (T_div, T_WGD, nuWGD, nuF, H)
            - T_div: Divergence period between the two diploid progenitors 
               (in units of 2*Na generations).

            - T_WGD: Time in the past at which the WGD occurred, creating the  
               allotetraploid population (in units of 2*Na generations).

            - nuWGD: Ratio of allotetraploid population immediately after WGD
                to ancestral diploid population size (ratio of *census* sizes).

            - nuF: Ratio of contemporary allotetraploid population
                to ancestral diploid population size (ratio of *census* sizes).

            - H: homoeologous exchange rate (in terms of 2*Na*eta)

            - gamma: population-scaled selection coefficient (= 2*Na*s)
        ns (tuple): Sample sizes (n1,n2).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting frequency spectrum.
    """
    T_div, T_WGD, nuWGD, nuF, H, gamma = params
    nu_f = lambda t: nuWGD*numpy.exp(numpy.log(nuF/nuWGD) * t/T_WGD)
    alloaflag = PolyInt.PloidyType.ALLOa
    allobflag = PolyInt.PloidyType.ALLOb
    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx, gamma=gamma)
    phi = PhiManip.phi_1D_to_2D(xx, phi)
    phi = PolyInt.two_pops(phi, xx, T_div, sel_dict1={"gamma": gamma}, sel_dict2={"gamma": gamma})
    phi = PolyInt.two_pops(phi, xx, T_WGD, nu1=nu_f, nu2=nu_f, m12=H, m21=H,
                           sel_dict1={"gamma": gamma}, sel_dict2={"gamma": gamma},
                           ploidyflag1=alloaflag, ploidyflag2=allobflag)
    fs = Spectrum.from_phi(phi, ns, (xx,xx))
    return fs

Bottlegrowth model of allotetraploid formation where the allotetraploid population starts with size nuWGD and grows exponentially to a size of nuF

Parameters

params (tuple): (T_div, T_WGD, nuWGD, nuF, H) - T_div: Divergence period between the two diploid progenitors (in units of 2*Na generations).

- T_WGD: Time in the past at which the WGD occurred, creating the  
   allotetraploid population (in units of 2*Na generations).

- nuWGD: Ratio of allotetraploid population immediately after WGD
    to ancestral diploid population size (ratio of *census* sizes).

- nuF: Ratio of contemporary allotetraploid population
    to ancestral diploid population size (ratio of *census* sizes).

- H: homoeologous exchange rate (in terms of 2*Na*eta)

- gamma: population-scaled selection coefficient (= 2*Na*s)

ns (tuple): Sample sizes (n1,n2). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting frequency spectrum.

def bottlegrowth_sel_noHE(params, ns, pts)
Expand source code
def bottlegrowth_sel_noHE(params, ns, pts):
    """
    Bottlegrowth model of allotetraploid formation where the 
    allotetraploid population starts with size nuWGD and 
    grows exponentially to a size of nuF
    
    Parameters:
        params (tuple): (T_div, T_WGD, nuWGD, nuF)
            - T_div: Divergence period between the two diploid progenitors 
               (in units of 2*Na generations).

            - T_WGD: Time in the past at which the WGD occurred, creating the  
               allotetraploid population (in units of 2*Na generations).

            - nuWGD: Ratio of allotetraploid population immediately after WGD
                to ancestral diploid population size (ratio of *census* sizes).

            - nuF: Ratio of contemporary allotetraploid population
                to ancestral diploid population size (ratio of *census* sizes).

            - gamma: population-scaled selection coefficient (= 2*Na*s)
        ns (tuple): Sample sizes (n1,n2).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting frequency spectrum.
    """
    T_div, T_WGD, nuWGD, nuF, gamma = params
    fs = bottlegrowth_sel((T_div, T_WGD, nuWGD, nuF, 0, gamma), ns, pts)
    return fs

Bottlegrowth model of allotetraploid formation where the allotetraploid population starts with size nuWGD and grows exponentially to a size of nuF

Parameters

params (tuple): (T_div, T_WGD, nuWGD, nuF) - T_div: Divergence period between the two diploid progenitors (in units of 2*Na generations).

- T_WGD: Time in the past at which the WGD occurred, creating the  
   allotetraploid population (in units of 2*Na generations).

- nuWGD: Ratio of allotetraploid population immediately after WGD
    to ancestral diploid population size (ratio of *census* sizes).

- nuF: Ratio of contemporary allotetraploid population
    to ancestral diploid population size (ratio of *census* sizes).

- gamma: population-scaled selection coefficient (= 2*Na*s)

ns (tuple): Sample sizes (n1,n2). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting frequency spectrum.

def bottleneck_asym_mig_w_dips_sel(params, ns, pts)
Expand source code
def bottleneck_asym_mig_w_dips_sel(params, ns, pts):
    """
    Three population (4D) model of allotetraploid formation where 
    the diploid progenitors diverge and then a WGD event occurs 
    forming the allotetraploid population.

    Parameters:
        params (tuple): (T_div, T_WGD, nu_allo, H, m31, m42)

            - T_div: Time in the past at which the diploid progenitors diverge 
               (in units of 2*Na generations).

            - T_WGD: Time in the past at which the WGD occurred, creating the  
               allotetraploid population (in units of 2*Na generations).

            - nu_allo: Ratio of contemporary allotetraploid to ancestral diploid population size 
               (ratio of *census* sizes).

            - H: homoeologous exchange rate between the two subgenomes, = 4*Na*eta
                (similar to a migration rate, see Blishcak et al. 2023 for details).

            - m31: migration rate from pop 1 (diploid progenitor A) into pop 3 (subgenome A)

            - m42: migration rate from pop 1 (diploid progenitor B) into pop 4 (subgenome B)

            - gamma: population-scaled selection coefficient (= 2*Na*s)
                Note that this is used for both the diploid and allotetraploid populations.
        ns (tuple): Sample sizes (n1, n2, n3, n4).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting frequency spectrum.

    Raises:
        ValueError: If `params` does not contain the expected number of elements.
    """
    T_div, T_WGD, nu_allo, H, m31, m42, gamma = params
    
    alloaflag = PolyInt.PloidyType.ALLOa
    allobflag = PolyInt.PloidyType.ALLOb

    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx, gamma=gamma)
    phi = PhiManip.phi_1D_to_2D(xx, phi)

    # integrate for T_div-T_WGD to model the diploid progenitors diverging
    phi = PolyInt.two_pops(phi, xx, T_div-T_WGD, sel_dict1={"gamma": gamma}, sel_dict2={"gamma": gamma})

    # create the allotetraploid population from the two diploid progenitors
    # the third dimension will be subgenome A entirely derived from the first diploid pop
    phi = PhiManip.phi_2D_to_3D(phi, 1, xx, xx, xx)
    # the fourth dimension will be subgenome B entirely derived from the second diploid pop
    phi = PhiManip.phi_3D_to_4D(phi, 0, 1, xx, xx, xx, xx)

    # then, integrate forward for a period of T_WGD
    phi = PolyInt.four_pops(phi, xx, T_WGD, m31=m31, m42=m42, m34=H, m43=H,
                            sel_dict1={"gamma": gamma}, sel_dict2={"gamma": gamma},
                            sel_dict3={"gamma": gamma}, sel_dict4={"gamma": gamma},
                            nu1=1, nu2=1, nu3=nu_allo, nu4=nu_allo,
                            ploidyflag3=alloaflag, ploidyflag4=allobflag)
    
    fs = Spectrum.from_phi(phi, ns, (xx,xx,xx,xx))
    return fs

Three population (4D) model of allotetraploid formation where the diploid progenitors diverge and then a WGD event occurs forming the allotetraploid population.

Parameters

params (tuple): (T_div, T_WGD, nu_allo, H, m31, m42)

- T_div: Time in the past at which the diploid progenitors diverge 
   (in units of 2*Na generations).

- T_WGD: Time in the past at which the WGD occurred, creating the  
   allotetraploid population (in units of 2*Na generations).

- nu_allo: Ratio of contemporary allotetraploid to ancestral diploid population size 
   (ratio of *census* sizes).

- H: homoeologous exchange rate between the two subgenomes, = 4*Na*eta
    (similar to a migration rate, see Blishcak et al. 2023 for details).

- m31: migration rate from pop 1 (diploid progenitor A) into pop 3 (subgenome A)

- m42: migration rate from pop 1 (diploid progenitor B) into pop 4 (subgenome B)

- gamma: population-scaled selection coefficient (= 2*Na*s)
    Note that this is used for both the diploid and allotetraploid populations.

ns (tuple): Sample sizes (n1, n2, n3, n4). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting frequency spectrum.

Raises

ValueError
If params does not contain the expected number of elements.
def bottleneck_mig_w_dips_sel(params, ns, pts)
Expand source code
def bottleneck_mig_w_dips_sel(params, ns, pts):
    """
    Three population (4D) model of allotetraploid formation where 
    the diploid progenitors diverge and then a WGD event occurs 
    forming the allotetraploid population.

    Parameters:
        params (tuple): (T_div, T_WGD, nu_allo, H, m)

            - T_div: Time in the past at which the diploid progenitors diverge 
               (in units of 2*Na generations).

            - T_WGD: Time in the past at which the WGD occurred, creating the  
               allotetraploid population (in units of 2*Na generations).

            - nu_allo: Ratio of contemporary allotetraploid to ancestral diploid population size 
               (ratio of *census* sizes).

            - H: homoeologous exchange rate between the two subgenomes, = 4*Na*eta
                (similar to a migration rate, see Blishcak et al. 2023 for details).

            - m: migration rate from pop 1 (diploid progenitor A) into pop 3 (subgenome A) and 
                 from pop 2 (diploid progenitor B) into pop 4 (subgenome B)

            - gamma: population-scaled selection coefficient (= 2*Na*s)
                Note that this is used for both the diploid and allotetraploid populations.
        ns (tuple): Sample sizes (n1, n2, n3, n4).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting frequency spectrum.

    Raises:
        ValueError: If `params` does not contain the expected number of elements.
    """
    T_div, T_WGD, nu_allo, H, m, gamma = params
    return bottleneck_asym_mig_w_dips_sel((T_div, T_WGD, nu_allo, H, m, m, gamma), ns, pts)

Three population (4D) model of allotetraploid formation where the diploid progenitors diverge and then a WGD event occurs forming the allotetraploid population.

Parameters

params (tuple): (T_div, T_WGD, nu_allo, H, m)

- T_div: Time in the past at which the diploid progenitors diverge 
   (in units of 2*Na generations).

- T_WGD: Time in the past at which the WGD occurred, creating the  
   allotetraploid population (in units of 2*Na generations).

- nu_allo: Ratio of contemporary allotetraploid to ancestral diploid population size 
   (ratio of *census* sizes).

- H: homoeologous exchange rate between the two subgenomes, = 4*Na*eta
    (similar to a migration rate, see Blishcak et al. 2023 for details).

- m: migration rate from pop 1 (diploid progenitor A) into pop 3 (subgenome A) and 
     from pop 2 (diploid progenitor B) into pop 4 (subgenome B)

- gamma: population-scaled selection coefficient (= 2*Na*s)
    Note that this is used for both the diploid and allotetraploid populations.

ns (tuple): Sample sizes (n1, n2, n3, n4). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting frequency spectrum.

Raises

ValueError
If params does not contain the expected number of elements.
def bottleneck_noHE_w_dips_sel(params, ns, pts)
Expand source code
def bottleneck_noHE_w_dips_sel(params, ns, pts):
    """
    Three population (4D) model of allotetraploid formation where 
    the diploid progenitors diverge and then a WGD event occurs 
    forming the allotetraploid population without HEs.

    Parameters:
        params (tuple): (T_div, T_WGD, nu_allo)

            - T_div: Time in the past at which the diploid progenitors diverge 
               (in units of 2*Na generations).

            - T_WGD: Time in the past at which the WGD occurred, creating the  
               allotetraploid population (in units of 2*Na generations).

            - nu_allo: Ratio of contemporary allotetraploid to ancestral diploid population size 
               (ratio of *census* sizes).

            - gamma: population-scaled selection coefficient (= 2*Na*s)
                Note that this is used for both the diploid and allotetraploid populations.
        ns (tuple): Sample sizes (n1, n2, n3, n4).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting frequency spectrum.

    Raises:
        ValueError: If `params` does not contain the expected number of elements.
    """
    T_div, T_WGD, nu_allo, gamma = params
    return bottleneck_asym_mig_w_dips_sel((T_div, T_WGD, nu_allo, 0, 0, 0, gamma), ns, pts)

Three population (4D) model of allotetraploid formation where the diploid progenitors diverge and then a WGD event occurs forming the allotetraploid population without HEs.

Parameters

params (tuple): (T_div, T_WGD, nu_allo)

- T_div: Time in the past at which the diploid progenitors diverge 
   (in units of 2*Na generations).

- T_WGD: Time in the past at which the WGD occurred, creating the  
   allotetraploid population (in units of 2*Na generations).

- nu_allo: Ratio of contemporary allotetraploid to ancestral diploid population size 
   (ratio of *census* sizes).

- gamma: population-scaled selection coefficient (= 2*Na*s)
    Note that this is used for both the diploid and allotetraploid populations.

ns (tuple): Sample sizes (n1, n2, n3, n4). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting frequency spectrum.

Raises

ValueError
If params does not contain the expected number of elements.
def bottleneck_w_dips_sel(params, ns, pts)
Expand source code
def bottleneck_w_dips_sel(params, ns, pts):
    """
    Three population (4D) model of allotetraploid formation where 
    the diploid progenitors diverge and then a WGD event occurs 
    forming the allotetraploid population.

    Parameters:
        params (tuple): (T_div, T_WGD, nu_allo, H)

            - T_div: Time in the past at which the diploid progenitors diverge 
               (in units of 2*Na generations).

            - T_WGD: Time in the past at which the WGD occurred, creating the  
               allotetraploid population (in units of 2*Na generations).

            - nu_allo: Ratio of contemporary allotetraploid to ancestral diploid population size 
               (ratio of *census* sizes).

            - H: homoeologous exchange rate between the two subgenomes, = 4*Na*eta
                (similar to a migration rate, see Blishcak et al. 2023 for details).

            - gamma: population-scaled selection coefficient (= 2*Na*s)
                Note that this is used for both the diploid and allotetraploid populations.
        ns (tuple): Sample sizes (n1, n2, n3, n4).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting frequency spectrum.

    Raises:
        ValueError: If `params` does not contain the expected number of elements.
    """
    T_div, T_WGD, nu_allo, H, gamma = params
    return bottleneck_asym_mig_w_dips_sel((T_div, T_WGD, nu_allo, H, 0, 0, gamma), ns, pts)

Three population (4D) model of allotetraploid formation where the diploid progenitors diverge and then a WGD event occurs forming the allotetraploid population.

Parameters

params (tuple): (T_div, T_WGD, nu_allo, H)

- T_div: Time in the past at which the diploid progenitors diverge 
   (in units of 2*Na generations).

- T_WGD: Time in the past at which the WGD occurred, creating the  
   allotetraploid population (in units of 2*Na generations).

- nu_allo: Ratio of contemporary allotetraploid to ancestral diploid population size 
   (ratio of *census* sizes).

- H: homoeologous exchange rate between the two subgenomes, = 4*Na*eta
    (similar to a migration rate, see Blishcak et al. 2023 for details).

- gamma: population-scaled selection coefficient (= 2*Na*s)
    Note that this is used for both the diploid and allotetraploid populations.

ns (tuple): Sample sizes (n1, n2, n3, n4). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting frequency spectrum.

Raises

ValueError
If params does not contain the expected number of elements.
def three_epoch_sel(params, ns, pts)
Expand source code
def three_epoch_sel(params, ns, pts):
    """
    Three epoch model of allotetraploid formation where the 
    allotetraploid population splits, maintains a size of nuWGD for T_WGD, 
    and then changes size again to nuF for a period of TF.
    This is similar to having a bottleneck for some period and then recover after the bottleneck.
    
    Parameters:
        params (tuple): (T_WGD, TF, nuWGD, nuF, H)
            - T_div: Divergence period between the two diploid progenitors 
               (in units of 2*Na generations).

            - T_WGD: Time length between the WGD event and second size change, creating the  
               allotetraploid population (in units of 2*Na generations).

            - TF: Time in the past at which the second epoch begins.

            - nuWGD: Ratio of initial allotetraploid population (during first epoch)
                 to ancestral diploid population size (ratio of *census* sizes).

            - nuF: Ratio of contemporary allotetraploid population (during second epoch)
                 to ancestral diploid population size (ratio of *census* sizes).

            - H: homoeologous exchange rate (in terms of 2*Na*eta)

            - gamma: population-scaled selection coefficient (= 2*Na*s)
        ns (tuple): Sample sizes (n1,n2).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting frequency spectrum.
    """
    T_div, T_WGD, TF, nuWGD, nuF, H, gamma = params
    alloaflag = PolyInt.PloidyType.ALLOa
    allobflag = PolyInt.PloidyType.ALLOb
    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx, gamma=gamma)
    phi = PhiManip.phi_1D_to_2D(xx, phi)
    phi = PolyInt.two_pops(phi, xx, T_div, sel_dict1={"gamma": gamma}, sel_dict2={"gamma": gamma})
    # second epoch
    phi = PolyInt.two_pops(phi, xx, T_WGD, nu1=nuWGD, nu2=nuWGD, m12=H, m21=H,
                           sel_dict1={"gamma": gamma}, sel_dict2={"gamma": gamma},
                           ploidyflag1=alloaflag, ploidyflag2=allobflag)
    # third epoch
    phi = PolyInt.two_pops(phi, xx, TF, nu1=nuF, nu2=nuF, m12=H, m21=H,
                           sel_dict1={"gamma": gamma}, sel_dict2={"gamma": gamma},
                           ploidyflag1=alloaflag, ploidyflag2=allobflag)
    fs = Spectrum.from_phi(phi, ns, (xx,xx))
    return fs

Three epoch model of allotetraploid formation where the allotetraploid population splits, maintains a size of nuWGD for T_WGD, and then changes size again to nuF for a period of TF. This is similar to having a bottleneck for some period and then recover after the bottleneck.

Parameters

params (tuple): (T_WGD, TF, nuWGD, nuF, H) - T_div: Divergence period between the two diploid progenitors (in units of 2*Na generations).

- T_WGD: Time length between the WGD event and second size change, creating the  
   allotetraploid population (in units of 2*Na generations).

- TF: Time in the past at which the second epoch begins.

- nuWGD: Ratio of initial allotetraploid population (during first epoch)
     to ancestral diploid population size (ratio of *census* sizes).

- nuF: Ratio of contemporary allotetraploid population (during second epoch)
     to ancestral diploid population size (ratio of *census* sizes).

- H: homoeologous exchange rate (in terms of 2*Na*eta)

- gamma: population-scaled selection coefficient (= 2*Na*s)

ns (tuple): Sample sizes (n1,n2). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting frequency spectrum.

def three_epoch_sel_noHE(params, ns, pts)
Expand source code
def three_epoch_sel_noHE(params, ns, pts):
    """
    Three epoch model of allotetraploid formation where the 
    allotetraploid population splits, maintains a size of nuWGD for T_WGD, 
    and then changes size again to nuF for a period of TF.
    This is similar to having a bottleneck for some period and then recover after the bottleneck.
    
    Parameters:
        params (tuple): (T_div, T_WGD, TF, nuWGD, nuF)
            - T_div: Divergence period between the two diploid progenitors 
               (in units of 2*Na generations).

            - T_WGD: Time length between the WGD event and second size change, creating the  
               allotetraploid population (in units of 2*Na generations).

            - TF: Time in the past at which the second epoch begins.

            - nuWGD: Ratio of initial allotetraploid population (during first epoch)
                 to ancestral diploid population size (ratio of *census* sizes).

            - nuF: Ratio of contemporary allotetraploid population (during second epoch)
                 to ancestral diploid population size (ratio of *census* sizes).

            - gamma: population-scaled selection coefficient (= 2*Na*s)
        ns (tuple): Sample sizes (n1,n2).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting frequency spectrum.
    """
    T_div, T_WGD, TF, nuWGD, nuF, gamma = params
    fs = three_epoch_sel((T_div, T_WGD, TF, nuWGD, nuF, 0, gamma), ns, pts)
    return fs

Three epoch model of allotetraploid formation where the allotetraploid population splits, maintains a size of nuWGD for T_WGD, and then changes size again to nuF for a period of TF. This is similar to having a bottleneck for some period and then recover after the bottleneck.

Parameters

params (tuple): (T_div, T_WGD, TF, nuWGD, nuF) - T_div: Divergence period between the two diploid progenitors (in units of 2*Na generations).

- T_WGD: Time length between the WGD event and second size change, creating the  
   allotetraploid population (in units of 2*Na generations).

- TF: Time in the past at which the second epoch begins.

- nuWGD: Ratio of initial allotetraploid population (during first epoch)
     to ancestral diploid population size (ratio of *census* sizes).

- nuF: Ratio of contemporary allotetraploid population (during second epoch)
     to ancestral diploid population size (ratio of *census* sizes).

- gamma: population-scaled selection coefficient (= 2*Na*s)

ns (tuple): Sample sizes (n1,n2). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting frequency spectrum.

def two_epoch_sel(params, ns, pts)
Expand source code
def two_epoch_sel(params, ns, pts):
    """
    Two epoch model of allotetraploid formation where the 
    diploid progenitors diverge for 1 diffusion unit and then the
    allotetraploid population splits and maintains a size of nu.
    
    Parameters:
        params (tuple): (T_div, T_WGD, nu, H, gamma)
            - T_div: Divergence period between the two diploid progenitors 
               (in units of 2*Na generations).

            - T_WGD: Time in the past at which the WGD occurred, creating the  
               autotetraploid population (in units of 2*Na generations).

            - nu: Ratio of contemporary autotetraploid to ancestral diploid population size 
               (ratio of *census* sizes).

            - H: homoeologous exchange rate (in terms of 2*Na*eta)

            - gamma: population-scaled selection coefficient (= 2*Na*s)
        ns (tuple): Sample sizes (n1,n2).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting (collapsed) frequency spectrum.
    """
    T_div, T_WGD, nu, H, gamma = params
    alloaflag = PolyInt.PloidyType.ALLOa
    allobflag = PolyInt.PloidyType.ALLOb
    xx = Numerics.default_grid(pts)
    phi = PhiManip.phi_1D(xx, gamma=gamma)
    phi = PhiManip.phi_1D_to_2D(xx, phi)
    phi = PolyInt.two_pops(phi, xx, T_div, sel_dict1={"gamma": gamma}, sel_dict2={"gamma": gamma})
    # then, integrate for T_WGD with allotetraploids
    phi = PolyInt.two_pops(phi, xx, T_WGD, nu1=nu, nu2=nu, m12=H, m21=H,
                           sel_dict1={"gamma": gamma}, sel_dict2={"gamma": gamma},
                           ploidyflag1=alloaflag, ploidyflag2=allobflag)
    fs = Spectrum.from_phi(phi, ns, (xx,xx))
    return fs

Two epoch model of allotetraploid formation where the diploid progenitors diverge for 1 diffusion unit and then the allotetraploid population splits and maintains a size of nu.

Parameters

params (tuple): (T_div, T_WGD, nu, H, gamma) - T_div: Divergence period between the two diploid progenitors (in units of 2*Na generations).

- T_WGD: Time in the past at which the WGD occurred, creating the  
   autotetraploid population (in units of 2*Na generations).

- nu: Ratio of contemporary autotetraploid to ancestral diploid population size 
   (ratio of *census* sizes).

- H: homoeologous exchange rate (in terms of 2*Na*eta)

- gamma: population-scaled selection coefficient (= 2*Na*s)

ns (tuple): Sample sizes (n1,n2). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting (collapsed) frequency spectrum.

def two_epoch_sel_noHE(params, ns, pts)
Expand source code
def two_epoch_sel_noHE(params, ns, pts):
    """
    Two epoch model of allotetraploid formation where the 
    diploid progenitors diverge for 1 diffusion unit and then the
    allotetraploid population splits and maintains a size of nu.
    
    Parameters:
        params (tuple): (T_div, T_WGD, nu)
            - T_div: Divergence period between the two diploid progenitors 
               (in units of 2*Na generations).

            - T_WGD: Time in the past at which the WGD occurred, creating the  
               autotetraploid population (in units of 2*Na generations).

            - nu: Ratio of contemporary autotetraploid to ancestral diploid population size 
               (ratio of *census* sizes).

            - gamma: population-scaled selection coefficient (= 2*Na*s)
        ns (tuple): Sample sizes (n1,n2).
        pts (int): Number of grid points to use in integration.

    Returns:
        fs (Spectrum): The resulting (collapsed) frequency spectrum.
    """
    T_div, T_WGD, nu, gamma = params
    fs = two_epoch_sel((T_div, T_WGD, nu, 0, gamma), ns, pts)
    return fs

Two epoch model of allotetraploid formation where the diploid progenitors diverge for 1 diffusion unit and then the allotetraploid population splits and maintains a size of nu.

Parameters

params (tuple): (T_div, T_WGD, nu) - T_div: Divergence period between the two diploid progenitors (in units of 2*Na generations).

- T_WGD: Time in the past at which the WGD occurred, creating the  
   autotetraploid population (in units of 2*Na generations).

- nu: Ratio of contemporary autotetraploid to ancestral diploid population size 
   (ratio of *census* sizes).

- gamma: population-scaled selection coefficient (= 2*Na*s)

ns (tuple): Sample sizes (n1,n2). pts (int): Number of grid points to use in integration.

Returns

fs (Spectrum): The resulting (collapsed) frequency spectrum.