Natural Selection Simulator: Hardy-Weinberg Model with Fitness Selection

simulator intermediate ~10 min
Loading simulation...
p → 0.99 in approximately 72 generations with 20% selection against aa

With an initial allele frequency of 0.1, equal fitness for AA and Aa (w=1.0), and reduced fitness for aa (w=0.8), the A allele rises from 10% to near-fixation in roughly 72 generations, demonstrating how even moderate selection efficiently spreads advantageous alleles.

Formula

p' = (p²·w_AA + p·q·w_Aa) / w̄
w̄ = p²·w_AA + 2pq·w_Aa + q²·w_aa
Heterozygosity H = 2pq

How Natural Selection Shapes Allele Frequencies

Natural selection is the differential survival and reproduction of organisms due to heritable variation in fitness. At the genetic level, this process changes allele frequencies across generations — the fundamental mechanism of adaptive evolution. This simulator implements the classic one-locus, two-allele model with viability selection, building on the Hardy-Weinberg framework first established independently by G.H. Hardy and Wilhelm Weinberg in 1908.

The Hardy-Weinberg Selection Model

In a diploid population with two alleles (A and a) at a single locus, the genotype frequencies after random mating follow Hardy-Weinberg proportions: freq(AA) = p², freq(Aa) = 2pq, freq(aa) = q², where p is the frequency of allele A and q = 1 - p. When genotypes differ in fitness (denoted w_AA, w_Aa, w_aa), the allele frequency in the next generation becomes:

p' = (p²·w_AA + p·q·w_Aa) / w̄

where w̄ = p²·w_AA + 2pq·w_Aa + q²·w_aa is the mean population fitness. This deceptively simple equation captures the essence of Darwinian selection at the molecular level.

Types of Selection

Directional selection occurs when one homozygote has the highest fitness. If w_AA > w_Aa > w_aa, allele A increases to fixation. The rate depends on the magnitude of fitness differences — try setting w_aa = 0.8 to see moderate directional selection in action.

Overdominance (heterozygote advantage) arises when w_Aa > w_AA and w_Aa > w_aa. This maintains a stable polymorphism with both alleles persisting indefinitely. The classic example is sickle-cell anemia: heterozygous carriers (Aa) resist malaria better than either homozygote. Try w_AA = 0.9, w_Aa = 1.0, w_aa = 0.7 to observe this.

Underdominance occurs when the heterozygote has the lowest fitness (w_Aa < w_AA and w_Aa < w_aa), creating an unstable equilibrium. The allele frequency will move toward whichever homozygote it is closer to.

Key Observations

Adjust the fitness values and initial frequency to explore: (1) How the selection coefficient affects the speed of allele frequency change — even small fitness differences compound over many generations. (2) How initial allele frequency matters — rare beneficial alleles take longer to establish. (3) The dramatic difference between additive, dominant, and recessive selection in their dynamics. R.A. Fisher's Fundamental Theorem of Natural Selection (1930) states that the rate of increase in mean fitness equals the additive genetic variance in fitness — a principle directly observable in this simulation.

FAQ

What is the Hardy-Weinberg equilibrium?

The Hardy-Weinberg principle states that allele and genotype frequencies remain constant across generations in an idealized population with no selection, mutation, migration, or genetic drift. Genotype frequencies follow p² + 2pq + q² = 1, where p and q are allele frequencies.

How does natural selection change allele frequencies?

When genotypes differ in fitness (survival and reproduction rates), alleles associated with higher fitness increase in frequency each generation. The rate of change depends on the selection coefficient s, where w_aa = 1 - s. The recurrence relation is p' = (p²·w_AA + p·q·w_Aa) / w̄.

What is heterozygote advantage?

Heterozygote advantage (overdominance) occurs when the heterozygous genotype Aa has higher fitness than both homozygotes. This maintains both alleles in the population at a stable equilibrium, as seen in sickle-cell trait conferring malaria resistance.

What is the formula for allele frequency change under selection?

The next-generation allele frequency is p' = (p²·w_AA + p·q·w_Aa) / w̄, where w̄ = p²·w_AA + 2pq·w_Aa + q²·w_aa is the mean fitness of the population, and q = 1 - p.

Sources

Embed

<iframe src="https://homo-deus.com/lab/evolution/natural-selection/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub