Skip to content

Trimming: removing adapters and low-quality regions

Trimming is a preprocessing step that cuts adapters and low-quality portions from reads stored in FASTQ. fastp is command-line software used for this work. If QC with FastQC diagnoses problems, trimming actually changes the reads according to that diagnosis.

Its position in the pipeline is:

FASTQ → QC(FastQC) → [② trimming(fastp)] → alignment → quantification(TPM) → comparison

Unlike FastQC, trimming changes the data and creates new FASTQ files.

fastp is one of today’s most widely used preprocessing tools for performing QC, trimming, and filtering on FASTQ in one pass. It describes itself as an “ultra-fast all-in-one FASTQ preprocessor.”

ItemDetails
DevelopmentOpenGene project, led by author Shifu Chen
LicenseMIT: open source, free to use, modify, and redistribute
LanguageC/C++ (native compilation makes it fast)
InterfaceCLI (command line). No GUI
InputFASTQ, including gzipped files, single-end or paired-end
Sourcegithub.com/OpenGene/fastp
PaperShifu Chen, iMeta (2025): “fastp 1.0: an ultra-fast all-round tool…”
  • Repository: github.com/OpenGene/fastp, under the MIT license. It is widely distributed through Bioconda and Linux distributions.
  • Project model: an active project centered on lead author Shifu Chen with 39 contributors. It has 58 releases, with the latest v1.3.6 (2026-06). It also has many issues and pull requests, making development much more active than FastQC.
  • If FastQC is “a single-maintainer tool from an academic core facility,” fastp is closer to an active project with lively community contributions.
ComponentDetails
Main languageC++ 91.4% for the core logic. Scripts use Python 5.8% and Shell 1.8%
BuildMake / CMake
Core librarieslibisal and libdeflate for ultra-fast gzip compression/decompression, libhwy (Google Highway) for SIMD acceleration
ParallelismMultithreaded, with 3 threads by default and adjustable with -w
  • Native C++ together with SIMD and fast compression libraries makes it very fast. Unlike FastQC, which is written in Java, fastp performs processing and QC together while maintaining speed.
  • It streams through FASTQ once, simultaneously performing quality profiling (QC), adapter and quality trimming, and filtering.
  • Unlike FastQC, which only diagnoses, fastp combines diagnosis with actual modification and produces new, cleaned FASTQ files.
  • For paired-end data, it analyzes the overlap between the two reads to detect adapters automatically, without needing their sequence. If one mate is discarded, it handles the other mate with it to keep pairs synchronized.
  • Cleaned FASTQ (out_R1.fastq.gz, out_R2.fastq.gz): input to the next alignment stage.
  • HTML report: interactive before-and-after quality curves, adapters, and filtering statistics.
  • JSON report: machine-readable statistics for automation and MultiQC aggregation.

Why trimming is needed: removing things that interfere with alignment

Section titled “Why trimming is needed: removing things that interfere with alignment”

Alignment matches reads against a genome. If a read includes a sequence absent from the genome or unreliable bases, it may align incorrectly or fail to align. Trimming mainly cleans up three categories.

① Adapters: artificial sequences absent from the genome

Section titled “① Adapters: artificial sequences absent from the genome”

During library preparation, adapters, handles that the sequencer captures, are attached to both ends of DNA fragments. Reading should start after the adapter, but if the fragment is shorter than the read length, the instrument finishes the fragment and continues into the adapter on the opposite end. This is called read-through. Shorten the fragment with the slider below to see it directly.

This adapter segment is absent from the genome and interferes with alignment, so it must be removed. Shorter fragments contain more adapter sequence.

② Low-quality bases, mainly at read ends

Section titled “② Low-quality bases, mainly at read ends”

As sequencing cycles progress toward the end of a read, the signal tends to weaken and quality declines. Low-quality bases are more likely to be incorrect and can cause misalignment, so read ends that fall below a threshold are cut off.

③ Other artifacts: polyX, N, and reads that become too short

Section titled “③ Other artifacts: polyX, N, and reads that become too short”

The categories are described in detail below. A read that becomes too short after trimming is no longer useful for alignment, so the entire read is discarded.

