# Population Genetics: Hardy-Weinberg and Evolutionary Forces

> Mating reshuffles alleles; dominance alone does not change their frequency. For a two-allele autosomal locus, this lesson derives the Hardy-Weinberg proportions, tests a sample against them with a chi-square, and then asks how selection, drift, migration, mutation and non-random mating differ from that null model. Afterwards you can turn genotype counts into allele frequencies, estimate carrier frequency from the incidence of a recessive condition, and explain how heterozygote advantage keeps the sickle allele in malaria-exposed populations.

Course: Genetics and Molecular Biology (Populations and complex traits). Level: core university (third year). About 22 minutes.
Lesson page (link this one when citing): https://stemhop.com/lessons/population-genetics/

Builds on: Probability, Crosses and the Chi-Square Test · Mendel's Peas: Segregation and Independent Assortment · Mutation: Where Variation Comes From

## What you'll learn

- Calculate allele and genotype frequencies from counts, derive the Hardy-Weinberg proportions p^2, 2pq and q^2, state their assumptions, and test a sample with a chi-square on one degree of freedom.
- Explain how drift, selection, migration, mutation and non-random mating each change frequencies, and say which change allele frequencies and which change only genotype frequencies.
- Estimate carrier frequency from the incidence of a recessive condition, and explain why selection against a rare recessive allele is slow.
- Explain heterozygote advantage for the sickle allele and malaria, and how founder effects raise particular variants in particular populations.

Here you calculate the first film’s answer and test it against real counts.

## The idea: with nothing acting, frequencies stay put

