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

  1. 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).
df = 1 for two alleles

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).

Pattern diagnosis

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.

QC, not biology

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.

Significant != important

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

✗ Myth: Rejecting H-W proves natural selection.

✓ Truth: Deviation has many causes: inbreeding, structure, migration, genotyping error. Selection is one candidate among several.

✗ Myth: df = 2 for the H-W test.

✓ 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
  1. 3
  2. 2
  3. 1
  4. 0
Answer: C.

3 genotype classes - 1 (total fixed) - 1 (p estimated) = 1.

Q2. A heterozygote deficit in H-W testing most likely indicates
  1. Genotyping error only
  2. Inbreeding or population structure
  3. Heterozygote advantage
  4. High mutation
Answer: B.

Inbreeding and Wahlund effects both reduce observed heterozygotes below 2pq.

Q3. In GWAS quality control, SNPs failing H-W in controls are typically
  1. Signatures of selection
  2. Discarded as likely genotyping errors
  3. Reported as hits
  4. Imputed
Answer: B.

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.