Quiz: from reads to coverage
Short questions on reads, alignment, filtering and coverage tracks. Try each on paper first, then open the answer.
Q1. A base in a Phred+33 FASTQ file has the quality character + (ASCII 43). What is its Q, and the probability that the base call is wrong? What would the same character mean in a Phred+64 file?
Q = ASCII − offset, and \(p = 10^{-Q/10}\).
Phred+33: Q = 43 − 33 = 10, \(p = 10^{-1} = 0.1\), one error in ten. In Phred+64, ASCII 43 would be Q = −21, which is impossible: Phred+64 qualities start at @ (ASCII 64). Seeing characters below ; in a file tells you it is Phred+33.
Q2. Decode the FLAGs 163 and 1040. What kind of read is each, and would samtools view -F 1804 keep it?
Subtract the largest power of two that fits, and repeat. 1804 = 1024 + 512 + 256 + 8 + 4.
163 = 128 + 32 + 2 + 1: read 2 of a properly paired fragment, on the forward strand, mate on the reverse strand. Kept. 1040 = 1024 + 16: a single-end read on the reverse strand, marked as a duplicate. Removed by -F 1804, because 1804 contains the 1024 bit.
Q3. A proper pair of 50 bp reads: read 1 has FLAG 99 and POS 20 001, read 2 has FLAG 147 and POS 20 251. How long is the fragment, and what is TLEN in each line?
Read 2 ends at 20 251 + 50 − 1 = 20 300. Fragment = 20 300 − 20 001 + 1 = 300 bp. TLEN = +300 for read 1 (the leftmost), −300 for read 2.
Q4. A read aligned with MAPQ 1 and the tags AS:i:-6 XS:i:-6. What does this tell you about the read, and should it go into a coverage track?
The best alignment score (AS) equals the second-best (XS): the read fits at least two places equally well, typically copies of a repeat, and bowtie2 reported one of them at random. MAPQ 1 means the position is very likely wrong. Remove it (MAPQ ≥ 30): otherwise its signal is spread at random over the copies. The repeat then has no signal at all, which means no information, not no binding.
Q5. Why are duplicates usually removed in ChIP-seq and ATAC-seq but usually kept in RNA-seq? When can removing them in ChIP-seq hurt?
In RNA-seq a highly expressed gene produces so many fragments that many share a start position by chance: removing them would compress the expression of the most expressed genes. In ChIP and ATAC, each position is covered by few independent fragments from a small amount of DNA, so identical start positions are mostly PCR copies, and an amplified fragment would look like a peak. Removing them can hurt at very strong, narrow peaks with single-end reads: there are only a few hundred possible start positions per strand, so independent fragments collide (saturation). In the CTCF data, 49% of reads inside peaks were flagged as duplicates against 4% outside.
Q6. 60% of the aligned reads of an ATAC-seq library are on chrM. You make a CPM track of the nuclear genome without removing the chrM reads. Compared with a track made after removing them, are the nuclear values too high or too low, and by what factor?
Too low, by a factor of 2.5. CPM divides by all reads in the BAM. Only 40% of the reads are nuclear, so the denominator is 1/0.4 = 2.5 times too large. Two libraries with different chrM fractions would look different even if their nuclear signal were the same.
Q7. A ChIP library has 20 million filtered reads, extended to 200 bp; the effective genome size is 2.7 × 109 bp. A base is covered by 45 fragments. What is its RPGC value? What is the CPM of a bin overlapped by 45 reads?
Average coverage = reads × fragment length / genome size.
Average coverage \(= 2 \times 10^7 \times 200 / 2.7 \times 10^9 = 1.48\). RPGC \(= 45 / 1.48 = 30.4\): 30 times the genome average. CPM \(= 45 \times 10^6 / (2 \times 10^7) = 2.25\).
Q8. After depth scaling, a 50 bp bin has 9 ChIP reads and 1 input read; another has 1 ChIP read and 0 input reads. Compute \(\log_2\)((ChIP + 1) / (input + 1)) for both. Why add 1?
log2(10/2) = 2.32 and log2(2/1) = 1.0. Without the pseudocount the second bin would be 1/0 = ∞, the most “enriched” bin in the genome on the strength of a single read. Adding 1 to both counts makes the ratio of small counts shrink towards 0 (no change), while large counts are hardly affected.
Q9. In a single-end ChIP-seq experiment, the coverage of the reads themselves (not extended) shows two humps about 180 bp apart around each binding site, with a dip in between. Explain the pattern. What should you do before making a coverage track?
Each read is one end of a fragment that spans the site. Fragments sequenced from the + strand put their reads to the left of the site, those from the − strand to the right, so the reads form two humps about one fragment length apart, and the site itself is between them. The distance (here about 180 bp) estimates the fragment length. Extend every read in its own direction to that length (bamCoverage --extendReads 180): the extended reads overlap on the site and give one peak. (Paired-end data give each fragment directly.)
Q10. To save time, a student aligns whole-genome ChIP-seq reads to a reference that contains only chr21. Most reads align, many with MAPQ 42. Explain what has gone wrong, and why the high MAPQ is no reassurance.
Reads from the other chromosomes were forced onto chr21 wherever the sequence was most similar (repeats, paralogues, processed pseudogenes), creating false signal. MAPQ only compares the places the aligner can see: if the true origin is not in the reference, a read can look unique on chr21 and get MAPQ 42. Align to the whole genome and select chr21 afterwards. (The course data avoid this by including only reads that ENCODE placed on chr21 or chrM against the whole genome.)