![]()
Learning Objectives
- Be able to assess the quality of read data.
- Know the limitations of FastQC.
- Know how to clean read data.
- Know when you need to clean read data.
The Master's Voice says: 'Reads need to be trimmed!'
The first step in every bioinformatics workflow is the quality trimming and filtering of MGS reads. However, this is not always necessary. So think carefully before applying your pipeline.
Setup
Login to the server and download the exercise data.
cd ${HOME}
curl -O "https://www.gdc-docs.ethz.ch/GeneticDiversityAnalysis/GDA/data/QF.tar.gz"
tar xvzf QF.tar.gz && rm QF.tar.gz
cd QF
ls
Before proceeding, verify the integrity of the downloaded files:
The exercise covers the following datasets:
| Example | File | Data Type | Platform |
|---|---|---|---|
| A | example_A.fq.gz | RNA-Seq | HiSeq4000 |
| B | example_B.fq.gz | DNA-Seq | HiSeq4000 |
| C | example_C.fq.gz | ddRAD | HiSeq2500 |
| D | example_D.fq.gz | Amp-Seq | MiSeq |
| E | example_E.fq.gz | Amp-Seq | HiSeq2000 |
| F | example_F.fq.gz | DNA-Seq | HiSeq2000 |
| G | example_G.fq.gz | DNA-Seq | unknown |
| H | example_H.fq.gz | Metagenomics | HiSeq2500 |
| I | example_I.fq.gz | DNA-Seq (10X) | NovaSeq |
| J | example_J.fq.gz | DNA-Seq (reverse reads) | NovaSeq |
| K | example_K.fq.gz | ancientDNA | MiSeq |
| L | example_L.fq.gz | Amp-Seq | unknown |
| M | example_M.fq.gz | Amp-Seq | MiSeq |
Quality Control
For quality control we use two complementary tools:
- FastQC provides per-sample read statistics including base quality, GC content, adapter contamination, and duplication levels.
- FastQ Screen aligns a subset of reads against standard databases (ribosomal RNA, adapters, human genome) to give a quick overview of library composition.
Many sequencing facilities provide both outputs. It is important to look at them carefully and in context — a red flag in FastQC does not always indicate a problem, and the interpretation depends on the data type.
Run FastQC on example A:
The FastQ Screen output for all examples has been precomputed (example_A_screen.html). Copy the HTML files to your computer using Cyberduck and open them in a browser.
Challenge 1: Assess example A
Run FastQC on example_A.fq.gz and inspect both the FastQC and FastQ Screen outputs. What do you observe? Is there a quality problem, and if so, what is it?
Solution
Inspect the following modules in the FastQC report:
- Per base sequence quality: does quality drop towards the end of reads?
- Adapter Content: are Illumina adapter sequences present?
- Per base sequence content: is there a bias in the first few bases (common in RNA-Seq due to random priming)?
- Sequence Duplication Levels: high duplication is expected in RNA-Seq and amplicon data but may indicate a problem in DNA-Seq.
The FastQ Screen output shows which fraction of reads map to known contaminants or reference sequences. A high rRNA fraction in an RNA-Seq library suggests insufficient rRNA depletion. Unexpected human or adapter signal may indicate contamination or incomplete library cleaning.
The key question is always: given the data type (RNA-Seq, HiSeq4000), is this pattern expected or problematic?
Quality Filtering
Once you have identified quality issues, the next step is to filter or trim the reads accordingly. A list of all Illumina adapter sequences is available here.
We use BBDuk from the BBTools package. For help with any option, run bbduk.sh -h.
Key BBDuk commands:
## Trim low-quality bases (Q < 15) from both ends and discard reads shorter than 100 bp
bbduk.sh in=example_fq.gz out=example_trim.fq.gz \
qtrim=rl trimq=15 minlength=100
## Remove a specific adapter sequence
bbduk.sh in=example_fq.gz out=example_trim.fq.gz \
literal=AGAGCACACGTCTGAACTCCAGTCACTGACCAATC
## Remove partial adapter matches using k-mer matching
bbduk.sh in=example_fq.gz out=example_trim.fq.gz \
literal=AGAGCACACGTCTGAACTCCAGTCACTGACCAATC ktrim=r k=23 mink=11
## Combined: adapter trimming + quality trimming + length filter
bbduk.sh in=example_fq.gz out=example_trim.fq.gz \
literal=AGAGCACACGTCTGAACTCCAGTCACTGACCAATC ktrim=r k=23 mink=11 \
qtrim=rl trimq=15 minlength=100
Why k-mer matching?
In most cases, adapter sequences are only partially present at the end of a read because the insert is shorter than the read length. The ktrim=r k=23 mink=11 settings tell BBDuk to trim any right-end sequence that matches the adapter with a k-mer of at least 11 bases. This is more sensitive than requiring a full-length adapter match.
Challenge 2: Filter example A
Based on the problems you identified in Challenge 1, design a BBDuk command to clean example_A.fq.gz. Run FastQC again on the filtered output and check whether the issue has been resolved.
Solution
Identify the adapter sequence from the FastQC Adapter Content module or from the Illumina adapter list. Then run BBDuk with appropriate settings, for example:
bbduk.sh in=example_A.fq.gz out=example_A_trim.fq.gz \
literal=AGAGCACACGTCTGAACTCCAGTCACTGACCAATC ktrim=r k=23 mink=11 \
qtrim=rl trimq=15 minlength=100
Run FastQC on the trimmed file to confirm:
A successful run will show reduced or absent adapter signal in the Adapter Content module and improved per-base quality at read ends. Note that the per-base sequence content bias at the 5' end is a known artefact of random hexamer priming in RNA-Seq and cannot be removed by trimming — it is expected and does not need to be corrected.
Challenge 3: Try fastp as an alternative
fastp performs adapter detection, quality trimming, and filtering automatically in a single step without requiring you to specify adapter sequences. Run it on example A and compare the output with your BBDuk result.
Solution
fastp auto-detects adapters by analysing k-mer frequencies near read ends and applies quality trimming with sensible defaults. It produces an HTML report (fastp.html) and a JSON summary automatically.
Compare the FastQC outputs for example_A_trim.fq.gz (BBDuk) and example_A_fastp.fq.gz (fastp). Both should show similar improvements. Differences may arise in edge cases such as very short adapter fragments or reads near the minimum length threshold.
fastp is faster than BBDuk for most use cases and requires less manual configuration. BBDuk offers more fine-grained control, which can be important for non-standard library types or when you need to match a specific published protocol.
Some suggestions for interpreting the results are available here.
Additional Resources
