Skip to content
Tutorials Center
My learning

Topics

Lesson 46 of 49 ยท Projects and Practice

Practice Problems: Genomics, RNA-seq, Structure and ML

Six hand-calculation problems on Phred scores, coverage, genotypes, TPM, Benjamini-Hochberg and RMSD, with an answer checker, code and fully worked solutions.

Reading a formula and using it are different skills. This practice set gives you six problems, each short enough to do by hand or with a calculator, each drawn from a different chapter. Try every problem on paper first. Then use the answer checker to test your numbers, and read the worked solutions to compare the reasoning, not just the result.

The problems are deliberately small and clean. Real data are larger and messier, but the arithmetic is the same arithmetic, and being fluent with it is what lets you notice when a number from a program looks wrong.

Six problem tiles in two rows: Phred arithmetic, coverage estimate, genotype from counts, normalize two genes, BH adjustment and RMSD by hand, each with a difficulty rating of one to three stars.
Caption: six problems, one per big idea, from easy to harder.

How to use this page

  1. Read a problem and write your answer on paper with units.
  2. Enter your answers in the checker. It tells you whether each is within a sensible tolerance, but it does not reveal the answer until you ask.
  3. If you disagree with the checker, read the worked solution and find the step where your reasoning differed.
  4. Run the Python solutions to see the same numbers computed by code, and change the inputs to make new variants of each problem.

The problems

Problem 1: Phred arithmetic (easy). (a) A base has Phred score Q25. What is the probability that it was called wrongly, as a percentage? (b) A caller reports an error probability of 0.0005 for a base. What Phred score is that? (c) A read has the quality string 5555?????IIII (offset 33). What are the mean Phred score and the expected number of wrong bases in the read?

Problem 2: Coverage (easy). (a) A 5-megabase bacterial genome is sequenced with 150-base single-end reads. How many reads are needed for 50x mean depth? (b) How many read pairs is that if you sequence 2 by 150 paired-end? (c) Under the Poisson model, what fraction of the genome is expected to have no reads at a mean depth of 8x, and how many bases is that?

Problem 3: Genotype from counts (medium). Use the binomial model with per-base error 0.01 and priors 0.998, 0.001, 0.001 for 0/0, 0/1, 1/1. For each pileup, choose the most probable genotype: (a) depth 24 with 11 alternate reads; (b) depth 10 with 1 alternate read; (c) depth 20 with 19 alternate reads; (d) depth 6 with 2 alternate reads, and say how confident the call is.

Problem 4: Normalizing two genes (medium). Three genes have lengths 2,000, 500 and 1,000 bases and counts of 400, 200 and 300 in one sample. Compute the CPM and the TPM for each gene. Which gene looks highest by CPM, and which by TPM? Explain the difference.

Problem 5: Benjamini-Hochberg (harder). Eight genes have raw p-values 0.002, 0.009, 0.013, 0.040, 0.041, 0.200, 0.500 and 0.700. (a) Which are significant at FDR 5%? (b) Compute the adjusted p-values.

Problem 6: RMSD by hand (medium). After superposing two chains, four matched C-alpha pairs are 1.0 ร…, 2.0 ร…, 2.0 ร… and 3.0 ร… apart. (a) What is the RMSD? (b) What would it be if the 3.0 ร… pair were removed? (c) Why is the first value higher than the plain average distance?

Study tips for calculation problems

Calculation fluency comes from a few small habits. Write the formula before you substitute numbers, so that an error in the setup is visible on the page. Carry units through every step: if the answer to a coverage question comes out in "reads per base", something is off, and a quick unit check catches many slips. Estimate before you compute: 50x of a 5 Mb genome with 150-base reads should be about a million and a half reads, because 50 times 5 million is 250 million bases and 250 million divided by 150 is under two million. If your calculator says 16,666, you dropped a factor of a hundred.

Use powers of ten as a guide. Phred scores are easy to sanity-check this way: Q20 is two zeros (1 in 100), Q30 is three zeros, Q40 four. When a problem asks for something between those values, such as Q25, the answer lies between 1 in 100 and 1 in 1,000, closer to the 1 in 316 that 10^(2.5) gives. Finally, check each answer against its meaning: a probability should lie between 0 and 1, an RMSD cannot be negative, and TPM values for one sample must sum to a million.

Check your answers

Enter your numbers; the checker accepts answers within a small tolerance. The "Show" buttons reveal the answer only when you click them.

Answer checker

Solutions by code

The Python version below solves every problem and prints the answers, so you can confirm the hand calculation and then experiment with the inputs. It also solves Problem 3 and the adjusted p-values for Problem 5.

Python Solutions in Python

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Worked solutions