These three artifacts have different causes, and knowing them helps you interpret QC results correctly.

  • mRNA has a polyA tail (AAAA…) at its 3’ end, which is a marker of mRNA. When a read reaches this tail, it appears as AAAA…. Reading the opposite strand produces the complementary sequence TTTT…, or polyT.
  • PolyA/T is therefore not an error but a sequence derived from real mRNA. It interferes with genome alignment, so a tail at the end of a read is trimmed.

polyG: a false signal from 2-color instruments

Section titled “polyG: a false signal from 2-color instruments”
  • Some Illumina instruments, including NextSeq, NovaSeq, and iSeq, distinguish four bases through combinations of two fluorescent colors. In this system, “no signal” is interpreted as G.
  • If a cluster passes the end of a fragment and has nothing left to read, causing the signal to disappear, the instrument can mistake that absence for G and add a false GGGG… to the end of the read. This is an artifact, not a real sequence.
  • By contrast, 4-color instruments such as HiSeq 2000/2500 and MiSeq give each base its own fluorescence and do not have the polyG problem. fastp detects the instrument and handles polyG automatically, or you can specify --trim_poly_g.
  • The sequencer inserts N when it cannot decide whether a base is A, T, G, or C. It also assigns the lowest quality score.
  • A few scattered Ns are harmless, but a read containing too many is unreliable and is discarded entirely.

The X in polyX means “any base”. It is a collective name for polyA, polyT, polyG, and polyC. fastp’s --trim_poly_x removes these single-base repeats from read ends regardless of the base.

Terminal window
fastp \
-i R1.fastq.gz -I R2.fastq.gz \ # input (two files together = preserve pairs)
-o out_R1.fastq.gz -O out_R2.fastq.gz \ # output
--trim_poly_x \ # remove polyA/T tails
--html report.html --json report.json # before/after reports
  • Automatic adapter detection is the default and usually works without additional options.
  • Common options include -q for the quality threshold, -l for minimum length, --trim_poly_g for polyG from 2-color instruments, and -w for threads.

The table compares public human RNA-seq run DRR024878 before and after fastp v1.3.6.

MetricBeforeAfterInterpretation
Read count4,469,5924,186,118About 93.7% retained, 6.3% removed
Q30 proportion89.9%92.9%Removing bad regions raised average quality
Mean length100 bp97 bpSlightly shorter by the trimmed amount
Pairs2,093,059 eachBoth sides equal, so pairs were preserved

Removed: adapters from 383,422 reads, totaling 8.2 million bases; polyX from 91,389 reads; 265,342 low-quality reads; and 17,288 reads that were too short.

The original data was good, so it required only light cleanup. “Q30 rises, length falls slightly” is a typical trimming tradeoff.

Confirming that trimming worked: rerun FastQC

Section titled “Confirming that trimming worked: rerun FastQC”

After trimming, run FastQC again to confirm that adapters were actually removed and quality was preserved. The revalidation section of the FastQC reference shows real before-and-after graphs where Adapter Content changes from WARN to PASS for the same sample.

  • An overly strict quality threshold can discard perfectly usable reads and distort expression quantification. If the data is good, trim lightly.
  • Modern aligners such as STAR and HISAT2 can use soft-clipping to ignore unmatched read ends automatically, so aggressive quality trimming is less useful than it once was. Adapter removal is still clearly worthwhile.
ToolCharacteristics
Trim GaloreA Perl wrapper around cutadapt and FastQC. Automatically detects adapters and provides presets for RNA, bisulfite sequencing, and more. Long validated and widely used.
TrimmomaticJava. Lets you specify stages in detail, including ILLUMINACLIP and SLIDINGWINDOW. Requires an adapter file but provides precise control. Common in legacy pipelines.
cutadaptPython. The core engine for adapter removal, used internally by many wrappers. Provides precise control over adapter patterns.
BBDuk (BBTools)Java. Uses k-mers to handle adapters, contamination, and quality together. Highly versatile.
AfterQCThe predecessor to fastp, by the same author.
  • To perform QC and trimming together quickly, choose fastp.
  • For fine-grained control over each stage, choose Trimmomatic.
  • To work directly with adapter patterns, choose cutadapt.
  • For multipurpose processing, including contamination removal, choose BBDuk.

In one sentence: trimming is the stage that creates clean FASTQ by cutting adapters, low-quality ends, and artifacts that interfere with alignment. fastp is a fast C++ tool that combines QC, trimming, and filtering, and the result should be checked again with FastQC.