Natural selection and genetic drift simulator

One population model with every force on this site. Pick a preset or set N, s, h and migration yourself.

Start from a chapter

Each preset reproduces the set-up of one part of the site. Open it, then change one thing at a time.

What the simulator does each generation

The model is the Wright–Fisher population used on every page of this site[1]: N diploid individuals, so 2N gene copies of two alleles, A (vermilion) with frequency p and a (blue). Each generation happens in a fixed order.

  1. Selection. Genotypes survive in proportion to their fitness, wAA = 1 + s, wAa = 1 + hs and waa = 1, which moves p to p′ = [p²(1 + s) + pq(1 + hs)] / w̄.
  2. Migration. A share m of the gene pool is replaced by copies from a source population at frequency pm: p″ = (1 − m)p′ + m pm.
  3. Drift. The next generation’s 2N copies are drawn at random from that pool: the count of A is an exact Binomial(2N, p″) draw. During a bottleneck the draw is of 2Nb copies instead, and the generation after it regrows to N from the survivors’ gene pool.

The dashed line repeats steps 1 and 2 without step 3: it is what an infinitely large population would do, the expectation the runs scatter around. The sentence under the figure compares the runs with theory: with no selection, a fraction p₀ of runs eventually fix A; with selection, Kimura’s 1962 diffusion formula, computed with the dominance h you chose[2]. With migration nothing is ever permanently fixed or lost, and with a bottleneck the constant-N formula does not apply, so the sentence says so instead.

One meaning of s, and Ns

On this site s always means the fitness difference between the two homozygotes: AA has fitness 1 + s and aa has 1. The heterozygote sits a fraction h of the way between them, at 1 + hs. So s = 0.1 with h = ½ means AA leaves 10 % more offspring than aa and Aa leaves 5 % more. A negative s means A is selected against.

Textbooks differ here. Kimura’s papers and some texts give each copy of A an advantage s, so AA has 1 + 2s; an additive allele with s = 0.1 on this site is s = 0.05 in that notation, and formulas written with 4Ns there are written with 2Ns here. Neither is wrong; the numbers only make sense once the convention is stated.

The readout gives Ns, the population size times s. When |Ns| is well below 1, the runs behave almost as if the allele were neutral; well above 1, selection decides. Try the tug-of-war preset: with N = 10 and s = 0.04, Ns = 0.4 and Kimura’s formula gives a 14 % chance of fixation from 10 %, barely above the neutral 10 %. Raise N to 500 (Ns = 20) and nearly every run fixes. established

What the simulator leaves out

Runs are reproducible: the same seed and settings give the same runs, and Share puts the exact settings and the generation on screen into a link that opens paused at that frame. At most 200 runs and 2,000 generations are drawn at once.

Sources

  1. Coop, Graham (2020). Population and Quantitative Genetics (open textbook, version of October 2021). University of California, Davis (CC BY 3.0). textbook Ch. 2 (Hardy–Weinberg, F), ch. 4 (drift, heterozygosity, fixation), ch. 5 (population structure, island model), ch. 10–12 (selection, selection and drift).
  2. Kimura, Motoo (1962). On the probability of fixation of mutant genes in a population. Genetics 47(6): 713–719. doi:10.1093/genetics/47.6.713. primary