# Trimming: removing adapters and low-quality regions

> The step that removes parts of reads that interfere with alignment, including adapters, low-quality ends, and polyX/N, according to QC findings. An introduction to fastp, its technical stack, why trimming is needed, real before-and-after results, and alternative tools.

**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](/en/reference/fastqc/) diagnoses problems, trimming actually changes the reads according to that diagnosis.

Its position in the pipeline is:

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

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

## Introducing fastp

**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."

| Item | Details |
| --- | --- |
| Development | **OpenGene** project, led by author Shifu Chen |
| License | **MIT**: open source, free to use, modify, and redistribute |
| Language | **C/C++** (native compilation makes it fast) |
| Interface | **CLI** (command line). No GUI |
| Input | FASTQ, including gzipped files, single-end or paired-end |
| Source | [github.com/OpenGene/fastp](https://github.com/OpenGene/fastp) |
| Paper | Shifu Chen, *iMeta* (2025): "fastp 1.0: an ultra-fast all-round tool…" |

### Open-source operation and repository

- **Repository**: [github.com/OpenGene/fastp](https://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**.

### Technical stack

| Component | Details |
| --- | --- |
| Main language | **C++ 91.4%** for the core logic. Scripts use Python 5.8% and Shell 1.8% |
| Build | **Make / CMake** |
| Core libraries | **libisal** and **libdeflate** for ultra-fast gzip compression/decompression, **libhwy** (Google Highway) for SIMD acceleration |
| Parallelism | **Multithreaded**, 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.

### How it works

- 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**.

### Outputs

- **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

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

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

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

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.

## polyX, polyG, and N in detail

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

### polyA / polyT: biological in origin

- 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

- 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`.

### N: an ambiguous base call

- 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.

## Using fastp

```bash
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.

## Case: results from one public sample

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

| Metric | Before | After | Interpretation |
| --- | --- | --- | --- |
| Read count | 4,469,592 | 4,186,118 | About 93.7% retained, 6.3% removed |
| Q30 proportion | 89.9% | **92.9%** | Removing bad regions raised average quality |
| Mean length | 100 bp | 97 bp | Slightly shorter by the trimmed amount |
| Pairs | | 2,093,059 each | **Both 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

After trimming, **run FastQC again** to confirm that adapters were actually removed and quality was preserved. The [revalidation section of the FastQC reference](/en/reference/fastqc/#run-it-again-after-trimming-beforeafter-validation) shows real before-and-after graphs where Adapter Content changes from WARN to PASS for the same sample.

## ⚠️ Caution: do not overtrim

- 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**.

## Alternative and complementary tools

| Tool | Characteristics |
| --- | --- |
| **Trim Galore** | A Perl wrapper around cutadapt and FastQC. Automatically detects adapters and provides presets for RNA, bisulfite sequencing, and more. Long validated and widely used. |
| **Trimmomatic** | Java. Lets you specify **stages in detail**, including `ILLUMINACLIP` and `SLIDINGWINDOW`. Requires an adapter file but provides precise control. Common in legacy pipelines. |
| **cutadapt** | Python. 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. |
| **AfterQC** | The predecessor to fastp, by the same author. |

### How to choose

- 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.