Why Use an Exact Test?
A Pearson test compares observed genotype counts with counts expected under Hardy-Weinberg equilibrium (HWE), using a chi-square reference distribution. That approximation can be unreliable when the sample is small or some expected genotype counts are sparse. Genotype counts are discrete, and with few individuals only a limited set of tables may be possible. A continuous chi-square approximation cannot represent that discreteness exactly.
An exact HWE test instead calculates probabilities for the possible genotype tables under a conditional null model. It is especially useful when a variant is uncommon or the sample is small. Its p-value is computed from a discrete distribution, rather than from a large-sample approximation. The exact calculation does not, however, remove the need to check whether the data and model are appropriate.
Conditional Distribution of the Heterozygote Count
Call the allele counted in \(R\) the A allele, and call the other allele a. Let \(r\) be the number of AA homozygotes and \(c\) the number of aa homozygotes. The genotype counts must satisfy \(2r+h=R\) and \(2c+h=2n-R\). Thus, for any possible heterozygote count \(h\), \(r=(R-h)/2\) and \(c=(2n-R-h)/2\). These counts must be nonnegative integers, so not every integer between 0 and \(n\) is possible.
Under HWE with A-allele frequency \(q\), the genotype probabilities are \(q^2\), \(2q(1-q)\), and \((1-q)^2\) for AA, Aa, and aa. Assuming independent genotype sampling, the probability of a particular count table is its multinomial coefficient times the product of those genotype probabilities. Conditioning on \(R\) removes the factors involving \(q\): every table with the same allele count has the same factor \(q^R(1-q)^{2n-R}\). The remaining relative weight for a possible \(h\) is
where the sum is over all possible heterozygote counts \(u\) consistent with \(n\) and \(R\), and \(H\) denotes the random heterozygote count. This gives a complete conditional distribution without needing to estimate the allele frequency for the test.
From the Distribution to a Two-Sided P-Value
A commonly used two-sided exact convention is probability ordering. For the observed heterozygote count \(h_{\mathrm{obs}}\), add the conditional probabilities of every possible count whose individual probability is no greater than the probability of the observed count:
This convention includes outcomes at least as improbable as the observed outcome, where improbability is judged by each outcome’s probability under the conditional null. It is not a rule that selects outcomes because their combined probability is below some threshold. Discrete distributions can also make different definitions of “two-sided” give different p-values; reports should identify the convention used.
Worked Example: A Small Sample Where Pearson’s Approximation Is Misleading
Suppose a hypothetical sample has \(n=4\) individuals, with 1 AA, 0 Aa, and 3 aa genotypes. The A-allele count is \(R=2(1)+0=2\). Under the conditional null, the possible heterozygote counts are \(h=0\) and \(h=2\).
For \(h=0\), \(r=1\) and \(c=3\), so \(w(0)=4!/(1!0!3!)=4\). For \(h=2\), \(r=0\) and \(c=2\), so \(w(2)=2^2 4!/(0!2!2!)=24\). The weights sum to 28; therefore \(P(H=0\mid R=2)=4/28=0.1429\) and \(P(H=2\mid R=2)=24/28=0.8571\).
The observed count is \(h_{\mathrm{obs}}=0\). It is the only possible outcome with probability no greater than 0.1429, so the probability-ordered exact p-value is \(0.1429\). At \(\alpha=0.05\), this test does not reject HWE.
For comparison, the estimated A-allele frequency is \(2/8=0.25\). Pearson expected counts are \(4(0.25^2)=0.25\) AA, \(4(2(0.25)(0.75))=1.5\) Aa, and \(4(0.75^2)=2.25\) aa. The Pearson statistic is \( (1-0.25)^2/0.25+(0-1.5)^2/1.5+(3-2.25)^2/2.25=4.00\). With the usual one degree of freedom, its approximate p-value is about 0.0455. The Pearson approximation would reject at 5%, whereas the conditional exact test would not. The expected counts are very small, so the chi-square approximation is questionable; the exact result reflects the limited set of tables possible for this sample.
Worked Probability-Ordered Calculations
Worked Example: Calculating the Exact P-Value for a Less Sparse Table
Consider a hypothetical sample of \(n=10\) with 2 AA, 2 Aa, and 6 aa genotypes. The allele count is \(R=2(2)+2=6\), and the observed heterozygote count is \(h=2\). The possible values of \(h\) are 0, 2, 4, and 6.
Their weights are \(w(0)=10!/(3!0!7!)=120\), \(w(2)=2^2 10!/(2!2!6!)=5040\), \(w(4)=2^4 10!/(1!4!5!)=20160\), and \(w(6)=2^6 10!/(0!6!4!)=13440\). The total weight is \(38760\). The corresponding probabilities, rounded to four significant figures, are 0.003096, 0.1300, 0.5201, and 0.3467.
The observed table has conditional probability 0.1300. The outcomes with individual probabilities no greater than 0.1300 are \(h=0\) and \(h=2\), so \(p_{\mathrm{exact}}=120/38760+5040/38760=5160/38760\approx0.1331\). In context, under the conditional HWE null and this probability-ordering convention, the total probability of outcomes at least as improbable as the observed heterozygote count is approximately 0.1331. Since \(0.1331>0.05\), the exact test does not reject HWE at the 5% level.
The Pearson expected counts are 0.9 AA, 4.2 Aa, and 4.9 aa, using the observed allele frequency \(6/20=0.3\). These include expected counts below 5, so the approximation deserves caution. Here the exact calculation gives the directly relevant conditional probability rather than relying on that approximation.
Worked Example: An Exact Result Below the 5% Level
For another hypothetical sample, let \(n=8\), with 2 AA, 0 Aa, and 6 aa genotypes. Then \(R=4\) and the observed heterozygote count is 0. The possible counts are \(h=0,2,4\).
The weights are \(w(0)=8!/(2!0!6!)=28\), \(w(2)=2^2 8!/(1!2!5!)=672\), and \(w(4)=2^4 8!/(0!4!4!)=1120\). Their sum is 1820, so the probabilities are 0.01538, 0.3692, and 0.6154, respectively. Since only \(h=0\) has probability no greater than the observed outcome’s probability, \(p_{\mathrm{exact}}=28/1820=0.01538\). Under the conditional HWE null and the stated two-sided convention, the total probability of outcomes at least as improbable as the observed one is 0.01538. This is below 0.05, so the test rejects HWE at the 5% level.
This conclusion is about evidence against the specified conditional HWE model, not proof of a particular cause of deviation. The calculation presumes that the assumptions stated above are suitable for these data.
Calculation Checks, Alternatives, and Limitations
A reliable calculation starts by checking the genotype table: the counts must sum to \(n\), and \(R=2r+h\) must be an integer from 0 to \(2n\). Then enumerate only heterozygote counts that give nonnegative integer values of \(r\) and \(c\). Compute each weight, normalize by their sum, and check that the probabilities sum to 1 (allowing for rounding). Finally, apply the chosen two-sided convention to the observed table’s probability, not to the table’s distance from an expected count.
Pearson’s test is a convenient large-sample alternative: it summarizes squared discrepancies from expected genotype counts and uses a chi-square approximation. It is often adequate when the approximation is reasonable, but can be poor with sparse expected counts. The conditional exact test handles discreteness directly, at the cost of requiring an enumeration and a stated two-sided convention. Exact p-values can be conservative because a discrete distribution may not allow a test to attain exactly the nominal significance level.
A mid-\(p\) calculation is sometimes reported as an alternative: it adds the probability of outcomes strictly less likely than the observed outcome, plus half the probability of outcomes tied with it. This can reduce conservatism, but it is not an exact level-\(\alpha\) test in the same sense: its probability of rejection under the null can exceed \(\alpha\). It should not be silently substituted for a probability-ordered exact p-value.
An exact test does not diagnose why a departure from HWE occurs, and failure to reject does not establish that HWE holds. Its validity depends on the sampling and genotype assumptions, and its interpretation is conditional on the observed allele count. For a genome-wide analysis, separate issues such as multiple testing and the population or sample context require attention; the single-locus exact calculation alone does not resolve them.
Check Your Understanding
Use probability ordering for each question. Solutions are given below the questions.
- For \(n=5\) and \(R=2\), enumerate the possible heterozygote counts and their conditional probabilities.
- In the setting of question 1, what is the exact p-value if the observed heterozygote count is 0? What is the decision at \(\alpha=0.05\)?
- State what a probability-ordered p-value of 0.03 means for a conditional HWE test.
- Why can a Pearson HWE test be unreliable when expected genotype counts are small?
Solutions. For question 1, \(h=0\) gives \(r=1,c=4\), with weight \(5!/(1!0!4!)=5\). \(h=2\) gives \(r=0,c=3\), with weight \(2^2 5!/(0!2!3!)=40\). The total is 45, so the probabilities are \(1/9=0.1111\) and \(8/9=0.8889\). For question 2, the observed outcome \(h=0\) is the only outcome with probability no greater than its own, so the exact p-value is 0.1111. Since this exceeds 0.05, do not reject HWE at that level. For question 3, under the conditional HWE null and the stated probability-ordering convention, the total probability of outcomes at least as improbable as the observed outcome is 0.03; it is not the probability that the null is true. For question 4, the chi-square reference distribution is an approximation whose accuracy can be poor when expected counts are sparse and the possible count tables are highly discrete.