← Notebook
Method · December 5, 2026 · 19 min read · 1 view

Statistical fine-mapping, post 1.2: genotype QC, which variants and people to remove, and why

How genotyping goes wrong, and the handful of checks that catch it: call rates, the sex check, heterozygosity, Hardy-Weinberg equilibrium and batch effects. We plant every problem ourselves, so we can score each check: what it catches, what it misses, and what it throws away by mistake.

Part of Statistical fine-mapping, post 4 of 20 · series map · ← post 1.1

Code Languages License

Contents

A pile of exam papers

Imagine you are marking a few hundred exam papers, and you want to know which questions the class found hard. Before you count anything, you’d throw a few papers aside. The student who left half the answers blank. The paper with two kinds of handwriting on it. The one with a boy’s name on it that the class list says belongs to a girl. And you’d look twice at the questions, too: if question 17 was misprinted, everybody’s answer to it is noise, and it would be silly to conclude that the class is bad at question 17.

Genotype quality control (QC) is exactly that, with people as the papers and variants as the questions. Some people’s DNA was poor, or got mixed with someone else’s, or carries the wrong label. Some variants were badly measured. Each problem leaves a fingerprint in the data, and a handful of simple checks find almost all of them.

In post 1.1 we checked that our files belong to the right people. Now we check that the genotypes themselves are worth trusting. And because our playground’s genotypes are already clean, we’ll do something you can’t do with real data: make a mess on purpose, clean it up, and score every check against the answer key.

How a chip reads your DNA

Most large genetic studies don’t sequence anybody. They use a genotyping array, or chip: a glass slide with probes for a few hundred thousand chosen variants. Your DNA is washed over it, and at each probe two dyes light up, one for each allele. A machine measures the two brightnesses and plots everyone in the study as a dot. If all goes well, the dots fall into three tidy clouds: lots of the first dye (two copies of allele A), lots of the second (two copies of B), or some of each (one of each, a heterozygote). A clustering program then draws a boundary around each cloud and calls everybody’s genotype.

This is an illustration, not real intensity data, but it shows the three ways a probe can behave. On the left, a good probe: three clouds, easy calls. In the middle, a poor probe: the clouds smear into each other, and dots that fall between them get no call at all (the grey crosses), while some are called wrong. On the right, the nastiest kind: a probe that works perfectly in one batch of plates but drifts in another, so that batch’s heterozygotes (circled) slide into the next cloud and are called as homozygotes. Nothing about this probe looks wrong if you only see one batch.

Everything in this post is about catching the consequences of pictures like these, when all you have is the calls.

Our messy lab

Here’s the setup. I took our 443 people and made them a pretend chip: 250,000 variants picked at random from their genomes, plus 8,000 on chromosome X (we’ll need those for the sex check). Then a “messy lab” script spoiled the data in the ways real labs do:

ProblemPlanted inWhat it does
Poor DNA5 people2.5% to 10% of their calls fail
Contamination3 peopletheir tube also holds 8% to 15% of someone else’s DNA
Sample-sheet error2 peoplesex recorded the wrong way round; the DNA is fine
Poor probes1.2% of variants3% to 25% of calls fail
Heterozygote dropout0.4% of variantsa quarter to most heterozygotes called as homozygotes
A bad batch0.3% of variantsthe drifting probe above, in the batch that holds all the cases
Backgroundeveryone0.2% of all calls fail at random

That last-but-one row is a design many real studies have stumbled into: the cases come from a clinic, arrive later, and are genotyped on their own plates. Keep an eye on it.

Every check below follows the same order most published protocols use 1,2: first the variants that are obviously broken, then the people, then the variants again more carefully.

Who answered too few questions? Call rates

The simplest check is how often a call failed. A person’s call rate is the share of variants that gave them a genotype; a variant’s call rate is the share of people it gave a genotype. (Its mirror image, the share that failed, is called missingness.)

On the left, every person, from worst to best. Almost everyone sits at 99.8%, which is about what a good chip gives. Five people sit far below, and they are exactly our five poor DNA samples. On the right, every variant (note the log scale): a huge spike near 100%, and a long orange tail of the poor probes.

Two thresholds, two passes. First I drop variants with a call rate below 95%, a loose cut, so that a few hundred terrible probes don’t drag down everybody’s personal call rate. Then I drop people below 98%. Then variants again, now at 98%. In our data the first pass removed 2,625 variants, every one of them planted; the people step removed all 5 poor DNA samples and nobody else; and the second variant pass took 584 more bad probes. Not one innocent person or variant was lost.

Why not just drop anything with a single failed call? Because a failed call is usually innocent: the 0.2% background rate means every person and every variant has a few. The thresholds are set where the bulk of the good data ends.

Does the paper match the name? The sex check

Men have one X chromosome, women have two. So a man can’t be heterozygous at a variant on X (outside the small regions X shares with Y): he has only one copy. A woman can be. That gives a check on the sample sheet that needs nothing but the genotypes 11.

For each person I compare how many X variants are heterozygous with how many we’d expect from the allele frequencies. The summary is an inbreeding coefficient F for chromosome X: about 1 when there are no heterozygotes at all (a man), and about 0 when there are as many as expected (a woman). The usual rule calls a person female when F is below 0.2 and male above 0.8.

Look at the right panel. Recorded women cluster around 0, recorded men in a tight line at 1. Two “women” sit up at 1 with the men: no heterozygous X variants at all. Those are our two sample-sheet errors, two men whose sex was written down wrong. The check doesn’t tell you what went wrong (a swapped label, a typo, or rarely a person whose sex chromosomes are unusual), only that the sheet and the DNA disagree, and that someone has to look before the person stays in.

Notice three more dots that look odd without failing the rule. One man sits at 0.75, a little below the others: he has a few heterozygous calls on X that a man can’t have. And two women sit well below zero, more heterozygous than a woman should be. Hold that thought.

Two people in one tube: heterozygosity

What happens when a tube holds DNA from two people? Wherever the two differ, the chip sees both alleles and calls a heterozygote. So a contaminated sample has too many heterozygous calls. (That is what the three odd dots in the sex check were: some of their X heterozygotes came from somebody else.) Too few heterozygous calls can mean the opposite: parents who are related, or a population that went through a bottleneck.

So the next check is each person’s heterozygosity: the share of their calls that are heterozygous. The usual rule removes anyone more than three standard deviations from the mean. The left panel of the figure above shows it, and it shows the catch at once: Europeans (blue) and Yoruba (green) are two separate clouds. African populations carry more genetic diversity than any others, so the Yoruba are heterozygous at about 20% of these variants, the Europeans at about 16%.

If you apply one rule to everybody, the dashed lines, the mean sits between the two clouds and the spread is huge. A European with 15% of someone else’s DNA in her tube sits at 22.1%, a hair inside the pooled line, and looks perfectly normal, because plenty of honest Yoruba are near 22%. The one with 8% contamination, at 19%, is nowhere near it. That pooled rule caught only 1 of our 3 contaminated samples, the Yoruba one at 28%. Applied within each ancestry, the shaded bands, it caught all 3, and nobody else.

Heterozygosity can also be too low: in children of related parents, or in populations that went through a bottleneck, long stretches of DNA are identical on both copies (posts 2.4 and 2.5 are about exactly that). Nobody in our cohort fell below the band, but when somebody does, it is a reason to look, not a verdict: their genotypes may be perfectly good.

Is the question broken? Hardy-Weinberg

Now the variants again, with a subtler check. If people pair up at random with respect to a variant, its genotype counts follow a simple rule called Hardy-Weinberg equilibrium: with allele frequency p, a share p2p^2 of people have two copies, 2p(1−p)2p(1-p) have one, and (1−p)2(1-p)^2 have none. Real populations follow it remarkably closely. A probe that miscalls heterozygotes as homozygotes breaks it: too few heterozygotes, too many homozygotes. An exact test 4 gives each variant a p-value for how far its counts are from the rule.

A plot of all those p-values against what we’d expect by chance (a QQ plot) shows the problem clearly:

In the middle, European controls: the grey variants hug the dotted line of “nothing going on”, and the orange planted probes shoot off the top. That is the picture you want.

On the left is what happens if you test everyone at once. The grey variants peel away from the line, hundreds of innocent variants with tiny p-values. Nothing is wrong with them. Mixing two populations with different allele frequencies always produces too few heterozygotes compared with the pooled frequency, an old result called the Wahlund effect 10. Testing everyone together flagged 2,033 variants, and 1,327 of them were innocent. Testing within each ancestry flagged 409, and only 7 were innocent (across a quarter of a million tests, a handful of false alarms is to be expected).

Why controls? Because in cases, a variant that truly causes the disease can be out of equilibrium for a real reason: cases are selected for carrying risk alleles. So cases get only a very lax test, p<10−10p < 10^{-10}, which catches the grossly broken probes. You can see why on the right: the cases’ line is shorter (fewer people, less power), and only the worst probes stand out.

The batch that holds the cases

Last, the problem I warned you about. Our bad-batch probes fail, or miscall heterozygotes, only on the plates that hold the cases. Two checks look for it. The case-only Hardy-Weinberg test, above. And a test of whether a variant’s call rate differs between cases and controls (Fisher’s exact test), because a probe that fails more in one batch leaves more holes in that group. Together with the call-rate cuts, they caught 380 of the 771 bad-batch probes. (The Fisher test itself caught none on its own: every probe it would have flagged had already gone at the call-rate cut.)

That leaves 391, about half. They are probes where the batch shifted a share of heterozygotes without failing many calls, and where the shift was too small to break Hardy-Weinberg in a few hundred cases. They pass every check, and each one carries a small, systematic difference between cases and controls, which is precisely what an association test is built to find. We’ll see the consequence in a moment.

The scorecard

Because we planted everything, we can grade the whole pipeline:

StepCheckRemovedPlantedInnocent
1variant call rate below 95%2,625 variants2,6250
2person call rate below 98%5 people50
3variant call rate below 98%584 variants5840
4sex check on chromosome X2 people20
5heterozygosity, within ancestry3 people30
6Hardy-Weinberg in controls, p<10−6p < 10^{-6}409 variants4027
7Hardy-Weinberg in cases, p<10−10p < 10^{-10}25 variants250
8call rate differs between cases and controls0 variants00
9minor allele frequency below 1%20,727 variants18220,545

Every planted person was caught: all 5 poor samples, all 3 contaminated ones, both sheet errors, and not one innocent person was lost. All but 3 of the 2,884 poor probes were caught. Of the probes that miscall heterozygotes, 557 of 992 were caught; the rest are mostly rare variants, where there are only a handful of heterozygotes to lose, too few for the Hardy-Weinberg test to notice.

The last row looks alarming and isn’t. A variant whose rarer allele is below 1% has, in 450 people, a handful of carriers at most. It is not wrong, just nearly useless for association, and rare variants are where genotype calling is least reliable, so most studies drop them. They are the only big group of innocents, and losing them costs almost nothing.

After QC we keep 433 of 443 people and 233,630 of 258,000 variants.

Why it matters: one scan, before and after

Here’s the payoff. The same case-control association scan, disease against every variant, adjusted for sex and ancestry, on the chip as it came from the lab and again after QC:

Before QC, the scan finds 40 variants with p<10−5p < 10^{-5}, and 10 cross the genome-wide line of 5×10−85 \times 10^{-8}, on eight different chromosomes. Every one of the 40 is a bad-batch probe: not biology, but plates. Notice how ordinary the top panel looks otherwise. The bulk of the scan is flat (the genomic inflation factor, which post 2.1 explains, is 1.00), so nothing on the surface says “artefact”. If you were writing this up, you would have ten genome-wide “discoveries”.

After QC, 37 of the 40 are gone. And three survive, one of them above the genome-wide line at p=1.7×10−8p = 1.7 \times 10^{-8}. They are bad-batch probes that passed every check. This is the real lesson of the post: QC cannot rescue a confounded design. When cases and controls are genotyped separately, every small technical difference between the batches turns into a difference between cases and controls. A study famously had to retract a headline result for this reason: the cases and controls had been genotyped partly on different chip versions, and the strongest hits turned out to be technical 8. The fix is at the bench, not in the software: mix cases and controls on every plate. When that’s not possible, look hard at every hit’s cluster plot, and see whether it replicates on another platform before you believe it.

