Content
Summary
The FASTQ format stores biological sequences and quality scores, with each read consisting of exactly four lines, allowing total read counts to be determined by dividing the total line count by four. Quality scores are ASCII-encoded values derived by subtracting an offset, such as 33, and tools like fastq_quality_trimmer use these scores to remove low-quality bases based on specified thresholds. Analyzing read length distributions after trimming helps assess the effectiveness of the quality control process.
Intuition
Think of a FASTQ file as a structured ledger where every sequencing read is recorded in a strict four-line block: the identifier, the sequence, a separator, and the quality string. To understand the data's reliability, we convert the ASCII characters in the quality string into numerical scores by subtracting an offset (like 33), which represents the probability of error. When we trim low-quality bases, we are essentially cutting off the unreliable ends of these sequences. By plotting the distribution of the remaining read lengths on a log scale, we can visually verify that we have removed poor-quality data without unnecessarily shortening the useful parts of the reads.
Derivation
- Identify that each read in a FASTQ file occupies exactly four lines.
- Calculate total reads by dividing the total number of lines in the file by four.
- Convert ASCII quality characters to numerical scores by subtracting the offset (e.g., 33).
- Apply a threshold (e.g., 20) to trim low-quality bases from the end of sequences.
- Ensure the -Q flag is used to specify the offset, as it is not in the help menu.
- Plot the resulting read lengths on a log-scale y-axis to visualize distribution variations.
- Compare pre- and post-trimming data to evaluate the effectiveness of the trimming process.
Worked example
You have a FASTQ file with 400 lines. You need to determine the number of reads and trim bases with quality scores below 20, assuming an offset of 33. What is the read count, and what flag is critical for the trimming tool?
- Count the total lines: 400.
- Divide by 4 to get the number of reads: 400 / 4 = 100 reads.
- Identify the quality threshold: 20.
- Recognize that the tool requires the -Q flag to specify the offset (33) because the help menu does not provide this value.
- Note that the default minimum length is 0, so no sequences are discarded by default unless specified.
Answer There are 100 reads. The critical flag is -Q 33.
Common mistakes
- Confusing error probability with quality score.
- Forgetting to use the -Q flag to specify the quality score offset, as it is not in the help menu.
- Assuming the default minimum length for trimming is non-zero; it is actually 0, meaning no sequences are discarded by default.