Tutorials › Statistical Genetics › Deriving the Allele-Frequency MLE Under Hardy–Weinberg Equilibrium

Likelihoods for Genetic Data · Tutorial 43 of 989

Deriving the Allele-Frequency MLE Under Hardy–Weinberg Equilibrium

See why the estimated allele frequency is the observed fraction of allele copies, and verify the result directly from the genotype likelihood.

Beginner 9 min read

What You'll Learn

  • State the sampling and Hardy–Weinberg assumptions behind the genotype-count likelihood
  • Write the likelihood for three diploid genotype counts as a function of one allele frequency
  • Derive the maximum-likelihood estimate by solving the likelihood equation
  • Verify that the solution is a maximum, including the boundary cases
  • Interpret the estimate as the observed proportion of allele copies

Why Estimate an Allele Frequency From Genotypes?

At a biallelic locus, a diploid individual carries two allele copies. If the alleles are \(A\) and \(a\), the observed genotype is \(AA\), \(Aa\), or \(aa\). The underlying frequency of \(A\) in the population is often a parameter of interest, but the data may be recorded as genotype counts rather than as a list of separately sampled allele copies. Under Hardy–Weinberg equilibrium, those genotype counts have a likelihood determined by the single allele-frequency parameter.

This tutorial derives the maximum-likelihood estimate (MLE) of that frequency and checks the answer using the likelihood equation. The result is a simple allele-count proportion, but its justification depends on the genotype sampling model and the Hardy–Weinberg assumption.

Model and Likelihood

Definition: Consider a biallelic locus with alleles \(A\) and \(a\). Let \(p\) be the population frequency of \(A\), and let \(q=1-p\) be the frequency of \(a\), where \(0\leq p\leq 1\). Under Hardy–Weinberg equilibrium, the genotype probabilities are \(P(AA)=p^2\), \(P(Aa)=2pq\), and \(P(aa)=q^2\). For \(n\) independently sampled diploid individuals, write their observed genotype counts as \(n_{AA}\), \(n_{Aa}\), and \(n_{aa}\), with \(n=n_{AA}+n_{Aa}+n_{aa}\).

The likelihood below assumes that the individuals are sampled independently from a population with a common allele frequency, their genotypes are correctly classified, and the genotype probabilities follow Hardy–Weinberg proportions. In applications, population structure, nonrandom mating, selection, or genotype-calling errors can make these assumptions inappropriate. The calculation estimates \(p\) under the stated model; it does not establish that the model is true.

Because the counts have a multinomial distribution, their likelihood is the probability of observing those counts as a function of \(p\). The multinomial coefficient does not depend on \(p\), but it is included in the full likelihood:

$$ L(p)=\frac{n!}{n_{AA}!\,n_{Aa}!\,n_{aa}!}(p^2)^{n_{AA}}[2p(1-p)]^{n_{Aa}}[(1-p)^2]^{n_{aa}}. $$

Collecting powers of \(p\) and \(1-p\) gives a useful form. Define \(K=2n_{AA}+n_{Aa}\), the number of observed \(A\) allele copies. Since there are \(2n\) allele copies in all, the number of observed \(a\) copies is \(2n-K=n_{Aa}+2n_{aa}\). Thus

$$ L(p)=C\,2^{n_{Aa}}p^K(1-p)^{2n-K}, \qquad C=\frac{n!}{n_{AA}!\,n_{Aa}!\,n_{aa}!}. $$

Here \(C\) and \(2^{n_{Aa}}\) are constant with respect to \(p\). They matter for the numerical value of the likelihood, but not for which value of \(p\) maximizes it.

Worked Example: Writing the Likelihood for Genotype Counts

Suppose, hypothetically, a sample of 100 individuals has \(n_{AA}=36\), \(n_{Aa}=48\), and \(n_{aa}=16\). The counts sum to \(36+48+16=100\), as required. The number of \(A\) copies is

$$ K=2n_{AA}+n_{Aa}=2(36)+48=120, $$

and the number of \(a\) copies is \(48+2(16)=80\), for \(120+80=200=2n\) total copies. Under the model, the likelihood is

$$ L(p)=\frac{100!}{36!\,48!\,16!}(p^2)^{36}[2p(1-p)]^{48}[(1-p)^2]^{16} =C\,2^{48}p^{120}(1-p)^{80}. $$

