Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Allele counts, MAF estimation, and genotyping error

We ask one question. What fraction of the sampled chromosome copies carries the alternate allele? When this frequency is at most 1/21/2, it is the minor allele frequency (MAF).

Start from first principles

  • Each diploid person contributes two alleles.

  • A true genotype dosage gi∈{0,1,2}g_i\in\{0,1,2\} counts alternate alleles.

  • Sequencing is a measurement process. It produces reads and genotype calls, not direct access to the true genotype.

  • A probabilistic model connects allele frequency, true genotype, and the observed measurement.

This worked example connects allele counts, genotype dosage, HWE, and genotyping error with probabilistic models, likelihood, MLE, latent genotypes, and EM.

1. Count alleles from exact genotype calls

Code an exact genotype call as gi∈{0,1,2}g_i\in\{0,1,2\}, the number of alternate alleles carried by person ii. With nn diploid people, the sample contains 2n2n chromosome copies. Therefore

f^count=∑i=1ngi2n.\widehat f_{\text{count}}=\frac{\sum_{i=1}^n g_i}{2n}.

This calculation treats each measured genotype call as the true genotype. The error model below allows the call to differ from the true genotype.

Loading...

2. The allele count is also the HWE MLE

Under Hardy--Weinberg equilibrium (HWE), let ff be the alternate-allele frequency. HWE gives a probabilistic model for the true genotype GiG_i:

P(Gi=0∣f)=(1−f)2,P(Gi=1∣f)=2f(1−f),P(Gi=2∣f)=f2.P(G_i=0\mid f)=(1-f)^2,\qquad P(G_i=1\mid f)=2f(1-f),\qquad P(G_i=2\mid f)=f^2.

For genotype calls treated as exact, the likelihood is

L(f)=∏iP(Gi=gi∣f).L(f)=\prod_i P(G_i=g_i\mid f).

If the data contain n0,n1,n2n_0,n_1,n_2 people with genotypes 0, 1, and 2, then

L(f)∝fn1+2n2(1−f)2n0+n1.L(f)\propto f^{n_1+2n_2}(1-f)^{2n_0+n_1}.

Maximizing this likelihood gives f^=(n1+2n2)/(2n)\widehat f=(n_1+2n_2)/(2n). The allele count is therefore the MLE when the genotype calls are exact.

Loading...
Plot with title “The MLE is the allele-count estimate”

Insight behind the approach

HWE gives a probabilistic model for the true genotype given allele frequency. Changing ff changes the expected genotype frequencies along the HWE curve. Genotyping error changes the observed calls in a different pattern. Likelihood uses these patterns to estimate both ff and the error rate.

3. Genotyping error separates genotype from measurement

The true genotype GiG_i is a biological state. The observed genotype call DiD_i is produced by measurement and genotype calling. The model connects them in two steps.

f⟶Gi⟶Di.f \longrightarrow G_i \longrightarrow D_i.
  1. The HWE model gives the probability of GiG_i from ff.

  2. The measurement model gives the probability of DiD_i from GiG_i. With probability ϵ\epsilon, the calling process makes an error event and assigns one of the three calls at random. Thus

P(Di=d∣Gi=g,ϵ)={1−2ϵ/3,d=g,ϵ/3,d≠g.P(D_i=d\mid G_i=g,\epsilon)= \begin{cases} 1-2\epsilon/3, & d=g,\\ \epsilon/3, & d\ne g. \end{cases}

This simple error model keeps the calculation visible. A sequencing analysis can use read-level genotype likelihoods in place of this call-error matrix.

Loading...
True MAF: 0.300
Direct count of observed calls: 0.313
Simulated error events: 494 of 10000

HWE gives a diagnostic for genotype measurement error

Under HWE, the three true genotype probabilities are determined by one parameter ff.

p(f)=((1−f)2,  2f(1−f),  f2).\mathbf p(f)=\left((1-f)^2,\;2f(1-f),\;f^2\right).

As ff changes, these probabilities trace a one-dimensional HWE curve. Under the simple error model used here, the observed-call probability is

qd(f,ϵ)=(1−ϵ)pd(f)+ϵ3.q_d(f,\epsilon)=(1-\epsilon)p_d(f)+\frac{\epsilon}{3}.

Changing ff moves the genotype probabilities along the HWE curve. Increasing ϵ\epsilon pulls the observed-call probabilities toward (1/3,1/3,1/3)(1/3,1/3,1/3), which generally moves them away from the HWE curve. The two parameters therefore leave different patterns in the three genotype counts.

A practical diagnostic fits HWE using the allele-count estimate and compares the observed and expected genotype counts. Departure from HWE signals model mismatch. Genotyping error is one possible explanation. Population structure, inbreeding, and selection can also produce departure from HWE.

Loading...
HWE diagnostic. X^2 = 8.68, df = 1, p = 0.00322

In this simulation, the observed genotype calls depart from the fitted HWE expectation. The error-aware model adds a measurement process. It treats the true genotype as latent and sums over its three possible values. The simulated true genotypes are retained only to check the answer.

L(f,ϵ)=∏i=1n∑g=02P(Di=di∣Gi=g,ϵ)P(Gi=g∣f).L(f,\epsilon)=\prod_{i=1}^n\sum_{g=0}^2 P(D_i=d_i\mid G_i=g,\epsilon)P(G_i=g\mid f).

EM applies this calculation to every person through repeated soft counting.

E-step infers each hidden genotype

wig=P(Gi=g∣Di=di,f,ϵ)∝P(Di=di∣Gi=g,ϵ)P(Gi=g∣f).w_{ig}=P(G_i=g\mid D_i=d_i,f,\epsilon) \propto P(D_i=d_i\mid G_i=g,\epsilon)P(G_i=g\mid f).

M-step recounts expected alleles and errors

fnew=12n∑i(wi1+2wi2),ϵnew=32n∑i[1−wi,di].f^{\text{new}}=\frac{1}{2n}\sum_i(w_{i1}+2w_{i2}),\qquad \epsilon^{\text{new}}=\frac{3}{2n}\sum_i[1-w_{i,d_i}].

The key idea is simple. Replace each hidden genotype by posterior weights, then count with those weights.

Loading...
Loading...
Loading...
Plot with title “EM soft-counts the hidden genotypes”

4. Check the answer two ways

Direct optimization of the same observed-data likelihood should agree with EM. The observed-data log-likelihood should also increase or remain unchanged at every EM iteration.

Loading...
Checks passed: EM agrees with direct optimization, and likelihood is monotone.

What to remember

  1. Concept and intuition. Allele frequency counts chromosome copies. Sequencing provides measurements from which genotypes are inferred.

  2. Insight behind the approach. HWE restricts the three genotype frequencies to a one-parameter curve. Genotyping error generally moves the observed-call frequencies away from that curve. These different patterns let likelihood estimate both ff and ϵ\epsilon.

  3. Worked example. An HWE comparison detects model mismatch. The error-aware model then uses EM to recover the MAF and error rate, with direct likelihood optimization as a check.

The error-aware estimate is useful when the error model describes the measurement process.

Source record and further detail

  • The genotyping-error simulation uses seed 581, n=10,000n=10{,}000, true MAF 0.30, and true error rate 0.05. The result is checked by direct likelihood optimization.

  • Pritchard, An Owner’s Guide to the Human Genome, Chapter 1.3, especially allele frequency, genotype coding, and HWE.