Advancedpopulation
Testing Hardy-Weinberg with Chi-Square
Overview
The chi-square test compares observed genotype counts to Hardy-Weinberg expectations computed from allele frequencies. Significant deviation (p < 0.05) rejects equilibrium and signals selection, nonrandom mating, migration, or genotyping error. With df = 1 for two alleles (3 genotypes minus 1 for total minus 1 for estimated p), the critical value is 3.84.
Learning objectives
- Compute H-W expected counts from observed data
- Run the chi-square test with correct df
- Interpret significant vs non-significant results
- Diagnose causes of deviation
The procedure
- Count alleles: p = (2N_AA + N_Aa)/2N. 2. Expected: Np^2, N2pq, Nq^2. 3. X^2 = sum((O-E)^2/E). 4. df = 1 (for 2 alleles). 5. Compare to 3.84. Example: 120 AA, 60 Aa, 20 aa (N=200): p = 0.75, expected 112.5/75/12.5, X^2 = 0.5 + 3.0 + 4.5 = 8.0 > 3.84: reject equilibrium (heterozygote deficit + aa excess suggests inbreeding).
Three genotype classes minus one (fixed total) minus one (estimated p) leaves 1 degree of freedom.
What deviation means
Heterozygote deficit: inbreeding, Wahlund effect, or selection against heterozygotes. Heterozygote excess: disassortative mating, heterozygote advantage, or recent admixture. Homogeneous excess of one homozygote: directional selection or genotyping dropout (null alleles).
The DIRECTION of deviation (which genotype is off) is as informative as its significance.
Genome-wide H-W testing
GWAS pipelines test H-W in controls for every SNP: systematic deviation flags genotyping errors (bad SNPs are discarded). True biological deviations are rare per-SNP, so H-W filtering is primarily quality control at genomic scale.
In GWAS, H-W p < 10^-6 in controls usually means a bad assay, not interesting evolution.
Power and pitfalls
Large samples detect trivial deviations; tiny samples miss real ones. Multiple testing across many loci needs correction. And H-W testing assumes the locus is autosomal and diploid: apply X-linked or polyploid versions where appropriate.
With n = 1,000,000, biologically trivial deviations become 'significant.' Report effect sizes too.
Key points
- Expected counts from allele counting; X^2 = sum((O-E)^2/E); df = 1; critical 3.84
- Heterozygote deficit suggests inbreeding/Wahlund; excess suggests admixture/advantage
- GWAS uses H-W testing mainly for genotyping QC
- Large samples make trivial deviations significant
Common misconceptions
✓ Truth: Deviation has many causes: inbreeding, structure, migration, genotyping error. Selection is one candidate among several.
✓ Truth: Estimating p from the data consumes a degree of freedom: df = 3 - 1 - 1 = 1.
Practice questions
Q1. For a two-allele H-W chi-square test, degrees of freedom equal
- 3
- 2
- 1
- 0
3 genotype classes - 1 (total fixed) - 1 (p estimated) = 1.
Q2. A heterozygote deficit in H-W testing most likely indicates
- Genotyping error only
- Inbreeding or population structure
- Heterozygote advantage
- High mutation
Inbreeding and Wahlund effects both reduce observed heterozygotes below 2pq.
Q3. In GWAS quality control, SNPs failing H-W in controls are typically
- Signatures of selection
- Discarded as likely genotyping errors
- Reported as hits
- Imputed
Systematic deviation usually reflects assay artifacts rather than biology.
Click a question to reveal the answer and explanation.
Frequently asked questions
Why estimate p from the data instead of assuming it?
True p is unknown; using the sample's own allele count gives the best-fit null, costing one df.
What is a null allele in genotyping?
A PCR primer-site mutation causing one allele to drop out, creating false homozygotes and apparent H-W deviation.
Can H-W hold at some loci but not others?
Yes: selection acts per-locus, so most of the genome can be at equilibrium while selected loci deviate.