Definitioncore
Mapping quality
Also called MAPQ.
The Phred-scaled probability that a read is placed at the wrong location, -10 log10 P(wrong). It is low for reads in repeats. Each aligner computes it by its own rule.
The mapping quality of a read says how sure an aligner is that it put the read in the right place on the reference. It uses the Phred scale: MAPQ 30 means a 1 in 1000 chance that the reported position is wrong. A read from a unique part of the genome can get a high value even with a few mismatches, while a read from a repeat with two equally good positions gets a value near 0 however well it matches. Li, Ruan and Durbin (2008) defined mapping quality in this way for the Maq aligner; the SAM format stores it in field 5, and each aligner computes it by its own rule.
Definition
Let a read be aligned to a reference, and let be the position the aligner reports. The mapping quality of the read is
rounded to an integer. In SAM the value 255 means that the mapping quality is not available.
The posterior form. Maq models the read as coming from one position of the reference, with a uniform prior over the positions. Given , the read bases are independent, and a base of quality is wrong with probability . So the probability of the read from is
and by Bayes' theorem
The sum runs over every position of the reference. An aligner can compute only the terms of the hits it finds, so in practice the sum is taken over the best few hits, with a correction for the hits that the search may have missed.
The approximation. When the best hit has no mismatch and the second best differs in a few bases, the sum is dominated by those two terms, and
where is the sum of the qualities of the mismatched bases of that hit. This is the form that Maq approximates, with caps that depend on the number of mismatches its search allows.
Each aligner has its own rule. BWA, Bowtie 2 and minimap2 all write MAPQ, but none computes the exact posterior. They map features such as the gap between the best and the second best alignment score, and the number of equally good hits, to a number on the Phred scale with their own tables and caps. BWA writes 0 for a read with several equally best hits. The largest value differs between tools (60 for BWA-MEM and minimap2, 42 for Bowtie 2), so MAPQ values from two aligners are not on the same footing.
Examples and non-examples
A unique read. A read has the best hit with no mismatches and a second hit with one more mismatch at a Q30 base, and no other hit is close. In the posterior form, the ratio of the two likelihoods is with , which is , so
The approximation counts the mismatch as instead of and gives 30. With two extra Q30 mismatches on the second hit, the posterior form gives 69.53.
A read in a two-copy repeat. If the read matches two positions equally well, each has posterior , and . With three equal hits, and . An aligner reports one of the copies at random, and BWA writes 0.
The help of the mate. If the read of the last example is one mate of a read pair and its mate maps uniquely, only one copy of the repeat sits at a distance that fits the insert size. A paired aligner then gives the read a high MAPQ; see paired-end read mapping.
Non-example: the alignment score. The score of an alignment measures how well the read matches at one position. MAPQ compares that position with the others. A perfect match in a repeat has a top score and MAPQ 0.
Non-example: a position missing from the reference. A read from a part of the sample genome that is not in the reference, such as a new copy of a repeat, can map uniquely to the wrong copy with a high MAPQ. The posterior is computed over the reference, so it cannot account for sequence that the reference lacks.
Non-example: a rule of thumb taken as a definition. Pipelines often keep only reads with MAPQ at least 20 or at least 30, for example with samtools view -q. These cut-offs are habits of common pipelines, not part of the SAM definition, and on the scale of a given aligner they mean different things.
Related definitions
- Phred scale. MAPQ uses the scale of base qualities; see Phred quality score.
- Secondary and supplementary alignments. Other hits of the same read are written with the flags 0x100 and 0x800 of SAM. The MAPQ of the primary record already accounts for them.
- Use in genotype calling. A base of a read with mapping quality comes from the wrong place with probability . Some callers mix that into the genotype likelihood, and others cap each base quality at the read's MAPQ so that no base counts for more than its placement.
- Pileup. The pileup format shows the MAPQ of each read at its first base.
References
- Heng Li, Jue Ruan and Richard Durbin, Mapping short DNA sequencing reads and calling variants using mapping quality scores, Genome Research 18(11), 2008, pp. 1851 to 1858, Methods (the definition of mapping quality as a posterior probability and its approximation from the best and second best hits in Maq)
- Heng Li and Richard Durbin, Fast and accurate short read alignment with Burrows-Wheeler transform, Bioinformatics 25(14), 2009, pp. 1754 to 1760, Methods (the mapping quality of BWA for unique and repeated hits)
- The SAM/BAM Format Specification, version 1.6, hts-specs, Section 1.4, field 5 MAPQ (-10 log10 of the probability that the mapping position is wrong, 255 if not available)
- Ben Langmead and Steven L. Salzberg, Fast gapped-read alignment with Bowtie 2, Nature Methods 9(4), 2012, pp. 357 to 359 (Bowtie 2 and its reporting of alignments)
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag J0YP9E Edit this page History Report an error Markdown