A short checklist

  1. Call rates. Drop clearly broken variants first (below 95%), then people below 97% to 99%, then variants below 98% to 99%.
  2. Sex. Compare chromosome X heterozygosity (F) with the sample sheet; look at every mismatch.
  3. Heterozygosity. Flag people more than 3 SD from the mean, within each ancestry. Too high suggests contamination; too low, relatedness of the parents or a bottleneck.
  4. Hardy-Weinberg. Test controls within each ancestry, at about 10−610^{-6}; test cases only for gross failures.
  5. Batches. Test whether call rates differ between cases and controls, and between batches.
  6. Allele frequency. Drop variants too rare for your sample size.
  7. Design. Put cases and controls on the same plates. Nothing above can fully undo it if you don’t.

Two things this post leaves for the next one: relatives (two people who share a lot of DNA count twice), and ancestry outliers. Both are about how people relate to each other, the subject of post 1.3.

Try it yourself

The whole post runs in a few minutes on the playground from post 0. The first run also fetches chromosome X (about 1 GB, once):

conda activate statgen-r
bash posts/1.2-genotype-qc/run_all.sh data results/post-1.2               # R
TRACK=python bash posts/1.2-genotype-qc/run_all.sh data results/post-1.2  # Python

and bash posts/1.2-genotype-qc/check.sh data runs both and checks that R and Python give the same messy chip, byte for byte, and the same numbers. On a shared cluster, use a compute node.

The heart of QC is a few lines once the genotypes are in a matrix. In R, with the messy chip loaded as variants × people (NA for a failed call):

source("lib/statgen.R")
g <- read_bed("results/post-1.2/chip/raw")       # counts of one allele: 0, 1, 2 or NA
fam <- data.table::fread("results/post-1.2/chip/raw.fam", header = FALSE)
called <- !is.na(g)

person_call <- colMeans(called)                     # call rate of each person
variant_call <- rowMeans(called)                    # call rate of each variant
het <- colSums(g == 1, na.rm = TRUE) / colSums(called)   # heterozygosity of each person

fam$V2[person_call < 0.98]                          # who answered too few questions?
summary(het)

And in Python:

import sys
import numpy as np
sys.path.insert(0, "lib")
import statgen as sg

g = sg.read_bed("results/post-1.2/chip/raw")      # counts of one allele: 0, 1, 2 or NaN
called = ~np.isnan(g)
person_call = called.mean(0)
variant_call = called.mean(1)
het = (g == 1).sum(0) / called.sum(0)
print((person_call < 0.98).sum(), "people below 98%")

For a real study you’d let PLINK do the work: --missing for call rates, --het for heterozygosity, --check-sex for the sex check, --hardy for Hardy-Weinberg, and --geno, --mind, --hwe and --maf to filter 7. Our scripts do the same arithmetic in the open, so you can see each number come out.

A few things to try:

  1. In 04_qc, set HET_SD <- 2 (or HET_SD = 2) and count how many innocent people you lose. Then set it to 4 and see which contaminated sample slips through.
  2. Replace the within-ancestry Hardy-Weinberg test with the pooled one and rerun step 5. How many good variants do you throw away, and does the scan change?
  3. In 03_messy_lab, put half the cases in each batch instead of all of them in batch B (the batch <- line), rerun steps 3 to 5, and look at the Manhattan plot.
For the curious: the checks in a little more detail

Chromosome X F. For a person with nn called X variants, the observed number of homozygous calls OO is compared with the number expected from allele frequencies pjp_j, E=∑j(1−2pj(1−pj))E = \sum_j \big(1 - 2p_j(1 - p_j)\big), as F=(O−E)/(n−E)F = (O - E)/(n - E). That equals one minus the ratio of observed to expected heterozygotes, which is how our code computes it. We take pjp_j from the person’s own ancestry group, for the same Wahlund reason as the Hardy-Weinberg test. PLINK’s --check-sex uses the same F with the same 0.2 and 0.8 defaults.

Why contamination raises heterozygosity. Where the two people differ at a variant, the mixture shows both alleles. With 15% of a second person’s DNA, the minor dye is weak but often enough to tip the call. Our messy lab models that simply: wherever the two differ, a homozygous call becomes heterozygous with a probability of three times the contamination fraction. Dedicated tools estimate the fraction from the intensities themselves 12.

