示例#1
0
class HuberTwoEpoch(models.DemographicModel):
    populations = [
        models.Population(id="ATL", description="A. thalina"),
    ]

    def __init__(self):

        # Time of second epoch
        T_2 = 568344
        # population sizes
        N_ANC = 746148
        N_2 = 100218

        self.population_configurations = [
            msprime.PopulationConfiguration(
                initial_size=N_2, metadata=self.populations[0].asdict()),
        ]

        self.migration_matrix = [[0]]

        self.demographic_events = [
            msprime.PopulationParametersChange(time=T_2,
                                               initial_size=N_ANC,
                                               population_id=0),
        ]
示例#2
0
class HuberThreeEpoch(models.DemographicModel):
    populations = [
        models.Population(id="ATL", description="A. thalina"),
    ]

    def __init__(self):

        # Time of second epoch
        T_2 = 7420
        T_3 = 14534
        # population sizes
        N_ANC = 161744
        N_2 = 24076
        N_3 = 203077

        self.population_configurations = [
            msprime.PopulationConfiguration(
                initial_size=N_3, metadata=self.populations[0].asdict()),
        ]

        self.migration_matrix = [[0]]

        self.demographic_events = [
            msprime.PopulationParametersChange(time=T_3,
                                               initial_size=N_2,
                                               population_id=0),
            msprime.PopulationParametersChange(time=T_2 + T_3,
                                               initial_size=N_ANC,
                                               population_id=0),
        ]
示例#3
0
# This script is a QC implementation of the Pongo model
import msprime
import numpy as np

import stdpopsim
import stdpopsim.models as models


_species = stdpopsim.get_species("PonAbe")

# Some generic populations to use for qc
population_sample_0 = models.Population("sampling_0",
                                        "Population that samples at time 0",
                                        0)


class LockePongo(models.DemographicModel):
    populations = [population_sample_0] * 2

    def __init__(self):
        # This is a split-migration style model, with exponential growth or
        # decay allowed in each population after the split. They assumed a
        # generation time of 20 years and a mutation rate of 2e-8 per bp per gen
        generation_time = 20

        # Parameters given in Table S21-2
        Ne = 17934
        s = 0.592
        NB0 = s*Ne
        NS0 = (1-s)*Ne
        NBF = 8805
示例#4
0
class DenisovanAncestryInPapuans(models.DemographicModel):
    """
    Demographic model from Jacobs et al (2019). The model is
    illustrated on Figure S5, parameters are in Table S5
    """

    populations = [population_sample_0] * 4 + [
        models.Population("", "", 2058),
        models.Population("", "", 2612),
    ] + [population_sample_none] * 4

    def __init__(self):
        self.generation_time = 29  # Just information

        # sizes of populations
        N_YRI = 48433
        N_CEU = 6962
        N_CHB = 9025
        N_Papuan = 8834
        N_DenA = 5083
        t_DenA = 2058  # generations
        N_NeanA = 826
        t_NeanA = 2612  # generations
        N_Nean1 = 13249
        N_Den1 = N_Nean1
        N_Den2 = N_Nean1
        N_Ghost = 8516
        # after coalescences
        N_CEU_CHB = 12971
        N_Human = 41563
        N_DenAnc = 100
        N_A = 32671

        # bottlenecks
        N_CEU_CHB_bot = 2231
        N_GhostA_bot = 1394
        N_Papuan_bot = 243

        # times of coalesces
        t_CEU_CHB = 1293
        t_CEU_Ghost = 1758
        t_Papuan_Ghost = 1784
        t_YRI_GhostA = 2218
        t_Nean1_NeanA = 3375
        t_Den1_DenA = 9750
        t_Den1_Den2 = 12500
        t_Den_Nean = 15090
        t_Human_Den_Nean = 20225

        # times of bottlenecks
        t_CEU_CHB_bot = 1659
        t_Papuan_bot = 1685
        t_GhostA_bot = 2119

        # migrations
        m_YRI_Ghost = 0.000179
        m_Ghost_CEU = 0.000442
        m_CEU_CHB = 3.14e-5
        m_CHB_Papuan = 5.72e-5
        m_CEUCHB_Papua = 0.000572
        m_Ghost_CEUCHB = 0.000442

        # times and proportions of admixtures
        p1 = 0.55
        t_Nean1_to_CHB = 883
        p_Nean1_to_CHB = 0.002
        t_Den2_to_Papuan = 45.7e3 / self.generation_time
        p_Den2_to_Papuan = (1 - p1) * 0.04
        t_Den1_to_Papuan = 29.8e3 / self.generation_time
        p_Den1_to_Papuan = p1 * 0.04
        t_Nean1_to_Papuan = 1412
        p_Nean1_to_Papuan = 0.002
        t_Nean1_to_CEU_CHB = 1566
        p_Nean1_to_CEU_CHB = 0.011
        t_Nean1_to_GhostA = 1853
        p_Nean1_to_GhostA = 0.024

        # set up populations
        self.population_configurations = [
            msprime.PopulationConfiguration(  # 0 YRI
                initial_size=N_YRI, growth_rate=0,
                metadata={"name": "YRI", "sampling_time": 0}),
            msprime.PopulationConfiguration(  # 1 CEU
                initial_size=N_CEU, growth_rate=0,
                metadata={"name": "CEU", "sampling_time": 0}),
            msprime.PopulationConfiguration(  # 2 CHB
                initial_size=N_CHB, growth_rate=0,
                metadata={"name": "CHB", "sampling_time": 0}),
            msprime.PopulationConfiguration(  # 3 Papuan
                initial_size=N_Papuan, growth_rate=0,
                metadata={"name": "Papuan", "sampling_time": 0}),
            msprime.PopulationConfiguration(  # 4 DenA
                initial_size=N_DenA, growth_rate=0,
                metadata={"name": "DenA", "sampling_time": t_DenA}),
            msprime.PopulationConfiguration(  # 5 NeanA
                initial_size=N_NeanA, growth_rate=0,
                metadata={"name": "NeanA", "sampling_time": t_NeanA}),
            msprime.PopulationConfiguration(  # 6 Den1
                initial_size=N_Den1, growth_rate=0,
                metadata={"name": "Den1", "sampling_time": None}),
            msprime.PopulationConfiguration(  # 7 Den2
                initial_size=N_Den2, growth_rate=0,
                metadata={"name": "Den2", "sampling_time": None}),
            msprime.PopulationConfiguration(  # 8 Nean1
                initial_size=N_Nean1, growth_rate=0,
                metadata={"name": "Nean1", "sampling_time": None}),
            msprime.PopulationConfiguration(  # 9 Ghost
                initial_size=N_Ghost, growth_rate=0,
                metadata={"name": "Ghost", "sampling_time": None})
        ]

        self.migration_matrix = [[0]*10 for _ in range(10)]
        self.migration_matrix[0][9] = m_YRI_Ghost
        self.migration_matrix[9][0] = m_YRI_Ghost
        self.migration_matrix[1][9] = m_Ghost_CEU
        self.migration_matrix[9][1] = m_Ghost_CEU
        self.migration_matrix[1][2] = m_CEU_CHB
        self.migration_matrix[2][1] = m_CEU_CHB
        self.migration_matrix[2][3] = m_CHB_Papuan
        self.migration_matrix[3][2] = m_CHB_Papuan

        self.demographic_events = [
            # Coalescence of CEU and CHB into CHB
            msprime.MassMigration(
                time=t_CEU_CHB, source=1,
                destination=2, proportion=1.),
            # Set size of CEU+CHB population
            msprime.PopulationParametersChange(
                time=t_CEU_CHB, initial_size=N_CEU_CHB,
                population_id=2),
            # Change migration matrix
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=0, matrix_index=(2, 1)),
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=0, matrix_index=(1, 2)),
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=0, matrix_index=(3, 2)),
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=0, matrix_index=(2, 3)),
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=0, matrix_index=(9, 1)),
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=0, matrix_index=(1, 9)),
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=m_CEUCHB_Papua, matrix_index=(2, 3)),
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=m_CEUCHB_Papua, matrix_index=(3, 2)),
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=m_Ghost_CEUCHB, matrix_index=(2, 9)),
            msprime.MigrationRateChange(
                time=t_CEU_CHB, rate=m_Ghost_CEUCHB, matrix_index=(9, 2)),
            # Set bottleneck size of CEU+CHB population
            msprime.PopulationParametersChange(
                time=t_CEU_CHB_bot, initial_size=N_CEU_CHB_bot,
                population_id=2),
            # Change migration matrix
            msprime.MigrationRateChange(time=t_CEU_CHB_bot, rate=0),
            # Set bottleneck size of Papuan population
            msprime.PopulationParametersChange(
                time=t_Papuan_bot, initial_size=N_Papuan_bot,
                population_id=3),
            # Coalescence of CEU+CHB and Ghost to Ghost
            msprime.MassMigration(
                time=t_CEU_Ghost, source=2,
                destination=9, proportion=1.),
            # Coalescence of Papuan and Ghost to GhostA
            msprime.MassMigration(
                time=t_Papuan_Ghost, source=3,
                destination=9, proportion=1.),
            # Set bottleneck size of GhostA population
            msprime.PopulationParametersChange(
                time=t_GhostA_bot, initial_size=N_GhostA_bot,
                population_id=9),
            # Coalescence of Ghost and YRI into Human (YRI)
            msprime.MassMigration(
                time=t_YRI_GhostA, source=9,
                destination=0, proportion=1.),
            # Set size of Human population
            msprime.PopulationParametersChange(
                time=t_YRI_GhostA, initial_size=N_Human,
                population_id=0),
            # Coalescence of NeanA and Nean1 into NeanAnc
            msprime.MassMigration(
                time=t_Nean1_NeanA, source=8,
                destination=5, proportion=1.),
            # Set size of NeanAnc population
            msprime.PopulationParametersChange(
                time=t_Nean1_NeanA, initial_size=N_Nean1,
                population_id=5),
            # Coalescence of Den1 and DenA into DenAnc (DenA)
            msprime.MassMigration(
                time=t_Den1_DenA, source=6,
                destination=4, proportion=1.),
            # Set size of DenA population
            msprime.PopulationParametersChange(
                time=t_Den1_DenA, initial_size=N_DenAnc,
                population_id=4),
            # Coalescence of DenAnc and Den2 into DenAnc
            msprime.MassMigration(
                time=t_Den1_Den2, source=7,
                destination=4, proportion=1.),
            # Set size of DenA population
            msprime.PopulationParametersChange(
                time=t_Den1_Den2, initial_size=N_DenAnc,
                population_id=4),
            # Coalescence of DenAnc and NeanAnc into Den_Nean (Nean1)
            msprime.MassMigration(
                time=t_Den_Nean, source=5,
                destination=4, proportion=1.),
            # Set size of Den_Nean population
            msprime.PopulationParametersChange(
                time=t_Den_Nean, initial_size=N_Nean1,
                population_id=4),
            # Coalescence of Den_Nean and Human into Anc (YRI)
            msprime.MassMigration(
                time=t_Human_Den_Nean, source=4,
                destination=0, proportion=1.),
            # Set ancestral size of population
            msprime.PopulationParametersChange(
                time=t_Human_Den_Nean, initial_size=N_A,
                population_id=0),

            # Admixture events
            # Admixture from Den1 to Papuans
            msprime.MassMigration(
                time=t_Den1_to_Papuan, source=3,
                destination=6, proportion=p_Den1_to_Papuan),
            # Admixture from Den2 to Papuans
            msprime.MassMigration(
                time=t_Den2_to_Papuan, source=3,
                destination=7, proportion=p_Den2_to_Papuan),
            # Admixture from Nean1 to GhostA
            msprime.MassMigration(
                time=t_Nean1_to_GhostA, source=9,
                destination=8, proportion=p_Nean1_to_GhostA),
            # Admixture from Nean1 to CEU+CHB
            msprime.MassMigration(
                time=t_Nean1_to_CEU_CHB, source=2,
                destination=8, proportion=p_Nean1_to_CEU_CHB),
            # Admixture from Nean1 to Papuans
            msprime.MassMigration(
                time=t_Nean1_to_Papuan, source=3,
                destination=8, proportion=p_Nean1_to_Papuan),
            # Admixture from Neandertal to East Asia population
            msprime.MassMigration(
                time=t_Nean1_to_CHB, proportion=p_Nean1_to_CHB, source=2,
                destination=8),
        ]
        self.demographic_events.sort(key=lambda x: x.time)
