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.
- Drift only: 40 populations of 20, no selection. Every line wanders; the mean stays put while heterozygosity falls (Chapter 3).
- Nothing acts, large N: 1,000 individuals, no selection. p barely moves, which is the Hardy–Weinberg null model (Chapter 1).
- Selection, large N and selection against A: the runs follow the dashed curve up, or down (Chapter 2).
- A recessive advantage with drift: a rare recessive allele is invisible to selection, so drift loses it more often than an additive or dominant one. Switch h and compare.
- Bottleneck: 200 individuals crash to 4 for three generations (Chapter 4).
- Gene flow: islands of 30 receive 5 % of their genes each generation from a source at 0.7 (Chapter 5).
- Selection against drift and one new mutant: whether advantage or luck wins depends on Ns (Chapter 6).
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.
- 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̄.
- 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.
- 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
- (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).
- (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