This is the genotype-count likelihood as a function of the unknown population frequency \(p\). The estimate will follow by maximizing this function, not by treating the genotype categories as three unrelated probabilities.

Deriving the Maximum-Likelihood Estimate

For an interior value \(0<p<1\), take the natural logarithm of the likelihood. The logarithm is a strictly increasing function, so maximizing the log-likelihood gives the same estimate as maximizing the likelihood:

$$ \ell(p)=\log L(p)=\log(C\,2^{n_{Aa}})+K\log p+(2n-K)\log(1-p). $$

Differentiate with respect to \(p\). The likelihood equation is the equation obtained by setting this derivative, often called the score, equal to zero:

$$ \frac{d\ell(p)}{dp}=\frac{K}{p}-\frac{2n-K}{1-p}=0. $$

Multiplying by \(p(1-p)\), which is positive for an interior \(p\), gives \(K(1-p)=p(2n-K)\). Expanding both sides and cancelling \(-Kp\) yields \(K=2np\). Therefore the solution of the likelihood equation is

$$ \hat{p}=\frac{K}{2n}=\frac{2n_{AA}+n_{Aa}}{2n}. $$

The estimate is the observed fraction of all allele copies that are \(A\). An \(AA\) individual contributes two copies to the numerator, an \(Aa\) individual contributes one, and an \(aa\) individual contributes none. The denominator counts both copies from every diploid individual.

Maximum-likelihood result: Under the independent-sampling Hardy–Weinberg model, if \(0<K<2n\), the MLE of the \(A\)-allele frequency is \(\hat{p}=(2n_{AA}+n_{Aa})/(2n)\). The corresponding estimate of the \(a\)-allele frequency is \(\hat{q}=1-\hat{p}=(n_{Aa}+2n_{aa})/(2n)\).

Why the Likelihood-Equation Solution Is a Maximum

A likelihood equation identifies a stationary point, but that alone does not prove the point is a maximum. For \(0<K<2n\), the second derivative of the log-likelihood is

$$ \frac{d^2\ell(p)}{dp^2} =-\frac{K}{p^2}-\frac{2n-K}{(1-p)^2}<0 \qquad (0<p<1). $$

Both terms are negative when \(K\) and \(2n-K\) are positive. The log-likelihood is therefore strictly concave over the interior of the parameter space, so its stationary point is the unique interior maximum. This verifies the likelihood-equation result.

If \(K=0\), every observed allele copy is \(a\), and the likelihood is proportional to \((1-p)^{2n}\). Its maximum on \(0\leq p\leq1\) occurs at \(p=0\). If \(K=2n\), every observed copy is \(A\), and the likelihood is proportional to \(p^{2n}\), maximized at \(p=1\). Thus the same formula gives the MLE at the boundaries as well. In these cases the maximum is at the edge of the parameter space, rather than at an interior solution of the likelihood equation.

Worked Example: Solving and Checking the Likelihood Equation

Consider a hypothetical sample of 60 diploid individuals with \(n_{AA}=18\), \(n_{Aa}=27\), and \(n_{aa}=15\). The counts sum to 60, and the number of \(A\) copies is

$$ K=2(18)+27=63, \qquad 2n=120. $$

The log-likelihood, apart from a constant, is \(\ell(p)=63\log p+57\log(1-p)\). Its derivative is

$$ \frac{d\ell(p)}{dp}=\frac{63}{p}-\frac{57}{1-p}. $$

Setting this equal to zero gives \(63(1-p)=57p\), so \(63=120p\) and \(\hat{p}=63/120=0.525\). Substituting the estimate back into the derivative verifies the likelihood equation:

$$ \frac{63}{0.525}-\frac{57}{0.475} =120-120=0. $$

The second derivative is negative throughout the interior because both counts of allele copies are positive. The estimate is therefore the unique maximum, not merely a stationary point. In this hypothetical sample, the estimated population frequency of allele \(A\) under the model is 0.525, or 52.5%.

Worked Example: Counting Heterozygotes Once

Suppose, hypothetically, 50 individuals have genotypes \(n_{AA}=7\), \(n_{Aa}=26\), and \(n_{aa}=17\). There are \(2(7)+26=40\) copies of \(A\) among \(2(50)=100\) allele copies. Hence

