Almost every sequencing project starts with FASTQ files. They are plain text, which means you can open them, inspect them and catch problems long before they reach an expensive analysis step.
Four lines per read
Each read in a FASTQ file takes exactly four lines:
@A00123:45:HV7KLDSXY:2:1101:12345:1000 1:N:0:ACGTACGT
GATTACAGATTACAGATTACAGATTACA
+
FFFFFFFFF:FFFFFFF,FFFFFFFFFF- Header, starting with
@. For Illumina data it encodes the instrument, run, flow cell, lane, tile and cluster position, then whether this is read 1 or 2, whether it failed the quality filter and the sample index. - Sequence: the bases that were called.
Nmeans the instrument could not decide. - Separator, a single
+, sometimes followed by a copy of the header. - Quality: one character per base, so this line is always exactly as long as the sequence.
Decoding quality scores
Each quality character stores a Phred score, Q = −10·log10(P), where P is the probability that the base call is wrong. Modern files use the Phred+33 encoding: take the character's ASCII code and subtract 33.
| Character | ASCII | Q | Error probability |
|---|---|---|---|
# | 35 | 2 | 63% |
+ | 43 | 10 | 1 in 10 |
5 | 53 | 20 | 1 in 100 |
? | 63 | 30 | 1 in 1,000 |
I | 73 | 40 | 1 in 10,000 |
Recent Illumina instruments bin qualities into a few values, which is why you often see long runs of F (Q37) and : (Q25) rather than a smooth range.
Everyday one-liners
FASTQ files are almost always gzip-compressed. These work directly on the compressed file:
# Look at the first two reads
zcat sample_R1.fastq.gz | head -n 8
# Count reads (lines divided by four)
echo $(( $(zcat sample_R1.fastq.gz | wc -l) / 4 ))
# Read-length distribution
zcat sample_R1.fastq.gz | awk 'NR % 4 == 2 { print length($0) }' | sort -n | uniq -cFor anything more, use a dedicated tool. seqkit stats gives counts, lengths and quality summaries in one command, and FastQC with MultiQC produces the reports everyone expects to see.
Paired-end files
Paired-end runs produce two files, usually named _R1 and _R2. Read number n in one file is the mate of read n in the other, so the files must always have the same number of reads in the same order. If a tool reports mismatched pairs, one file has usually been filtered or truncated on its own.
What to check before you go further
- Read counts match between R1 and R2, and roughly match what the facility reported.
- Quality drops towards the end of reads are normal; low quality across the whole read is not.
- Adapter content rising along the read means fragments were short. Trim before aligning.
- High duplication can be expected (RNA-seq of highly expressed genes) or a sign of low input.
Terms like Phred, adapter and duplicate reads are explained in the glossary.