Algorithm Search⌘K

Problemcore

Variant calling

Also called SNP calling, small variant calling.

Given reads aligned to a reference, find the positions where a sample differs from it and assign a genotype with a confidence.

Variant calling takes the reads of a sample, mapped to a reference genome, and finds where the sample differs from the reference: single-nucleotide variants (SNVs) and short insertions and deletions (indels). For each variant it gives the genotype of the sample, such as heterozygous or homozygous, and how sure the call is. The reads have errors and some are mapped to the wrong place, so the problem is statistical: a mismatch in one read is weak evidence, and the caller must weigh many reads and their qualities. The output is usually a VCF file.

In plain words

You have many short pieces of text copied from one book, with some typing mistakes, and you know where in a reference copy of the book each piece belongs. You want to find the places where this book really differs from the reference.

At each place, look at all the pieces that cover it. If one piece in thirty has another letter, it is likely a mistake. If about half of them have the other letter, this book has two versions there, one like the reference and one not. If almost all have it, both versions differ. The task is to make that choice for every place, and to say how sure you are.

Definition

Input.

  • A reference genome RR, with positions 1 to GG, as in VCF.
  • Reads from one or more samples, mapped to RR, with base qualities and mapping qualities, usually in a sorted BAM file.
  • The ploidy of each sample, which is 2 for human autosomes.

Output. A list of variant records. Each record has a position, a reference allele and one or more alternate alleles, a site quality, and for each sample a genotype and a genotype quality.

The statistical form. At a candidate site with alleles rr and aa, a diploid sample has a genotype g∈{0,1,2}g \in \{0, 1, 2\}, the number of copies of aa. With the data DD of the reads that cover the site, the caller reports the posterior

P(g∣D)=P(D∣g) P(g)∑g′P(D∣g′) P(g′),P(g \mid D) = \frac{P(D \mid g)\, P(g)}{\sum_{g'} P(D \mid g')\, P(g')},

where P(D∣g)P(D \mid g) is the genotype likelihood and P(g)P(g) is a prior. SNP discovery asks whether the site is variant in any sample, with the site quality −10log⁡10P(no sample carries a∣D)-10 \log_{10} P(\text{no sample carries } a \mid D); genotype calling asks for each sample's gg. Nielsen et al. (2011) stress that the two are distinct.

Small variants. The word "small" separates SNVs and indels of up to a few tens of bases from structural variants. A size of 50 bases is a common boundary in the literature, but it is a convention, not a rule.

Variants

  • Germline calling of one sample. One sample at a time, with a prior from the expected rate of differences, as in Bayesian genotype calling.
  • Joint calling of many samples. All samples share one site and one allele frequency, so weak evidence in many samples adds up. The prior can be a Hardy-Weinberg prior with an allele frequency estimated by expectation maximization (Li, 2011).
  • Low-coverage population calling. At 2x to 6x per sample, single-sample genotypes are poor; the genotype likelihoods are passed on to imputation or to estimates of the allele frequency and the site frequency spectrum.
  • Haplotype-based calling. Callers such as GATK HaplotypeCaller and FreeBayes look at a window and score whole candidate haplotypes, which handles indels and nearby variants better than one site at a time; see haplotype-based variant calling.
  • Somatic calling. In tumors, a variant can be in a small share of the cells, so the expected allele fractions are not 0, 1/2 and 1; see somatic variant calling.
  • Larger events. Structural variants and copy number changes need other evidence, such as read pairs, split reads and depth; see structural variant detection and copy number segmentation.
  • Other ploidies and pools. Polyploid samples and pools of many individuals change the possible allele fractions, and with them the likelihood.

Examples

All examples use the reference allele A, the alternate allele G, base qualities on the Phred scale and the prior of Bayesian genotype calling with θ=0.001\theta = 0.001.

  • A clear heterozygote. Six reads: A at qualities 30, 30, 20 and G at 30, 20, 10. The posterior of A/G is 0.997462, and the site quality is 25.96.
  • One error in ten. One G and nine A, all Q30. The call is A/A; the posterior of A/G is only 0.002932, because the prior and the nine A reads outweigh one base that has a 1 in 1000 chance of an error.
  • Low depth. Two G reads, both Q30. The posteriors of A/A, A/G and G/G are 0.000148, 0.333432 and 0.666420. The site is clearly variant (site quality 38.3), but the genotype G/G has a genotype quality of only 4.77, since a heterozygote shows G on both reads with probability 1/41/4.
  • An indel in a repeat. On a reference that starts GTCACACAGT, a sample with GTCACAGT lacks one copy of CA. The deletion can be written at several positions; the normalized record is POS 2, REF TCA, ALT T.

Known algorithms

method approach source
Bayesian genotype calling per-site posterior from base qualities and a prior, as in Maq, samtools and bcftools, and GATK UnifiedGenotyper Li, Ruan and Durbin (2008); Li (2011); DePristo et al. (2011)
Haplotype-based calling local assembly or candidate haplotypes in a window, read likelihoods by a pair HMM Garrison and Marth (2012) for FreeBayes; GATK HaplotypeCaller
DeepVariant a convolutional network classifies an image of the pileup at each candidate site into three genotypes Poplin et al. (2018)
Variant quality score recalibration a filter after calling: a mixture model on the site annotations separates real sites from artifacts DePristo et al. (2011)

The calls depend on the steps before them as much as on the caller: read mapping, duplicate marking and base quality score recalibration. The paired-end placement of the reads decides which repeats can be called at all.

AlgorithmTimeSpacePropertiesCode
Bayesian genotype callingΘ(n) worst · average · bestΘ(1) extradeterministicexactonlineiterative1 language
Haplotype-based variant callingO(R H L n + R H^2 + R H V) worstO(R H + L n) extradeterministicnot exactofflineiterative1 language

Bounds

  • Time. A per-site caller reads each aligned base once and does O(1)O(1) work per base and genotype, so it runs in time linear in the total number of aligned bases, about NLN L for NN reads of length LL. Haplotype-based callers cost more in active regions, where they align every read against every candidate haplotype.
  • Depth. A heterozygous site with dd reads, each from either chromosome with probability 1/2, shows no alternate read with probability 2−d2^{-d}, and at most one with probability (1+d)2−d(1 + d) 2^{-d}. For d=10d = 10 these are 0.098% and 1.07%; for d=30d = 30, about 9.3×10−109.3 \times 10^{-10} and 2.9×10−82.9 \times 10^{-8}. With coverage that varies along the genome, the low-depth sites dominate the missed heterozygotes.
  • Mappability. If a segment of the genome has an exact copy longer than the reads and the inserts, reads from it cannot be placed, and no caller can tell in which copy a variant lies.
  • Measuring accuracy. Calls are compared with benchmark sets, such as the Genome in a Bottle calls for NA12878 (Zook et al., 2014), in their confident regions, and the result is given as precision and recall. The comparison needs the two sets in the same representation, which variant normalization gives for simple cases.

Reductions

  • To one decision per site. With a pileup and a fixed allele pair, per-site calling is a choice among m+1m + 1 genotypes by maximum a posteriori estimation.
  • From read mapping. The input is the output of read mapping; a better placement of the reads changes the calls more than any change of the prior.
  • To phasing. The genotypes of a VCF of unknown phase are the input of haplotype phasing.
  • To filtering. The raw calls of a sensitive caller are filtered, by hard thresholds on their annotations or by variant quality score recalibration.

Applications

  • Clinical genetics. Finding the variant that causes a rare disease in an exome or genome of a patient and the parents.
  • Population genetics. Allele frequencies, the site frequency spectrum and estimators such as Watterson's start from variant calls or from genotype likelihoods.
  • Association studies. Genotypes of many individuals at many sites, often completed by imputation.
  • Cancer. Somatic calls of a tumor against its matched normal.

References

  1. Rasmus Nielsen, Joshua S. Paul, Anders Albrechtsen and Yun S. Song, Genotype and SNP calling from next-generation sequencing data, Nature Reviews Genetics 12(6), 2011, pp. 443 to 451 (the difference between SNP calling and genotype calling, the steps before calling, and single-sample and multi-sample methods)
  2. Mark A. DePristo, Eric Banks, Ryan Poplin and others, A framework for variation discovery and genotyping using next-generation DNA sequencing data, Nature Genetics 43(5), 2011, pp. 491 to 498 (the three phases of data processing, variant discovery and genotyping, and filtering)
  3. Heng Li, A statistical framework for SNP calling, mutation discovery, association mapping and population genetical parameter estimation from sequencing data, Bioinformatics 27(21), 2011, pp. 2987 to 2993 (calling from genotype likelihoods across many samples)
  4. Erik Garrison and Gabor Marth, Haplotype-based variant detection from short-read sequencing, arXiv 1207.3907, 2012, the sections on the model and on the detection of haplotypes in a window (FreeBayes)
  5. Ryan Poplin, Pi-Chuan Chang, David Alexander and others, A universal SNP and small-indel variant caller using deep neural networks, Nature Biotechnology 36(10), 2018, pp. 983 to 987 (DeepVariant, genotype calling from images of the pileup with a convolutional network)
  6. Justin M. Zook, Brad Chapman, Jason Wang and others, Integrating human sequence data sets provides a resource of benchmark SNP and indel genotype calls, Nature Biotechnology 32(3), 2014, pp. 246 to 251 (the Genome in a Bottle benchmark calls for NA12878 and their confident regions)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml