Genetic drift and selection (2D)

Allele-frequency trajectories of many populations, with theory for drift, fixation and heterozygosity.

Switch to 3D

Presets

Playback

Population

Run

Layers

Model check

The science

What is modelled

One gene with two alleles, A (red marbles) and a (blue marbles), in a population of N diploid individuals, so 2N gene copies. Each jar is a gene pool. In every generation the next pool is drawn at random, with replacement, from the parents, after any selection, mutation or migration. That random draw is genetic drift: allele frequencies wander and eventually one allele is lost and the other fixed, even with no selection at all. The jars are 12 independent runs from the same start; the graphs use 200 runs.

Equations

  • Fitness AA : Aa : aa = 1 + s : 1 + hs : 1 gives the mean fitness w̄ = p²(1+s) + 2pq(1+hs) + q² and the post-selection frequency p' = [p²(1+s) + pq(1+hs)] / w̄.
  • Mutation u = v each way and migration at rate m from a source with frequency pm: p'' = (1 − m)[p'(1 − u) + (1 − p')u] + m pm.
  • Sampling: the next count of A copies is Binomial(2N, p''), variance p(1 − p)/2N per generation.
  • Neutral heterozygosity decays as Ht = H0 (1 − 1/2N)t; the chance that a neutral allele eventually fixes equals its starting frequency; the mean time to fixation (given that it fixes) is T = −4N p ln p / (1 − p) generations.
  • Additive selection (h = 1/2): Kimura's fixation probability u(p) = (1 − e−2Nsp)/(1 − e−2Ns) (a diffusion approximation; with these fitnesses each copy of A has advantage s/2). Selection beats drift when 2N|s| is well above 1.
  • Heterozygote advantage (h > 1, s > 0) keeps both alleles at p* = h/(2h − 1) in a large population.

Checks run in the page (seeded Monte Carlo, error bars shown)

  • Neutral heterozygosity after 30 generations against H0(1 − 1/2N)t.
  • Neutral fixation probability against the starting frequency.
  • Fixation probability with selection against Kimura's formula.
  • Iterating the deterministic map for heterozygote advantage against h/(2h − 1).

Honest simplifications

  • Constant population size, random mating, discrete non-overlapping generations, one locus, no linkage. The effective size is taken equal to N.
  • Kimura's formula is an approximation for large N and small s; the check allows a 0.02 tolerance for that.
  • The marbles are a picture of the 2N gene copies; their positions are only a pile, not part of the model.

What to try

  • "Neutral drift, small population" loses variation within about 40 generations; "large population" takes hundreds. Watch H fall along the dashed line.
  • "Rare beneficial mutant": most runs lose the allele while the lucky ones sweep to fixation. About 2s of them win.
  • "Heterozygote advantage" keeps both colours in every jar.
Frequency across runs
Heterozygosity (drift removes variation)
Variance of p across runs
Fixation and loss over time