示例#5
0
class KammAncientSamples(models.DemographicModel):
    """
    Demographic inferred by momi described in Kamm et al. (2019). The model is
    illustrated in Figure 3, with parameters given in Table 2.
    """
    populations = [
        population_sample_0,
        models.Population("", "", 8e3 / 25),
        population_sample_0,
        models.Population("", "", 7.5e3 / 25),
        models.Population("", "", 24e3 / 25),
        population_sample_0,
        models.Population("", "", 45e3 / 25),
        models.Population("", "", 50e3 / 25),
        population_sample_none
    ]

    def __init__(self):

        generation_time = 25

        # population sizes
        N_Losch = 1.92e3
        N_Mbu = 1.73e4
        N_Mbu_Losch = 2.91e4
        N_Han = 6.3e3
        N_Han_Losch = 2.34e3
        N_Nean_Losch = 1.82e4
        N_Nean = 86.9
        N_LBK = 75.7
        N_Sard = 1.5e4
        N_Sard_LBK = 1.2e4

        # unknown population sizes
        # these should be set to ancestral Eurasian population size,
        # but at the moment it's unclear to me if that is N_Han_Losch? N_Losch?
        N_Basal = N_Losch
        N_Ust = N_Basal
        N_MA1 = N_Basal

        # population merge times in years, divided by generation time
        t_Mbu_Losch = 9.58e4 / generation_time
        t_Han_Losch = 5.04e4 / generation_time
        t_Ust_Losch = 5.15e4 / generation_time
        t_Nean_Losch = 6.96e5 / generation_time
        t_MA1_Losch = 4.49e4 / generation_time
        t_LBK_Losch = 3.77e4 / generation_time
        t_Basal_Losch = 7.98e4 / generation_time
        t_Sard_LBK = 7.69e3 / generation_time
        # t_GhostWHG_Losch = 1.56e3 / generation_time

        # pulse admixture times and fractions
        p_Nean_to_Eur = 0.0296
        t_Nean_to_Eur = 5.68e4 / generation_time
        p_Basal_to_EEF = 0.0936
        t_Basal_to_EEF = 3.37e4 / generation_time
        p_GhostWHG_to_Sard = 0.0317
        t_GhostWHG_to_Sard = 1.23e3 / generation_time

        # sample_times (in years), divided by estimated generation time
        t_Mbuti = 0
        t_Han = 0
        t_Sardinian = 0
        t_Loschbour = 7.5e3 / generation_time
        t_LBK = 8e3 / generation_time
        t_MA1 = 24e3 / generation_time
        t_UstIshim = 45e3 / generation_time
        t_Altai = 50e3 / generation_time

        # set up populations
        self.population_configurations = [
            msprime.PopulationConfiguration(  # Mbuti
                initial_size=N_Mbu, growth_rate=0,
                metadata={"name": "Mbuti", "sampling_time": t_Mbuti}),
            msprime.PopulationConfiguration(  # LBK
                initial_size=N_LBK, growth_rate=0,
                metadata={"name": "LBK", "sampling_time": t_LBK}),
            msprime.PopulationConfiguration(  # Sardinian
                initial_size=N_Sard, growth_rate=0,
                metadata={"name": "Sardinian", "sampling_time": t_Sardinian}),
            msprime.PopulationConfiguration(  # Loschbour
                initial_size=N_Losch, growth_rate=0,
                metadata={"name": "Loschbour", "sampling_time": t_Loschbour}),
            msprime.PopulationConfiguration(  # MA1
                initial_size=N_MA1, growth_rate=0,
                metadata={"name": "MA1", "sampling_time": t_MA1}),
            msprime.PopulationConfiguration(  # Han
                initial_size=N_Han, growth_rate=0,
                metadata={"name": "Han", "sampling_time": t_Han}),
            msprime.PopulationConfiguration(  # UstIshim
                initial_size=N_Ust, growth_rate=0,
                metadata={"name": "UstIshim", "sampling_time": t_UstIshim}),
            msprime.PopulationConfiguration(  # Neanderthal
                initial_size=N_Nean, growth_rate=0,
                metadata={"name": "Altai", "sampling_time": t_Altai}),
            msprime.PopulationConfiguration(  # Basal Eurasian
                initial_size=N_Basal, growth_rate=0,
                metadata={"name": "Basal", "sampling_time": None})
        ]

        # no migration rates, only pulse events, so set mig mat to zeros
        num_pops = len(self.population_configurations)
        self.migration_matrix = [[0] * num_pops] * num_pops

        # Compute Neanderthal pop size decline rate
        # I'm assuming that the N_Nean is the size of Neanderthal population
        # at the time of sampling the Altai individual
        r_Nean = -math.log(N_Nean_Losch/N_Nean) / (t_Mbu_Losch-t_Altai)

        # Using columns in figure in Kamm paper as proxies for pop number
        self.demographic_events = [
            msprime.MassMigration(
                time=t_GhostWHG_to_Sard, source=2,
                destination=3, proportion=p_GhostWHG_to_Sard),
            msprime.MassMigration(
                time=t_Sard_LBK, source=2, destination=1,
                proportion=1.),
            msprime.PopulationParametersChange(
                time=t_Sard_LBK, initial_size=N_Sard_LBK,
                population_id=1),
            msprime.MassMigration(
                time=t_Basal_to_EEF, source=1, destination=8,
                proportion=p_Basal_to_EEF),
            msprime.MassMigration(
                time=t_LBK_Losch, source=1, destination=3,
                proportion=1.),
            msprime.MassMigration(
                time=t_MA1_Losch, source=4, destination=3,
                proportion=1.),
            msprime.PopulationParametersChange(
                time=t_Altai, initial_size=N_Nean,
                growth_rate=r_Nean, population_id=7),
            msprime.MassMigration(
                time=t_Han_Losch, source=5, destination=3,
                proportion=1.),
            msprime.PopulationParametersChange(
                time=t_Han_Losch, initial_size=N_Han_Losch,
                population_id=3),
            msprime.MassMigration(
                time=t_Ust_Losch, source=6, destination=3,
                proportion=1.),
            msprime.MassMigration(
                time=t_Nean_to_Eur, source=3, destination=7,
                proportion=p_Nean_to_Eur),
            msprime.MassMigration(
                time=t_Basal_Losch, source=8, destination=3,
                proportion=1.),
            msprime.MassMigration(
                time=t_Mbu_Losch, source=0, destination=3,
                proportion=1.),
            msprime.PopulationParametersChange(
                time=t_Mbu_Losch, initial_size=N_Mbu_Losch,
                population_id=3),
            msprime.PopulationParametersChange(
                time=t_Mbu_Losch, initial_size=N_Nean_Losch,
                growth_rate=0, population_id=7),
            msprime.MassMigration(
                time=t_Nean_Losch, source=7, destination=3,
                proportion=1.),
            msprime.PopulationParametersChange(
                time=t_Nean_Losch, initial_size=N_Nean_Losch,
                population_id=3)
        ]
示例#6
0
import math

import msprime

import stdpopsim
import stdpopsim.models as models


_species = stdpopsim.get_species("HomSap")

# Some generic populations to use for qc
population_sample_0 = models.Population("sampling_0",
                                        "Population that samples at time 0",
                                        0)
population_sample_none = models.Population("sampling_none",
                                           "Population that does not sample",
                                           None)


class TennessenOnePopAfrica(models.DemographicModel):
    populations = [population_sample_0]

    def __init__(self):
        # This model is the same as the Tennessen two population model except
        # the European population has been removed.

        # Since the Tennessen one population model largely uses parameters from
        # the Gravel et al 2001, we begin by taking the maximum likelihood value
        # from the table 2 of Gravel et al. 2011 using the Low-coverage + exons
        # data. Initially we copy over the pre- exponential growth population
        # size estimates, migration rates, and epoch times: