def vic_two_epoch_admix(params, ns, pts): """ Split with no gene flow, followed by no migration but a discrete admixture event from pop 1 into pop 2 occurs. Populations are fractions of ancient population, where population 2 is represented by nuA*(s), and population 1 is represented by nuA*(1-s). nuA: Ancient population size s: Fraction of nuA that goes to pop2. (Pop 1 has size nuA*(1-s).) nu1: Size of population 1 after split. nu2: Size of population 2 after split. T1: The scaled time between the split and admixture event (in units of 2*Na generations). T2: The scaled time between the admixture event and present. f: Fraction of updated population 2 to be derived from population 1. """ nuA, nu1, nu2, T1, T2, s, f = params xx = Numerics.default_grid(pts) phi = PhiManip.phi_1D(xx) phi = PhiManip.phi_1D_to_2D(xx, phi) nu1 = nuA * (1 - s) nu2 = nuA * s phi = Integration.two_pops(phi, xx, T1, nu1, nu2, m12=0, m21=0) phi = PhiManip.phi_2D_admix_1_into_2(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
def founder_nomig_admix_two_epoch(params, ns, pts): """ Split into two populations, with no migration. Populations are fractions of ancient population, where population 2 is represented by nuA*(s), and population 1 is represented by nuA*(1-s). Population two undergoes an exponential growth event, while population one is constant. nuA: Ancient population size s: Fraction of nuA that goes to pop2. (Pop 1 has size nuA*(1-s).) nu1: Final size of pop 1. nu2: Final size of pop 2. T1: Time in the past of split (in units of 2*Na generations) T2: The scaled time between the admixture event and present. f: Fraction of updated population 2 to be derived from population 1. """ nuA, nu1, nu2, T1, T2, s, f = params xx = Numerics.default_grid(pts) phi = PhiManip.phi_1D(xx, nu=nuA) phi = PhiManip.phi_1D_to_2D(xx, phi) nu1 = nuA * (1 - s) nu2_0 = nuA * s nu2_func = lambda t: nu2_0 * (nu2 / nu2_0)**(t / T1) #note, the nu2_0 can be eliminated and the function can appear as: #nu2_func = lambda t: (nuA*(1-s)) * (nu2/(nuA*(1-s)))**(t/T) phi = Integration.two_pops(phi, xx, T1, nu1, nu2_func, m12=0, m21=0) phi = PhiManip.phi_2D_admix_1_into_2(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
def vic_no_mig_admix_late(params, ns, pts): """ Split into two populations, no migration but a discrete admixture event from pop 1 into pop 2 occurs. Populations are fractions of ancient population, where population 2 is represented by nuA*(s), and population 1 is represented by nuA*(1-s). nuA: Ancient population size s: Fraction of nuA that goes to pop2. (Pop 1 has size nuA*(1-s).) 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) f: Fraction of updated population 2 to be derived from population 1. """ nuA, nu1, nu2, T, s, f = params xx = Numerics.default_grid(pts) phi = PhiManip.phi_1D(xx) phi = PhiManip.phi_1D_to_2D(xx, phi) nu1 = nuA * (1 - s) nu2 = nuA * s phi = Integration.two_pops(phi, xx, T, nu1, nu2, m12=0, m21=0) phi = PhiManip.phi_2D_admix_1_into_2(phi, f, xx, xx) fs = Spectrum.from_phi(phi, ns, (xx, xx)) return fs
def vic_two_epoch_admix(params, ns, pts): """ Split into two populations, no migration but a discrete admixture event from pop 1 into pop 2 occurs (between two drift events). Populations are fractions of the reference population, where population 2 is represented by Nref*(s), and population 1 is represented by Nref*(1-s). Nref implicitly has size = 1. params = 4 s: Fraction of Nref that goes to pop2. Pop2 size = s. Pop 1 size = 1-s. T1: The scaled time between the split and admixture event (in units of 2*Na generations). T2: The scaled time between the admixture event and present. f: Fraction of updated population 2 to be derived from population 1. """ T1, T2, s, f = params xx = Numerics.default_grid(pts) phi = PhiManip.phi_1D(xx) phi = PhiManip.phi_1D_to_2D(xx, phi) phi = Integration.two_pops(phi, xx, T1, nu1=1 - s, nu2=s, m12=0, m21=0) phi = PhiManip.phi_2D_admix_1_into_2(phi, f, xx, xx) phi = Integration.two_pops(phi, xx, T2, nu1=1 - s, nu2=s, m12=0, m21=0) fs = Spectrum.from_phi(phi, ns, (xx, xx)) return fs
def vic_no_mig_admix_late(params, ns, pts): """ Split into two populations, no migration but a discrete admixture event from pop 1 into pop 2 occurs (after drift). Populations are fractions of the reference population, where population 2 is represented by Nref*(s), and population 1 is represented by Nref*(1-s). Nref implicitly has size = 1. params = 3 s: Fraction of Nref that goes to pop2. Pop2 size = s. Pop 1 size = 1-s. T: Time in the past of split (in units of 2*Na generations) f: Fraction of updated population 2 to be derived from population 1. """ T, s, f = params xx = Numerics.default_grid(pts) phi = PhiManip.phi_1D(xx) phi = PhiManip.phi_1D_to_2D(xx, phi) phi = Integration.two_pops(phi, xx, T, nu1=1 - s, nu2=s, m12=0, m21=0) phi = PhiManip.phi_2D_admix_1_into_2(phi, f, xx, xx) fs = Spectrum.from_phi(phi, ns, (xx, xx)) return fs
def custom_model(params, ns, pts): nuPre, TPre, nu1, nu2, T1, T2, m12, m21, 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=m12, m21=m21) phi = PhiManip.phi_2D_admix_1_into_2(phi, f, xx, xx) phi = Integration.two_pops(phi, xx, T2, nu1, nu2, m12=m12, m21=m21) fs = Spectrum.from_phi(phi, ns, (xx, xx)) return fs
def founder_nomig_admix_two_epoch(params, ns, pts): """ Split into two populations, no migration but a discrete admixture event from pop 1 into pop 2 occurs (between two drift events). Populations are fractions of the reference population, where population 2 is represented by Nref*(s), and population 1 is represented by Nref*(1-s). Population two undergoes an exponential growth event to obtain size nu2, while population one is constant. Admixture occurs after size nu2 is achieved. Nref implicitly has size = 1. params = 5 s: Fraction of Nref that goes to pop2. Pop2 size = s. Pop 1 size = 1-s. nu2: Final size of pop 2, after exponential growth. T1: Time in the past of split (in units of 2*Na generations) T2: The scaled time between the admixture event and present. f: Fraction of updated population 2 to be derived from population 1. """ nu2, T1, T2, s, f = params xx = Numerics.default_grid(pts) phi = PhiManip.phi_1D(xx) phi = PhiManip.phi_1D_to_2D(xx, phi) nu2_func = lambda t: s * (nu2 / s)**(t / T1) phi = Integration.two_pops(phi, xx, T1, nu1=1 - s, nu2=nu2_func, m12=0, m21=0) phi = PhiManip.phi_2D_admix_1_into_2(phi, f, xx, xx) phi = Integration.two_pops(phi, xx, T2, nu1=1 - s, nu2=nu2, m12=0, m21=0) fs = Spectrum.from_phi(phi, ns, (xx, xx)) return fs