3: Raw Read Quality Control & Adapter Trimming
Chapter 3: Raw Read Quality Control & Adapter Trimming
Raw reads off the sequencer are contaminated with residual adapter sequences, low-quality base calls at the 3' tails, sequencing artifacts, and optical flow cell anomalies. Passing unfiltered reads directly into aligners degrades mapping accuracy and causes false-positive variant calls. Quality control and pre-processing are non-negotiable first steps in every production NGS pipeline.
During SBS cycles, incomplete enzymatic deblocking (pre-phasing) or failure to incorporate a dNTP (phasing) causes individual molecules within a cluster to lose synchrony. As cycle number increases (especially past cycle 100), accumulated phasing noise degrades signal-to-noise ratio, causing Phred scores to drop at the 3' ends of reads.
1. Deconstructing the FastQC Report
FastQC provides a rapid modular assessment of high-throughput sequence data:
- Per Base Sequence Quality: Boxplots depicting Q-score distribution per cycle. Scores above Q30 (green zone) indicate high fidelity. If median scores drop below Q20, trimming is necessary.
- Per Base Sequence Content: Evaluates base proportions (A, T, G, C) across cycles. While genomic DNA should exhibit equal lines (e.g. ~25% each depending on GC%), RNA-seq libraries often display severe nucleotide bias in the first 10–12 bases due to random hexamer priming during reverse transcription.
- Per Sequence GC Content: Compares the observed GC distribution to a theoretical normal curve. Bimodal distributions indicate sample contamination (e.g., bacterial infection or mycoplasma).
- Adapter Content: Identifies the proportion of reads containing Illumina universal adapter sequences, caused when library insert sizes are shorter than the read length (read-through).
2. High-Performance Pre-Processing with fastp
fastp is an ultra-fast, multithreaded preprocessor written in C++ that performs adapter trimming, quality filtering, poly-G clipping, and base correction in a single pass:
# Execute fastp on paired-end Illumina WGS reads
fastp \
-i sample_R1.fastq.gz \
-I sample_R2.fastq.gz \
-o sample_trimmed_R1.fastq.gz \
-O sample_trimmed_R2.fastq.gz \
--detect_adapter_for_pe \
--cut_front --cut_tail \
--cut_window_size 4 --cut_mean_quality 20 \
--qualified_quality_phred 20 \
--unqualified_percent_limit 30 \
--length_required 50 \
--trim_poly_g \
--thread 16 \
--html sample_fastp_report.html \
--json sample_fastp_report.json3. Cohort Quality Aggregation with MultiQC
When sequencing hundreds of samples, inspecting individual FastQC or fastp reports is impossible. MultiQC recursively scans directories and aggregates all logs into a single interactive HTML dashboard:
# Run FastQC on all FASTQ files in parallel
fastqc -t 8 -o qc_reports/ raw_data/*.fastq.gz
# Aggregate FastQC, fastp, and aligner logs into a unified cohort dashboard
multiqc qc_reports/ -o cohort_qc_dashboard/Common Pitfalls & Troubleshooting Checklist
- Java Heap Exhaustion (GATK / Picard): If processes terminate with
java.lang.OutOfMemoryError, set your environment variable explicitly:export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp". - Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with
samtools index -@ 4 sample.bam. - Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority:
conda config --set channel_priority strict. - Chromosome Naming Contamination: Always verify whether reference FASTA headers use
chr1or1; divergent naming causes silent alignment drops.