Problem 1. (a) P = 10^(-Q/10) = 10^(-2.5) = 0.00316, about 0.32%. (b) Q = -10 * log10(0.0005); since log10(0.0005) = -3.301, Q = 33.0. (c) The characters 5, ? and I have ASCII codes 53, 63 and 73, so with offset 33 they are Q20, Q30 and Q40. The string has 4 bases at Q20, 5 at Q30 and 4 at Q40: the mean is (80 + 150 + 160) / 13 = 30.0. The expected number of errors is 4 * 0.01 + 5 * 0.001 + 4 * 0.0001 = 0.0454, so less than one in twenty reads like this would contain any error.

Problem 2. (a) reads = depth * genome / read length = 50 * 5,000,000 / 150 = 1,666,667. (b) A pair contributes 300 bases, so 50 * 5,000,000 / 300 = 833,333 pairs, half as many pairs as single reads. (c) The uncovered fraction is e^(-8) = 0.000335, which is 0.000335 * 5,000,000, about 1,677 bases. Even at 8x, a handful of short stretches remain unread under the idealized model, and real genomes have more because of bias.

Problem 3. (a) Depth 24 with 11 alternates is an alternate fraction of 0.46, close to 0.5, so 0/1; the likelihood is vastly higher under the heterozygous model than under either homozygous one. (b) One alternate read in 10 is exactly what a 1% error rate plus a large prior for 0/0 expects, so 0/0. (c) 19 of 20 alternates is nearly all alternate with one possible error: 1/1. (d) Two of six alternates (fraction 0.33) is ambiguous: the model says 0/0 with a posterior of about 0.86, because the strong prior favors reference and six reads are too few to overturn it; the call is weak (a genotype quality near 8). This is the case to flag as low confidence. Notice how depth drives certainty: the same alternate fraction at depth 30 would be called heterozygous.

Problem 4. Reads per base of gene length: gene A 400 / 2000 = 0.2, gene B 200 / 500 = 0.4, gene C 300 / 1000 = 0.3; the sum is 0.9. TPM is each divided by 0.9, times a million: A 222,222; B 444,444; C 333,333. CPM only divides by total counts (900): A 444,444; B 222,222; C 333,333. By CPM, gene A looks the most expressed, but it is four times longer than gene B and so collects more reads per transcript. After accounting for length, gene B has the most transcripts per million, as the figure in the normalization lesson showed. The rankings of A and B reverse.

Problem 5. The BH thresholds (k/8) * 0.05 are 0.00625, 0.0125, 0.01875, 0.025, 0.03125, 0.0375, 0.04375 and 0.05. Ranks 1 to 3 pass (0.002, 0.009 and 0.013 are below their thresholds). Rank 4 (0.040 against 0.025) does not, and neither does anything after it, so three genes are significant. The adjusted values are p * m / rank: 0.016, 0.036, 0.0347, 0.08, 0.0656, 0.267, 0.571, 0.7, and then enforcing monotonicity from the end by a running minimum gives 0.016, 0.0347, 0.0347, 0.0656, 0.0656, 0.267, 0.571, 0.7. Three genes fall below 0.05, matching the threshold method. Notice how the second gene's value 0.036 was lowered to 0.0347 to keep the sequence non-decreasing.

Problem 6. (a) RMSD = sqrt((1 + 4 + 4 + 9) / 4) = sqrt(4.5) = 2.121 ร…. (b) Without the 3 ร… pair: sqrt((1 + 4 + 4) / 3) = sqrt(3) = 1.732 ร…. (c) The plain mean distance is 2.0 ร…. The RMSD is larger because squaring weights large deviations more heavily; removing one outlier lowers the RMSD by about 0.4 ร…, which is why a single mobile loop can dominate a protein comparison.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. A base error probability of 0.001 corresponds to which Phred score?

    Q = -10 * log10(0.001) = 30.
  2. 2. To reach 20x depth on a 4 Mb genome using 100-base reads you need about:

    20 * 4,000,000 / 100 = 800,000 reads.
  3. 3. Genes of equal expression but different length differ in raw counts because:

    Reads sample the transcript in proportion to its length.
  4. 4. A gene has raw p = 0.03 at rank 2 among 10 tests. What is its BH value before the running-minimum step?

    The raw adjusted value is p * m / rank = 0.03 * 10 / 2 = 0.15.
  5. 5. Removing the largest-distance pair from an RMSD calculation will:

    Because distances are squared, the largest one contributes disproportionately.

Summary

  • Phred scores, depth, TPM, BH adjustment and RMSD are short calculations; practice them until they are automatic.
  • Always carry units, and sanity-check results against what is plausible (for example 30x for a human genome needs hundreds of millions of reads).
  • Depth drives genotype confidence: the same alternate fraction means different things at 6 reads and at 30 reads.
  • Length and depth corrections can reverse a ranking of genes; outliers can dominate an RMSD.

Next: Glossary