The exact Hardy-Weinberg test. With few people or rare alleles, the classic chi-squared test is unreliable. The exact test of Wigginton and colleagues 4 counts the probability of every possible number of heterozygotes given the allele counts, and sums those as or less likely than the one observed. That is what plink2 --hardy reports.

Differential missingness. For each variant, a 2 × 2 table of failed and successful calls in cases and controls, and Fisher’s exact test. Clayton and colleagues showed that even subtle differences in call quality between cases and controls inflate the whole scan 5.

What we skipped. Real pipelines also check for duplicated samples, relatives (post 1.3), ancestry outliers (post 1.3), Mendelian errors in families, and look at the cluster plots of every variant they report 6,9. And with imputation (post R) come checks of imputation quality.

Concepts in this post

  • Genotyping array: a chip that measures a few hundred thousand chosen variants at once with two dyes.
  • Genotype calling: turning two dye brightnesses into AA, AB or BB by clustering everyone in the study.
  • Call rate and missingness: the share of genotypes that were (or were not) called, for a person or a variant.
  • Sex check: comparing chromosome X heterozygosity with the recorded sex.
  • Heterozygosity: the share of a person’s calls that are heterozygous; too high hints at contamination.
  • Hardy-Weinberg equilibrium: the genotype counts expected from allele frequencies under random mating.
  • Wahlund effect: too few heterozygotes when two populations are pooled.
  • Batch effect: a technical difference between groups processed separately.
  • Minor allele frequency: the frequency of a variant’s rarer allele.

References

  1. Anderson CA, Pettersson FH, Clarke GM, Cardon LR, Morris AP, Zondervan KT. Data quality control in genetic case-control association studies. Nature Protocols 5, 1564–1573 (2010). doi:10.1038/nprot.2010.116
  2. Marees AT et al. A tutorial on conducting genome-wide association studies: quality control and statistical analysis. International Journal of Methods in Psychiatric Research 27, e1608 (2018). doi:10.1002/mpr.1608
  3. Koenig Z et al. A harmonized public resource of deeply sequenced diverse human genomes. Genome Research 34, 796–809 (2024). doi:10.1101/gr.278378.123
  4. Wigginton JE, Cutler DJ, Abecasis GR. A note on exact tests of Hardy-Weinberg equilibrium. American Journal of Human Genetics 76, 887–893 (2005). doi:10.1086/429864
  5. Clayton DG et al. Population structure, differential bias and genomic control in a large-scale, case-control association study. Nature Genetics 37, 1243–1246 (2005). doi:10.1038/ng1653
  6. Laurie CC et al. Quality control and quality assurance in genotypic data for genome-wide association studies. Genetic Epidemiology 34, 591–602 (2010). doi:10.1002/gepi.20516
  7. Chang CC et al. Second-generation PLINK: rising to the challenge of larger and richer datasets. GigaScience 4, 7 (2015). doi:10.1186/s13742-015-0047-8
  8. Sebastiani P et al. Genetic signatures of exceptional longevity in humans. Science (2010), retracted 2011. doi:10.1126/science.1190532
  9. Turner S et al. Quality control procedures for genome-wide association studies. Current Protocols in Human Genetics 68, 1.19.1–1.19.18 (2011). doi:10.1002/0471142905.hg0119s68
  10. Wahlund S. Zusammensetzung von Populationen und Korrelationserscheinungen vom Standpunkt der Vererbungslehre aus betrachtet. Hereditas 11, 65–106 (1928). doi:10.1111/j.1601-5223.1928.tb02483.x
  11. Purcell S et al. PLINK: a tool set for whole-genome association and population-based linkage analyses. American Journal of Human Genetics 81, 559–575 (2007). doi:10.1086/519795
  12. Jun G et al. Detecting and estimating contamination of human DNA samples in sequencing and array-based genotype data. American Journal of Human Genetics 91, 839–848 (2012). doi:10.1016/j.ajhg.2012.09.004

Every figure was made for this post with the code in posts/1.2-genotype-qc/. The genotypes are from the HGDP + 1000 Genomes panel 3; the problems in them were planted by the messy-lab script.

fine-mappingquality controlgenotyping arraysHardy-WeinbergPLINKstatistical geneticstutorial