A **population**, here, is a group of individuals that mate with one another. At a **locus** (a place on a chromosome) with two **alleles** (versions), A and a, the fraction of all allele copies that are A is **p** and the fraction that are a is **q**: the **allele frequencies**. A **genotype frequency** is the fraction of individuals who are AA, Aa or aa. With two alleles, p + q = 1. (In this lesson p and q are always allele frequencies. The capital P in “P = 0.05” further down is a probability from the [chi-square](https://stemhop.com/methods/chi-square-test/) test.)

> **The one idea.** Mating reshuffles alleles; dominance alone does not change their frequency.
>
> *Scope:* one two-allele autosomal locus in a large population, with the same allele frequencies in eggs and sperm. (In a small population, chance sampling of gametes moves frequencies: that is drift.) The [Hardy-Weinberg](https://stemhop.com/methods/population-genetic-models/) baseline below adds random mating at this locus and no selection, mutation or migration.

Written as algebra, the first film’s square gives the **Hardy-Weinberg proportions**:

> **Equation card: Given how common each allele is, how common each genotype should be when nothing is acting on the population.**
>
>     p^2 + 2pq + q^2 = 1, with p + q = 1
>
> In words: The AA share is p squared, the Aa share is two times p times q, the aa share is q squared, and the three shares add up to everyone.
>
> - p^2: the expected frequency of AA: draw A from the egg and A from the sperm, p × p
> - 2pq: the expected frequency of Aa: A from the egg and a from the sperm (pq), or the reverse (qp)
> - q^2: the expected frequency of aa, q × q
> - p: the frequency of allele A: the fraction of all allele copies in the population that are A
> - q: the frequency of allele a. With two alleles, q = 1 − p.
>
> Sanity check: If q = 0 there are no a copies, and the equation says everyone is AA (p^2 = 1). If p = q = 0.5, heterozygotes make up half the population (2 × 0.5 × 0.5 = 0.5), the most they ever can at two alleles.
> Try one number Take q = 0.10, so p = 0.90. AA: 0.90 × 0.90 = 0.81. Aa: 2 × 0.90 × 0.10 = 0.18. aa: 0.10 × 0.10 = 0.01. Check the total: 0.81 + 0.18 + 0.01 = 1.00. With an allele at 10%, only 1 person in 100 is aa, but 18 in 100 carry one copy.

This is the product and sum rule from [probability and crosses](https://stemhop.com/lessons/probability-and-crosses/), applied to a whole population. The first film’s recount of A copies, in three lines (AA zygotes are all A; Aa zygotes are half A):

1. A frequency = p2 + (half of 2pq) = p2 + pq.
2. Take p out of both terms: p2 + pq = p(p + q).
3. p + q = 1, so this is just p.

The allele frequency has not moved, and one generation of random mating gives these genotype proportions whatever the proportions were before, provided eggs and sperm begin with the same p and q.

G. H. Hardy published this in 1908; Wilhelm Weinberg, a physician in Stuttgart, derived it independently in a lecture in January 1908, so the principle carries both names. W. E. Castle and Karl Pearson had made earlier attempts at the same problem.

Hardy-Weinberg is a **null model**: what you would see under the baseline in the box above, against which you detect departures. Real populations break its assumptions.

## Counting alleles and testing equilibrium

**Worked problem, part 1.** In a sample of 1,000 people typed at a codominant locus (each genotype distinguishable), there are MM 298, MN 489 and NN 213. Assume unrelated individuals and accurate typing.

1. *Count alleles, not people.* Each MM person carries two M copies and each MN person one. M copies = 2 x 298 + 489 = 1,085, out of 2,000. So p = 0.5425, and q = 1 - p = 0.4575. Count first; never find p from the square root of a homozygote frequency before you know the sample is at equilibrium.
2. *Expected counts.* Multiply the sample size by each [Hardy-Weinberg](https://stemhop.com/methods/population-genetic-models/) proportion. MM = 1,000 x 0.54252 = 294.3. MN = 1,000 x 2 x 0.5425 x 0.4575 = 496.4. NN = 1,000 x 0.45752 = 209.3. They add to 1,000.
3. *[Chi-square](https://stemhop.com/methods/chi-square-test/)*, a score for how far the counts sit from the expected ones (bigger means more surprising; see [probability and crosses](https://stemhop.com/lessons/probability-and-crosses/)). (298 - 294.3)2 / 294.3 = 0.046; (489 - 496.4)2 / 496.4 = 0.110; (213 - 209.3)2 / 209.3 = 0.065. The total is 0.22.
4. *Degrees of freedom.* Three classes, minus 1 because the counts must add to 1,000, minus 1 more because p was estimated from these same counts: **1**, not 2.
5. *Decide.* The critical value at P = 0.05 for one degree of freedom is 3.84. Since 0.22 is far below it (P is about 0.64), there is no evidence of departure.

That is all: a good fit does not prove random mating or the absence of selection, and a poor fit does not prove selection, because inbreeding, a sample that mixes two populations, and genotyping errors can all produce one.

**Worked problem, part 2.** A recessive condition affects 1 in 2,500 newborns in a hypothetical population. Assume the population is at equilibrium at this locus.

**Predict.** Will carriers be nearer 1 in 2,500, 1 in 50 or 1 in 25? Name their Hardy-Weinberg term.

> **Check your prediction.** Carriers are two p q, about 1 in 26, so 1 in 25 is the closest choice.

Affected people are aa, so q2 = 1/2,500; the square root gives q = 1/50 = 0.02, and p = 0.98. Carriers are 2pq = 2 x 0.98 x 0.02 = 0.039, about 1 in 26 (1 ÷ 0.0392 is about 25.5).

Carriers are about 100 times as common as affected people (0.0392 / 0.0004 = 98). In symbols, 2pq / q2 = 2p/q (one q cancels), and when q is small p is close to 1, so the ratio is close to 2/q: here 2/0.02 = 100. A rare allele sits almost entirely in heterozygotes: here 98% of a copies are in carriers. This is how families meet a recessive condition with no affected relatives in the [pedigree](https://stemhop.com/lessons/pedigrees/).

That 1 in 26 needs both q = 0.02 and Hardy-Weinberg proportions: non-random mating can change it while q stays fixed. The second film asks what can move q.

**Film transcript: What Moves Allele Frequencies?**

### Film transcript: What Moves Allele Frequencies?

The first film left the blue and gold allele bar unchanged after mating. What must happen to move that boundary? Keep following copies as different processes act on the population. The answer depends on what touches those copies.

Selection acts when genotypes leave different numbers of surviving offspring. Suppose a genotype contributes fewer copies to the next pool. The bar moves predictably toward the copies contributed more often. Which genotype has that advantage depends on the environment. So the direction can change when the environment changes. Migration moves copies between populations. Pour a small stream from a population with a different allele mix into the resident pool. The new frequency becomes a weighted average. It shifts toward the migrants' mix. The amount of movement depends on the migrants' share. Mutation changes the identity of a copy. A blue block flips to gold as it enters the next pool.

That creates a new route between allele states. At a human locus, the immediate frequency change is usually weak. Mutation supplies variation on which other forces act. Now copy the same small population twice. Each copy samples its next generation by chance. Both begin with the same copy inventory.

Predict the result. Must both allele bars move together, or can identical starting populations separate without selection? They can separate. Drift is random sampling of allele copies between generations. One sample happens to take more blue; another takes more gold.

Across many repeats there is no preferred direction, but small populations spread widely. Non-random mating produces a different signature. Relatives, or partners alike in a trait this locus affects, pair more often. So homozygotes can increase while heterozygotes decrease. Yet every blue and gold copy remains. The bar therefore stays in the same place. Mating pattern alone changes genotype frequencies, not allele frequencies. These processes can overlap, so an unusual sample rarely names a cause. A heterozygote deficit might reflect non-random mating, mixed populations, or genotyping error. A pattern can therefore support several explanations.

Population genetics compares predictions with patterns, then asks for independent evidence. Track what each process touches. Selection changes contribution. Migration changes membership. Mutation changes identity. Drift changes the sample. Non-random mating changes pairing. The moving bar is evidence to explain, not a label for one cause. Forces change allele frequencies in distinct, testable ways. Follow the copies, compare the expected signature with the data, and keep alternative causes open until more evidence separates them.

From the film

- Forces change allele frequencies in distinct, testable ways.
- Selection changes which genotypes contribute copies; migration mixes populations.
- Mutation creates alleles, while drift samples them without a preferred direction.
- Non-random mating alone rearranges genotypes without changing allele frequencies.

## What can move a frequency?

The second film showed what each process touches; here is how far and how fast. Recall the rule: mating reshuffles alleles; dominance alone does not change their frequency. To move a frequency, something has to act on the population.

**Selection** (genotypes differing consistently in survival or reproduction) is fast or slow depending on which genotypes it can “see.” Against a rare recessive it is slow, because selection acts only on aa, and almost every a copy is hidden in a carrier. If aa individuals never reproduced, q would fall as qn = q0 / (1 + n q0), where q0 is the starting frequency and qn the frequency after n generations. Starting at 0.02, halving q to 0.01 takes 50 generations: with qn = 0.01, 1 + n × 0.02 must equal 0.02 / 0.01 = 2, so n = 50. (Check: at n = 0 the formula gives q0, and q shrinks ever more slowly as it gets rarer.)

**Migration** (gene flow) gives the second film’s weighted average.

**Predict.** Residents have p = 0.2, migrants p = 0.6, and migrants supply one tenth of the copies. Estimate the new p.

> **Check your prediction.** Nearer 0.2, because residents supply nine tenths of the copies.

> **Equation card: How far one generation of migration moves a population's allele frequency.**
>
>     p' = (1 − m) p + m p_m
>
> In words: Next generation's p is the residents' share times their frequency, plus the migrants' share times theirs.
>
> - p': the frequency of allele A in the next generation
> - m: the fraction of the next generation's allele copies that come from migrants, so 1 − m come from residents
> - p: the residents' frequency of A now
> - p_m: the frequency of A among the migrants
>
> Sanity check: With no migrants (m = 0) p' = p and nothing changes. If every copy came from migrants (m = 1), p' = p_m. Between those, p' always lands between p and p_m.
> Try one number With p = 0.2, p_m = 0.6 and m = 0.1: residents supply 0.9 × 0.2 = 0.18 and migrants supply 0.1 × 0.6 = 0.06. p’ = 0.18 + 0.06 = 0.24. The frequency moved a tenth of the way from 0.2 toward 0.6, because a tenth of the copies are new.

**Mutation**, the source of new alleles (see [mutation](https://stemhop.com/lessons/mutation/)), is weak on frequency. In human parent-offspring trios, the TOPMed study estimated about 1.2 x 10−8 new single-base changes per base pair per generation, a genome average. That is about one change per 83 million base pairs (1 ÷ 1.2 x 10−8 is about 83 million; see [powers](https://stemhop.com/math-toolkit/#powers)). Over a few generations, that barely moves an allele frequency.

**Non-random mating** is the odd one out, as the second film showed: same copies, different pairs. Its two kinds are **inbreeding** (mating between relatives) and **assortative mating** (partners alike in a trait the locus affects). By putting more rare recessive copies into aa individuals, they can still expose those alleles to selection.

*Figure (AI-generated illustration).* Inbreeding and assortative mating pair the same allele copies differently: homozygotes become more common and heterozygotes rarer, so genotype frequencies change while p and q stay where they were. Image: two panels each showing four people holding two allele blocks apiece. With random mating there are one AA, two Aa and one aa person. With inbreeding or assortative mating there are two AA and two aa people. Both panels use the same four A and four a blocks, re-paired by a broad arrow between them.

## Drift and founders: chance in small populations

The second film’s two cups showed **drift**: chance sampling of the parents’ allele copies. Under the simplest model, with a constant **[effective population size](https://stemhop.com/methods/population-genetic-models/)** Ne (the number of breeders in an idealized population that would drift at the same rate), one generation’s wobble has a known size.

**Predict.** At the same Ne, is one-generation variance larger at p = 0.5 or p = 0.1? Check the boundaries.

> **Check your prediction.** Larger at p = 0.5; p(1 - p) peaks halfway between the boundaries.

> **Equation card: How far, on average, chance alone moves an allele frequency in one generation.**
>
>     Var(Δp) = p(1 − p) / (2 × Ne)
>
> In words: The variance of the change in p equals p times one minus p, divided by twice the effective population size.
>
> - Δp: the change in the allele frequency p from one generation to the next. Var(Δp) is its variance: how widely that change scatters if you could rerun the generation many times.
> - p: the allele frequency now
> - Ne: the effective population size. Each breeder passes on two allele copies, hence the 2.
>
> Sanity check: If p is 0 or 1 the variance is zero: a lost or fixed allele has nothing left to drift. The wobble is largest at p = 0.5, and it shrinks as Ne grows, so drift matters most in small populations.
> Try one number With Ne = 50 and p = 0.5: the top is 0.5 × 0.5 = 0.25 and the bottom is 2 × 50 = 100. Variance = 0.25 / 100 = 0.0025. The standard deviation is its square root, 0.05. Across repeated populations, the one-generation changes have standard deviation 0.05. Any one population can move less or more, in either direction.

Left long enough, a small population’s frequency wanders until it hits 0 (the allele is lost) or 1 (it is **fixed**).

*Interactive on the lesson page:* Drift and selection: replicate populations

Peter Buri saw this in 1956 in 107 laboratory populations of Drosophila, each kept at 8 males and 8 females and started at one half for an eye-colour allele. Over 19 generations they spread apart and many lost or fixed the allele, while their average stayed near where it began.

A **founder effect** is drift at the start of a population: a small group carries, by chance, a different set of alleles than the population it left. In a 2020 exome study of 5,521 Lancaster County Old Order Amish participants, 124 carried the KCNQ1 variant p.T224M, about 1 in 45, and none was homozygous. Each person carries two copies, so the 124 carriers hold 124 variant copies out of 2 x 5,521 = 11,042, an allele frequency of about 0.011: a carrier frequency of 1 in 45 is not an allele frequency of 1/45. The authors note that pathogenic variants may occur at much higher frequency in founder populations, and they attribute this variant’s frequency to a founder effect and drift. Tay-Sachs disease among Ashkenazi Jewish people and the rare diseases of the Finnish disease heritage are other examples often taught this way. These are features of particular populations and their histories, not of races: most human genetic variation lies within populations, not between them.

## Balanced polymorphism: sickle cell and malaria

The sickle allele of the β-globin gene (HBB) changes glutamate to valine at position 6 of the β chain, and deoxygenated HbS polymerises (see [protein binding and allostery](https://stemhop.com/lessons/protein-binding-allostery/)). Sickle-cell disease (SS) is autosomal recessive. In conditions where the disease shortens life, selection should remove S. Yet in regions with intense falciparum malaria the allele is common.

**Predict.** If AS survives better than both homozygotes, should S disappear, become fixed, or settle between?

> **Check your prediction.** Between the extremes: rare S sits mostly in favoured AS, while common S makes more SS, which selection removes.

The reason is heterozygote advantage. In two cohorts of children on the Kenyan coast, sickle-cell trait (AS) made no difference to how often children carried parasites without symptoms, but it was associated with about 50% protection against mild malaria, 75% against hospital admission and almost 90% against severe disease. The allele settles where the losses at the two homozygotes balance; with costs s to AA and t to SS, the equilibrium is:

*Figure (AI-generated illustration).* Sickle-cell trait (AS) does not give immunity to malaria, but it was associated with protection against mild, admitted and severe malaria. AS outsurvives AA through malaria and SS through the disease, so selection holds both alleles. Image: three tiles showing red blood cells for genotypes AA, AS and SS. The AA cell is round with a malaria parasite inside. The AS cell is round, also with a parasite, and is outlined in gold with a shield badge. The SS cell is crescent-shaped with a bundle of rods inside. A band below reads that selection holds both alleles.

> **Equation card: Where heterozygote advantage holds the frequency of the S allele.**
>
>     q = s / (s + t)
>
> In words: The equilibrium frequency of S is the cost to AA divided by the two costs added together.
>
> - q: the frequency of the S allele at equilibrium
> - s: the fitness cost to AA homozygotes: 1 minus their survival relative to AS
> - t: the fitness cost to SS homozygotes: 1 minus their survival relative to AS
>
> Sanity check: If the two costs are equal (s = t), q = 1/2. If SS costs far more than AA (t much bigger than s), q is small: the allele stays rare because each S copy that lands in an SS person is lost. If AA paid no cost (s = 0), q = 0 and nothing would hold S.
> Try one number Round values to keep the arithmetic easy (not data): s = 0.2 and t = 0.8. q = 0.2 / (0.2 + 0.8) = 0.2 / 1.0 = 0.2. So S would settle at 20% of allele copies, with A at 80%.

### Design problem

Interpret these illustrative data (not measurements) for a malaria-endemic population. Newborns are AA 0.81, AS 0.18 and SS 0.01, so q = 0.10, at [Hardy-Weinberg](https://stemhop.com/methods/population-genetic-models/) proportions. Relative survival to adulthood is AA 0.88, AS 1.00 and SS 0.20. What maintains the S allele, where should its frequency settle, and what would adults look like? What other data would you need to rule out migration or drift?

> **One way to do it.** Heterozygotes survive best, so this is balancing selection. The fitness costs are s = 1 - 0.88 = 0.12 for AA and t = 1 - 0.20 = 0.80 for SS. Assuming a large, randomly mating population with survival as the only force, the equilibrium is q = s / (s + t) = 0.12 / (0.12 + 0.80) = 0.12 / 0.92 = 0.13. Since newborns start at 0.10, q should rise slightly over generations.
>
> Check one generation. Survivors are AA 0.81 x 0.88 = 0.713, AS 0.18, SS 0.01 x 0.20 = 0.002, out of 0.895. As fractions of adults: AA 0.797, AS 0.201, SS 0.002. Adult q = 0.201/2 + 0.002 = 0.103. Under Hardy-Weinberg, q = 0.103 predicts 2 x 0.897 x 0.103 = 0.185 heterozygotes, but adults have 0.201. Adults show a **heterozygote excess**, even though their newborns fit. When to sample matters.
>
> To separate selection from the alternatives, show that the allele’s frequency follows the historical intensity of malaria across regions, that AS children are protected in follow-up studies, and that newborns fit equilibrium while adults show the excess. Migrants from a high-S population would raise q, but if they come from a population at Hardy-Weinberg proportions the mixture shows a heterozygote deficit, not an excess, unless the adult migrants were themselves selected in a malarious region; so record where each adult was born.

The [next lesson](https://stemhop.com/lessons/complex-traits-and-gwas/) uses the same allele counts, across hundreds of thousands of loci at once, to look for variants associated with complex traits.

---

From STEMhop (https://stemhop.com), free lessons by Christopher Deppmann. Lesson text © the authors. Practice questions: https://stemhop.com/lessons/population-genetics/
