03. Checking FASTQ Quality and Trimming
Receiving FASTQ does not mean analysis should begin immediately. Miscalled bases and residual adapters can cause the next stage to place reads at the wrong locations. The output of this lesson is clean FASTQ for alignment.
Question for this lesson: which reads should be kept unchanged, and which ends should be removed?
This resembles running schema validation and quality monitoring before loading events from an external system into a database. FastQC is a read-only function that produces an observation report; trimming is a transformation that repairs only problems confirmed in that report.
report_before = fastqc(raw_fastq) # read-only inspectionclean_fastq = trim(raw_fastq, report_before)report_after = fastqc(clean_fastq) # check effects and side effectsThis is pseudocode for the control flow. The important structure is to separate inspection from modification and run the same inspection again after modification.
1. Files are handoffs between analysis stages
Section titled “1. Files are handoffs between analysis stages”RNA-seq file formats are easier to understand as records of how the data’s state changes through analysis than as separate formats to memorize.
FASTQ (fragments read by the sequencer and their confidence) → SAM/BAM (where each fragment aligned in the genome) → expression matrix (how many fragments accumulated at each gene)
The reference genome sequence is provided as FASTA and gene locations as GTF. Together they act as a map showing where reads can return and where gene boundaries lie.
Each file is an interface contract between pipeline stages. FASTQ preserves sequences and quality, BAM preserves coordinates and alignment state, and the expression matrix preserves gene-level aggregates. Later stages summarize detail from earlier ones, so an expression matrix cannot reconstruct the original quality strings.
See the Data Formats Reference for extensions, internal columns, and examples, and the GTF Reference for gene-annotation structure.
2. Quality control: can this read be trusted for analysis?
Section titled “2. Quality control: can this read be trusted for analysis?”Reads produced by a sequencer can contain miscalled bases, adapter sequence, and abnormally short fragments. FastQC summarizes these signals so you can decide whether to proceed, while MultiQC compares results from multiple samples on one screen.
You do not need to memorize the FastQC report from beginning to end. Read it through these four questions.
| Question | First item to inspect | If there is a problem |
|---|---|---|
| Is the read reliable through its end? | Per-base quality | Trim only the declining end |
| Is adapter sequence present? | Adapter Content | Remove that adapter |
| Are unexpected sequences abundant? | Overrepresented Sequences, GC distribution | Suspect rRNA, another organism, or adapter contamination |
| Are read length and failed calls normal? | Length distribution, N content | Check equipment and library problems |
PASS, WARN, and FAIL here do not have the meaning of a test-suite result. They only show whether a heuristic threshold was crossed, and expected RNA-seq duplication or base composition can trigger warnings. Do not branch on the status label alone; inspect the graph together with the way the sample was prepared.
Inspect quality at the read end
Section titled “Inspect quality at the read end”While reading a 100 bp read, fluorescent signal can weaken toward the end. If the first 80 bases stay near Q30 but the final 20 decline sharply, trim only the low-quality end rather than discarding the entire read. See Probability and Phred Scores for the relationship between Q30 and error probability.
If the graph’s median remains in the high-quality region through the end, there is no reason to trim for quality. Trimming is not a stage to run by habit; it is a response to an observed problem.
Adapter content rises at the end
Section titled “Adapter content rises at the end”If a fragment is shorter than the read length, the instrument reads past the end of the fragment and into the adapter. An Adapter Content curve that rises toward the read end is direct evidence for adapter trimming.
After trimming, verify that the graph has fallen close to 0. At the same time, check that too many reads have not disappeared or become excessively short.
A red result is not always a failure
Section titled “A red result is not always a failure”FastQC’s PASS, WARN, and FAIL labels identify places to investigate; they are not a final pass/fail decision for the sample. In RNA-seq, the following two items can be red even when the data is normal.
- Skewed A, T, G, and C proportions at the beginning of reads can result from priming bias during library preparation.
- Repeated identical sequences can be real reads produced repeatedly from highly expressed genes.
Conversely, an unexpected extra peak in the GC distribution or one overwhelmingly repeated sequence warrants checking for contamination. The graph’s shape and the RNA-seq context matter more than the traffic-light colour.
See the FastQC Reference for detailed thresholds for each module, real FastQC graphs, and comparison of multiple samples with MultiQC.
3. Trimming: remove ends that interfere with alignment
Section titled “3. Trimming: remove ends that interfere with alignment”Trimming removes low-quality read ends and artificial sequences such as adapters. Characters that are not on the map make it harder for an aligner to find the read’s original location when they remain attached to its end.
As string preprocessing, trimming removes a known adapter suffix and a low-confidence tail. It does not delete arbitrary internal regions or force every record to the same length.
Reading through a short fragment into the adapter
Section titled “Reading through a short fragment into the adapter”If an instrument is configured to read 100 bp but the actual fragment is 70 bp, it continues for 30 cycles after finishing the 70 bp of sample sequence. The remaining 30 bp records the adapter attached to the end of the fragment. Try reducing the fragment length below 100 bp below.
Adapters are handles needed for library preparation and sequencing, but their sequences do not exist in the human genome. Leaving them in a read makes it hard for an aligner to match the complete read to the genome. Remove the adapter and everything after it.
What gets removed?
Section titled “What gets removed?”Trimming does not make every read the same length. It removes only the regions identified as problematic in each read.
- Adapters: artificial sequence read after passing the end of the fragment
- Low-quality ends: bases whose confidence declines late in sequencing
- polyG and N: regions produced when the instrument loses signal or cannot determine a base
- polyA and polyT tails: ends derived from real RNA that can still interfere with genome alignment
More trimming is not necessarily better. Reads that become too short align ambiguously to multiple locations. Run FastQC again after trimming to confirm that contamination declined while enough usable read length and read count remain.
The goal of a before-and-after comparison is not to turn every traffic light green. Adapter warnings should disappear and per-base quality should remain good. A new warning in the length distribution can be a natural consequence of producing reads trimmed to different lengths.
The before-and-after trimming stage of the RNA-seq exercise places the FastQC and Trim Galore! outputs side by side and decides whether to continue.
See the Trimming Reference for adapter read-through, polyG, polyA, N, the problems caused by excessive trimming, and tool selection.
Summary
Section titled “Summary”FastQC does not automatically approve or reject reads. It reveals problem signals. Inspect the graphs, trim only what is needed, and check again.
Original FASTQ → FastQC → trim what is needed → FastQC again → FASTQ for alignment
Next, Aligning RNA Reads to the Genome finds where the cleaned reads came from in the genome.
Sources
Section titled “Sources”- Reference-genome ALT/HLA/decoy removal: GTEx / TOPMed RNA-seq pipeline
- Normal-tissue expression reference (GTEx): GTEx Portal: bulk tissue expression · Nature Genetics 2013
- Cancer expression and genome reference (PCAWG): Pan-cancer analysis of whole genomes, Nature 2020 · ICGC/ARGO data access
- Sid’s public expression viewer: osteosarc.com/rnaseq