Hardy-Weinberg Extended Calculator

Calculate allele frequencies, test for HWE departure, and detect selection or drift.

Leave 0 to calculate from counts
Please check your inputs and try again.

The Five Assumptions

Hardy–Weinberg describes what allele and genotype frequencies do when nothing is happening evolutionarily. Departure from it therefore signals that something is.

AssumptionViolated by
No selectionFitness differences between genotypes
No mutationNew alleles arising
No migrationGene flow from other populations
Infinite populationGenetic drift in small populations
Random matingAssortative mating, inbreeding, population structure
p² + 2pq + q² = 1     χ² = Σ(O − E)²/E, df = 1

Note that df = 1 for a two-allele locus, not 2. Three genotype classes give two degrees of freedom, but one is consumed estimating the allele frequency from the data itself. The critical value at p = 0.05 is therefore 3.84.

Reading a Departure

PatternSuggests
Heterozygote deficitInbreeding, population structure (Wahlund effect), null alleles
Heterozygote excessBalancing selection, outbreeding, small sample
Departure at one locus onlyGenotyping error or selection at that locus
Departure across many lociPopulation structure or admixture

That last distinction is how HWE testing is used in practice. A single locus out of equilibrium in a genotyping panel usually means a technical problem — a null allele or a miscalled genotype — which is why HWE is a standard quality control filter in genome-wide studies. Departure across many loci simultaneously points to genuine population structure instead.

The Wahlund effect is worth knowing: pooling two populations with different allele frequencies produces a heterozygote deficit even when each subpopulation is individually in perfect equilibrium.

Worked Examples

Example 1: 36 AA, 48 Aa, 16 aa (n=100)
p=0.60, q=0.40, exp: AA=36, Aa=48, aa=16
Result: chi²=0 — perfect HWE
This is the exact HWE expectation
Example 2: 30 AA, 60 Aa, 10 aa (n=100)
p=0.60, exp same
Result: chi²=6.25 — significant departure!
Excess heterozygotes — heterozygote advantage?
Example 3: Heterozygote deficit from structure
Two populations pooled, each internally in HWE
Result: Apparent deficit of heterozygotes
The Wahlund effect. Differing allele frequencies between subpopulations produce fewer heterozygotes than the pooled allele frequencies predict.
Example 4: HWE as quality control
One SNP of 500,000 shows χ² = 45
Result: Genotyping error, not selection
A single extreme outlier in a genome-wide panel almost always reflects a technical problem. This is why HWE filtering is standard practice.

Common Mistakes

⚠️
Using df = 2 for a two-allele locus

One degree of freedom is consumed estimating the allele frequency from the data. Use df = 1, with a critical value of 3.84.

⚠️
Concluding evolution from a single locus departure

One locus out of equilibrium in a large panel usually indicates a genotyping error or null allele rather than selection.

⚠️
Forgetting the Wahlund effect

Pooling subpopulations with different allele frequencies creates an apparent heterozygote deficit even when each is individually in equilibrium.

⚠️
Applying the chi-square test to small expected counts

With expected genotype counts below about five, the chi-square approximation fails. Use an exact test instead.

Frequently Asked Questions

HWE assumptions (5 conditions)?
1. Large population (no drift). 2. No mutation. 3. No migration. 4. Random mating. 5. No selection. Violation of any one causes departure. Most real populations violate multiple assumptions.
Uses of HWE?
Detecting selection (excess homozygotes = inbreeding or selection against het). Quality control in GWAS (excess homozygotes can indicate genotyping error). Estimating carrier frequencies in genetic counseling. Testing population structure.
What are the Hardy–Weinberg assumptions?
No selection, no mutation, no migration, infinite population size, and random mating. Departure indicates one or more is violated.
Why is df = 1 rather than 2?
Three genotype classes give two degrees of freedom, but one is used estimating the allele frequency from the same data. The critical value is 3.84.
What does a heterozygote deficit indicate?
Inbreeding, population structure, or null alleles in the genotyping assay. The Wahlund effect produces it whenever subpopulations are pooled.
Why is HWE used as quality control?
Because a single locus departing sharply in a large panel almost always reflects genotyping error rather than biology, making it an effective filter.