What the Pearson Hardy-Weinberg Test Assesses
For a biallelic autosomal variant, the Hardy-Weinberg model specifies genotype proportions \(p^2\), \(2pq\), and \(q^2\), where \(p\) and \(q=1-p\) are the two allele frequencies. The earlier material on expected genotype counts established how to estimate these proportions and turn them into expected counts. Here the question is whether the observed genotype counts depart more than expected from those model-based counts.
The Pearson goodness-of-fit test summarizes the discrepancies across the three genotype categories. Its reference distribution is approximate: under the null model and suitable regularity conditions, the statistic is compared with a chi-square distribution with one degree of freedom. A small upper-tail p-value is evidence against the Hardy-Weinberg proportions for the sampled population; it does not identify the reason for a departure.
Assumptions and the One-Degree-of-Freedom Reference
The test requires genotype counts from a clearly defined group of diploid individuals at a biallelic autosomal locus. It assumes individuals contribute independent observations, genotype calls are sufficiently accurate for the counts to be meaningful, and the null model of Hardy-Weinberg proportions is appropriate for the population being assessed. The model is generally motivated by conditions such as random mating with respect to the locus and no consequential population mixture or other process disrupting the proportions. These are modeling conditions, not guarantees supplied by the calculation.
The chi-square approximation also requires sufficiently large expected counts. A common practical rule is that each expected count should be at least about 5; this is a diagnostic guideline rather than a universal theorem. When expected counts are sparse, the Pearson statistic can still be computed, but its chi-square p-value may be poorly calibrated. A small expected count is not repaired by a large total sample size if one genotype category remains rare.
The degrees of freedom reflect both the three genotype categories and the fitted allele frequency. The three observed counts sum to \(n\), so only two count contrasts can vary independently. Estimating \(p\) from those same counts uses one of these dimensions: changes in the fitted frequency account for one direction of discrepancy. One independent direction of departure remains, giving \(3-1-1=1\) degree of freedom. This is why the test is not compared with a two-degree-of-freedom distribution when the allele frequency is estimated from the sample. If the allele frequency were fixed in advance rather than estimated, the usual goodness-of-fit count would instead be \(3-1=2\) degrees of freedom.
The justification is asymptotic. Under the null, the three genotype counts have a multinomial distribution with probabilities determined by \(p\). For large samples with probabilities away from zero, their centered, scaled count vector is approximately normal. Its possible fluctuations lie in the two-dimensional plane imposed by the fixed total. Estimating \(p\) fits one direction of that fluctuation, leaving a one-dimensional residual component. The Pearson quadratic form in that remaining component is asymptotically distributed as \(\chi^2_1\). This approximation depends on the null model and adequate expected counts; it is not an exact finite-sample identity.
Worked Example: A Departure With Adequate Expected Counts
Suppose a hypothetical quality-control data set contains 500 unrelated diploid samples at a biallelic autosomal locus. The observed counts are 320 \(AA\), 150 \(Aa\), and 30 \(aa\). Assume for this calculation that genotype calls are reliable and that these samples are intended to represent one population. Test the Hardy-Weinberg proportions at \(\alpha=0.05\).
First estimate the allele frequencies. There are \(2(500)=1000\) allele copies, of which \(2(320)+150=790\) are \(A\):
The expected counts under Hardy-Weinberg proportions are:
They sum to 500, as required. Each expected count exceeds 5, so the usual expected-count check does not flag an obvious problem with the chi-square approximation. Now calculate the statistic:
Rounded to three decimal places, \(X^2=4.593\). With \(df=1\), the upper-tail probability is approximately \(P(\chi^2_1\ge 4.59274)=0.0321\). Since \(0.0321<0.05\), reject the Hardy-Weinberg model for this test at the 5% significance level. In context, the observed genotype counts show a statistically significant departure from the fitted Hardy-Weinberg proportions for these hypothetical samples. The result alone does not tell us whether the departure reflects population structure, nonrandom mating, genotyping problems, or another cause.
Using the Statistic and Its P-Value
The null hypothesis is that the genotype proportions follow Hardy-Weinberg proportions at the allele frequency estimated from the sample. The alternative is that they do not. Because the Pearson statistic adds squared discrepancies, departures in either direction increase \(X^2\); the p-value is therefore an upper-tail probability. A large statistic means the observed counts are relatively far from the fitted expected counts, after scaling each discrepancy by its expected count.
A p-value is calculated under the null model and the approximation conditions: it is the probability of obtaining a statistic at least as large as the observed one if those conditions hold. It is not the probability that the null is true, nor is it the probability that a particular biological or technical explanation is correct. The significance threshold \(\alpha\) is chosen before interpreting the result; the p-value is not a measure of the size or importance of the departure.
Worked Example: Counts That Match the Fitted Model
In another hypothetical data set, \(n=200\) samples have observed counts \(O_{AA}=98\), \(O_{Aa}=84\), and \(O_{aa}=18\). Suppose the samples are independent, the calls are reliable, and the expected counts are adequate.
The estimated \(A\)-allele frequency is \(\hat{p}=[2(98)+84]/400=280/400=0.70\), so \(\hat{q}=0.30\). The expected counts are \(E_{AA}=200(0.70)^2=98\), \(E_{Aa}=200(2)(0.70)(0.30)=84\), and \(E_{aa}=200(0.30)^2=18\). Thus:
The upper-tail p-value for a statistic of zero is 1. There is no discrepancy between the observed counts and the fitted expectations. This does not prove that the population satisfies every Hardy-Weinberg assumption; it only says these counts provide no evidence of departure by this statistic.
Worked Example: When the Approximation Is Not Trustworthy
Consider a third hypothetical set of \(n=100\) samples with counts \(O_{AA}=98\), \(O_{Aa}=2\), and \(O_{aa}=0\). Assume the same basic setting of a biallelic autosomal locus and reliable calls. The allele-frequency estimates are \(\hat{p}=[2(98)+2]/200=0.99\) and \(\hat{q}=0.01\). The expected counts are \(98.01\), \(1.98\), and \(0.01\), respectively.
The arithmetic Pearson statistic is:
A mechanical comparison with \(\chi^2_1\) would give an upper-tail probability of about 0.920. However, the expected \(aa\) count is only 0.01, far below the usual adequacy guideline. The reported chi-square probability should not be relied on as a calibrated test result. This example illustrates why checking expected counts is part of the procedure, not an optional afterthought; a finite-sample exact approach is an alternative for sparse counts.
Diagnostics, Alternatives, and Limits
Before interpreting a Pearson test, inspect the observed and expected counts together. Check that the genotype categories are defined consistently, the three counts total the number of included samples, and the allele frequency was computed from allele copies rather than from the proportion of individuals with a genotype. Confirm that the expected counts support the approximation and that the sampled individuals can reasonably be treated as independent. Unexpectedly large discrepancies should prompt scrutiny of the data and model, not just a report of a p-value.
For small expected counts, an exact Hardy-Weinberg test is a principal alternative because it avoids relying on the same large-sample chi-square approximation. The Pearson method is simple and interpretable when counts are adequate; an exact method is more suitable when that approximation is doubtful. Neither method identifies why counts depart from the model. Detailed evaluation of possible causes requires additional context and diagnostics.
A test can also flag a tiny departure in a very large sample, so statistical significance should not be confused with practical importance. Conversely, a nonsignificant result is not proof of equilibrium, especially with limited sample size. Treat the result as one quality-control signal to interpret alongside data quality, population definition, and other evidence. A test outcome by itself is not a justification for deleting a variant or a sample.
Common Mistakes
- Using two degrees of freedom automatically. With allele frequency estimated from these genotype counts, one parameter is fitted; the Pearson test uses \(df=1\).
- Using allele frequency as the genotype proportion. Estimate \(\hat{p}\) from the total number of \(A\) allele copies, then calculate all three expected counts under the model.
- Ignoring small expected counts. A computed statistic does not guarantee a trustworthy chi-square p-value. Inspect all expected counts first.
- Calling a nonsignificant result proof of equilibrium. Failure to reject means the test did not find sufficient evidence of departure; it does not establish that all assumptions hold.
- Treating a significant result as an explanation. It signals mismatch with the fitted proportions, not a specific biological mechanism or genotyping error.
Check Your Understanding
Answer each question, then compare your work with the solutions.
- For counts \(O_{AA}=45\), \(O_{Aa}=40\), and \(O_{aa}=15\), find \(n\), \(\hat{p}\), \(\hat{q}\), and the three Hardy-Weinberg expected counts.
- Why does the Pearson Hardy-Weinberg test use one degree of freedom when the allele frequency is estimated from the sample?
- A test gives \(X^2=2.71\) with \(df=1\). Its approximate upper-tail p-value is 0.100. What is the decision at \(\alpha=0.05\), and what does it mean in context?
- All but one expected genotype count exceed 5; the remaining expected count is 0.4. Is the usual chi-square approximation automatically trustworthy? Explain.
- What can a significant Pearson Hardy-Weinberg test establish, and what can it not establish by itself?
Solutions. (1) \(n=100\). The estimated frequency is \(\hat{p}=[2(45)+40]/200=130/200=0.65\), and \(\hat{q}=0.35\). The expected counts are \(100(0.65)^2=42.25\), \(100(2)(0.65)(0.35)=45.50\), and \(100(0.35)^2=12.25\). (2) The three counts have a fixed total, leaving two independent contrasts; fitting the allele frequency uses one, leaving one residual degree of freedom. (3) Since \(0.100>0.05\), do not reject the Hardy-Weinberg model at the 5% level. The data do not provide sufficient evidence of a departure; this does not prove equilibrium. (4) No. An expected count of 0.4 is sparse, so the chi-square p-value may be poorly calibrated; an exact alternative is preferable. (5) It provides evidence that the observed genotype counts depart from the fitted Hardy-Weinberg proportions under the test assumptions. It does not identify the cause of the departure or prove a particular biological or technical explanation.