Lesson 2 of 7
Module 5 · Sequencing data
FastQC checks each FASTQ file against a list of common problems and writes a report you open in a browser. Learning to read it is one of the most useful skills in sequencing analysis.
Running FastQC
Quality control (QC) means checking the raw data before you spend hours analysing it. A problem found now, such as a failed sample, a contaminated library or leftover adapter, costs minutes; the same problem found after alignment and statistics costs days and can lead to wrong conclusions. FastQC reads every read in a FASTQ file and runs a series of checks, called modules, each of which looks at one property of the data and gives it a status.
QC sits between the two halves of From sample to reads. The sequencing steps explained there each leave a pattern in the reads, and FastQC is the tool that shows those patterns: falling quality from the loss of step during sequencing, adapter from short fragments, and identical reads from PCR copying during library preparation. When you read a report, ask of each plot which step of library preparation or sequencing could have produced it.
FastQC looks at each file on its own and knows nothing about your genome or your experiment. It cannot tell you that two samples were swapped, that the reads came from the wrong species, or that the treatment worked. Those questions are answered later: the share of reads that align to the genome, in Aligning reads to a genome, is the next check on whether the reads are what you think they are. A clean FastQC report means the reads are well made, not that they are the right reads.
fastqc --outdir qc data/*.fastq.gz ls qc | head -n 4 unzip -p qc/ctrl_1_R1_fastqc.zip ctrl_1_R1_fastqc/summary.txt
What this does
fastqc --outdir qc data/*.fastq.gzchecks all eight FASTQ files, R1 and R2 for each of the four samples, and writes the reports into the qc folder you made in From sample to reads. FastQC does not create the output folder for you, so it must exist first.ls qc | head -n 4lists the first four files it wrote.unzip -pprints one file from inside a zip archive to the screen, without unpacking the archive. The file it prints, summary.txt, is FastQC's one-line-per-module verdict.
Reading the output
- FastQC writes two files per FASTQ file: an .html report to open in a browser, and a .zip archive that holds the same results as plain text for programs to read.
- Each line of the summary has three tab-separated parts: the status, the module name and the file. A status is PASS, WARN (unusual, worth a look) or FAIL (very unusual). For ctrl_1_R1, all ten modules pass.
- Check every file, not only the first. With eight files, opening each report in turn is slow and it is easy to skip one; MultiQC, at the end of this lesson, puts all eight side by side.
Open qc/ctrl_1_R1_fastqc.html in a browser to see the plots. Every module passes here, but the details still matter: mean quality falls from about Q37 at the start of the read to about Q30 at base 100, and adapter content rises towards the end of the read to about 5%.
In the quality plot, each position along the read gets a box summarising the quality of every read at that position: the middle line is the median, the box covers the middle half of the reads, and the whiskers show the spread. The background is coloured green for very good quality (above about Q28), orange for reasonable and red for poor (below Q20). A gentle slope from Q37 to Q30, as here, stays in the green the whole way and is typical of a good run.
The adapter plot shows, for each position, the share of reads in which adapter sequence has started by that position. It can only rise along the read, because once a read has run into adapter it stays in adapter. Ending at about 5% matches the 4.8% you counted with grep in Module 3.
Two more modules are easy to overlook. Per base N content shows how often the sequencer could not decide on a base at each position and wrote N instead. A few Ns are normal; a spike at one position usually means a fault in that sequencing cycle. Per sequence GC content plots the share of G and C bases in each read. For a sample from one organism it forms a single smooth hump, centred near that organism's usual GC content. A second hump, or a shoulder on one side, often means reads from something else, such as bacteria in a cell culture or DNA from another sample.
FastQC is software from the Babraham Institute, written by Simon Andrews. It has no journal paper, so cite it by name, version and web page (the FastQC project page). MultiQC is described by Ewels, Magnusson, Lundin and Käller (2016, Bioinformatics). FastQC's documentation explains each module and its thresholds. Those thresholds are rules of thumb tuned for random genomic DNA, not statistical tests, so “all modules passed” is not by itself evidence of good data. In a methods section, report the versions of both tools and describe any sample you removed, and why.
The modules that matter most
| Module | What it shows | What to do about a problem |
|---|---|---|
| Per base sequence quality | Quality at each position along the reads | Trim low-quality ends (Trimming and filtering) |
| Adapter content | Share of reads running into adapter, by position | Trim adapters (Trimming and filtering) |
| Per base sequence content | A, C, G, T at each position | A wobble in the first ~10 bases is normal for RNA-seq |
| Sequence duplication | How often identical reads occur | High duplication is expected for very abundant RNAs; worrying for DNA |
| Overrepresented sequences | Single sequences making up a large share | Look them up: adapter dimers, ribosomal RNA, contamination |
How to read this table
Each row is one FastQC module. The middle column says what the plot shows, and the last column what a warning usually means and what to do. Several rows say that a flag may be normal; that is the point of the worked example below. Some terms in it:
- A wobble in the first bases is an uneven mix of A, C, G and T at the start of the reads. Many RNA-seq kits start copying RNA at random short sequences, and these do not bind quite evenly, so the first ten or so bases are slightly biased. It does not harm the analysis.
- Because of this wobble, Per base sequence content gives a warning or failure for most RNA-seq libraries. Trimming the first ten bases to make it pass is a common mistake: it throws away good sequence and does not change the counts in any useful way.
- Duplication means reads with exactly the same sequence. In DNA sequencing, many duplicates usually mean the same original molecules were copied over and over during library preparation.
- An adapter dimer is two adapters joined with no sample DNA between them. It sequences as pure adapter and often shows up as an overrepresented sequence.
- Ribosomal RNA is the RNA that builds ribosomes. It is most of the RNA in a cell, so a lot of it in the reads means its removal during library preparation did not work well.
To look up an overrepresented sequence, copy it from the report and search it against a database, as you did with an unknown sequence at the end of Module 4. FastQC already compares each one with a list of common adapters and names the match in the Possible Source column. If that column says No Hit, a similarity search usually tells you within a minute whether it is ribosomal RNA, a very abundant gene or something that should not be there.
Worked example · reading a warning in context
a few genes make up a large share of all mRNA → many reads are identical by chance
→ expected, not a fault; for whole-genome DNA it would suggest a problem
Step by step. Take one very highly expressed gene whose RNA is 1,000 bases long. Reads can start at about 1,000 positions on each strand, so about 2,000 different starting points in all. If that gene receives 100,000 reads, then on average 100,000 ÷ 2,000 = 50 reads start at each point, and many of those will be identical. Nothing went wrong: the gene really is that abundant. In whole-genome sequencing, by contrast, reads are spread over about 3 billion positions, so identical reads should be rare, and many of them point to over-copying of too little starting DNA.
FastQC's thresholds were designed for random genomic DNA. Judge each flag against what your library type should look like.
With many samples, MultiQC (conda install -c bioconda multiqc, then multiqc qc/) gathers every report, and later the trimming and alignment logs, into one page so outlier samples stand out.
MultiQC does not run any analysis itself. It finds the reports and log files that other tools have written in the folders you give it, and draws each measure as one plot with every sample on it. It recognises the output of FastQC, fastp, HISAT2, featureCounts and many other tools, so at the end of this module one MultiQC report can show every step for every sample.
In the MultiQC report, look first at the general statistics table at the top: one row per file, with the number of reads, the share of duplicated reads and the GC content. Then go through the plots looking for the sample that does not follow the others, rather than reading every line of every sample. A sample with half the reads of the rest, a GC curve of a different shape or much more adapter deserves a closer look before you go on.
When you run FastQC again on the trimmed reads from Trimming and filtering, expect two changes. Adapter content should fall to almost nothing, which is the point of trimming. Sequence Length Distribution will probably now show a warning, because FastQC warns whenever the reads in a file are not all the same length, and trimming makes them differ. That warning is the expected result of trimming, not a new problem.
Go deeper: patterns FastQC shows in real runs
Read 2 is usually a little worse than read 1. By the time it is sequenced, the clusters have already been through a full read and the extra copying needed to switch to the other strand, so read 2 quality tends to start lower and fall faster. A modest difference is normal; judge each file against its own partner and against the other samples.
Two other patterns often confuse people. Newer instruments such as the NovaSeq report only a few distinct quality values, so the boxes in the quality plot look flat and blocky; that is a reporting choice, not a fault. A sudden dip at one position in every read of a run, with good quality on either side, usually points to a problem during that single cycle, such as a bubble on the flow cell, rather than to anything in the library.
Key point
Run QC on raw reads and again after trimming. Compare samples with each other: one sample unlike the rest is often more important than any single warning.
For example, suppose seven of eight samples show a small, similar overrepresented sequence, while the eighth has a large share of reads matching ribosomal RNA. Every sample might pass most modules, yet the eighth has far fewer useful reads and may group apart from its replicates later on. Seen side by side in MultiQC, it stands out at once; reading eight reports one at a time, you could easily miss it.
Further reading · Module 5Conesa et al. 2016: the whole RNA-seq workflow, from design to interpretation. · All reading for this course
Check your understanding
1. Adapter content rises towards the end of reads. What causes it?
2. RNA-seq data fail the duplication module. What should you think first?
3. What does MultiQC add?
Up next
Lesson 3
Trimming and filtering