$$ \hat{p}=\frac{2(7)+26}{2(50)} =\frac{40}{100}=0.400. $$

The complementary estimate is \(\hat{q}=1-0.400=0.600\), which also follows by counting \(a\) copies: \([26+2(17)]/100=60/100=0.600\). The genotype counts have been used consistently: each homozygote contributes two copies of its allele, and each heterozygote contributes one copy of each allele. In this hypothetical sample, the model-based estimate of the \(A\)-allele frequency is 0.400.

Worked Example: A Boundary Estimate

Suppose a hypothetical sample of 12 individuals contains 12 \(aa\) genotypes and no \(AA\) or \(Aa\) genotypes. Then \(n=12\) and \(K=2(0)+0=0\). The allele-count formula gives

$$ \hat{p}=\frac{0}{2(12)}=0. $$

To check the maximum directly, the likelihood as a function of \(p\) is proportional to \((1-p)^{24}\). For \(0\leq p\leq1\), this quantity is at most 1 and reaches 1 at \(p=0\); it decreases as \(p\) increases. Thus the MLE is the boundary value \(p=0\). The data contain no observed \(A\) copies, so the estimated \(A\)-allele frequency is zero under this model. This estimate does not prove that the population frequency is exactly zero; it is the likelihood-maximizing value for these observed data under the assumed model.

Why the Result Matters—and What It Does Not Say

The simple allele-count expression is useful because it turns genotype counts into an estimate of a population parameter while respecting diploidy. It also provides a direct check on likelihood calculations: if the counts are entered correctly, the MLE must agree with the fraction of observed allele copies. Under the specified Hardy–Weinberg model, the likelihood’s dependence on \(p\) reduces to \(p^K(1-p)^{2n-K}\), which explains why the same proportion emerges from the likelihood equation.

That algebraic form should not be taken as a claim that the two alleles within each individual were separately sampled observations in every possible genetic model. The derivation uses the Hardy–Weinberg genotype probabilities and independent sampling of individuals. If those assumptions fail, the displayed likelihood may not describe the data, and the estimate need not have the intended interpretation.

This MLE is a point estimate. It does not, by itself, quantify sampling uncertainty or test Hardy–Weinberg equilibrium. It estimates \(p\) conditional on the likelihood model used here; whether the genotype counts fit that model is a separate question.

Common Mistakes

  • Counting a heterozygote incorrectly. An \(Aa\) individual contributes one \(A\) copy, not two. The numerator is \(2n_{AA}+n_{Aa}\), not \(2n_{AA}+2n_{Aa}\).
  • Using \(n\) as the denominator. There are two allele copies per diploid individual, so the denominator is \(2n\), not \(n\).
  • Assuming any likelihood-equation solution is automatically a maximum. Check curvature or compare the likelihood over the parameter space. Here the second derivative proves an interior solution is a maximum, and the all-one-allele cases are checked at the boundaries.
  • Interpreting the estimate as proof of the assumptions. The likelihood gives an estimate conditional on Hardy–Weinberg proportions and the sampling assumptions; it does not demonstrate that those assumptions hold.
Key takeaway: With \(n\) diploid genotype calls at a biallelic locus, the Hardy–Weinberg likelihood yields \(\hat{p}=(2n_{AA}+n_{Aa})/(2n)\). The likelihood equation gives this allele-copy proportion, and concavity or a boundary check verifies that it is the maximum.

Check Your Understanding

Use the genotype-count likelihood and allele-copy reasoning to answer the following.

  1. For counts \(n_{AA}=12\), \(n_{Aa}=30\), and \(n_{aa}=18\), calculate \(\hat{p}\) and \(\hat{q}\).
  2. State the Hardy–Weinberg genotype probabilities in terms of \(p\) and \(q\), and identify the assumptions needed to use them in this likelihood.
  3. Explain why the heterozygote count contributes once, rather than twice, to the numerator for \(\hat{p}\).
  4. What does the negative second derivative of the log-likelihood establish when \(0<K<2n\)?
  5. If all observed genotypes are \(AA\), what is the MLE of \(p\), and why is this a boundary case?
Clinical Biostats