Week 4 – Lecture A
Jelmer Poelstra
2026-09-14
DNA and protein (amino acid) sequences, as well as sequence annotations, are mostly stored in plain-text formats. Some of the most common types, which you’ll work with in this course, are:
FASTA
Simple sequence files, where each entry contains a header and a sequence.
Versatile: may contain a few short sequences, genome assemblies, proteomes, etc.
FASTQ
The standard format for HTS reads.
Differs from FASTA, e.g., by including a quality score for each nucleotide.
GTF/GFF
A (genome) annotation format.
A table with coordinates of, e.g., genes and exons.
Another common pair is SAM/BAM, e.g. produced when aligning reads to a genome.
FASTA files contain one or more DNA or amino acid sequences,
with no limits on the number of sequences or the sequence lengths.
The following example FASTA file contains two entries:
Each entry contains a header and the sequence itself, where:
>” and provide identifying information (metadata) for the sequence.FASTA files most commonly have a .fa or .fasta file extension. Also used are extensions that make explicit whether the file contains nucleotide (.fna) or amino acid sequences (.faa).
FASTQ is the standard format for HTS reads. Each read forms one FASTQ entry and is represented by four lines, which contain, respectively:
@ and uniquely identifies the read+The quality scores represent an estimate of the error probability of the base call.
Specifically, they correspond to a numeric “Phred” quality score (\(Q\)), which is a function of the estimated probability that a base call is erroneous (\(P\)):
\[ Q = -10 \log_{10}(P) \]Some specific probabilities and their rough qualitative interpretation for Illumina data:
| Phred score | Error probability | Rough interpretation | ASCII character |
|---|---|---|---|
| 10 | 1 in 10 | terrible | |
| 20 | 1 in 100 | bad/mediocre | |
| 30 | 1 in 1,000 | good | |
| 40 | 1 in 10,000 | excellent |
Single-character representation
The numeric Phred quality score is represented in FASTQ files not by the number itself, but by a corresponding “ASCII character”.
This allows for a single-character representation of each possible score — therefore, each quality score character can correspond to (and line up with) a base character in the read.
| Phred score | Error probability | Rough interpretation | ASCII character |
|---|---|---|---|
| 10 | 1 in 10 | terrible | + |
| 20 | 1 in 100 | bad/mediocre | 5 |
| 30 | 1 in 1,000 | good | ? |
| 40 | 1 in 10,000 | excellent | I |
Single-character representation
The numeric Phred quality score is represented in FASTQ files not by the number itself, but by a corresponding “ASCII character”.
This allows for a single-character representation of each possible score — therefore, each quality score character can correspond to (and line up with) a base character in the read.
What do quality scores mean in practice?
In a 100-bp read, how many errors do you expect if:
Even at Q30, a file with 500,000 such reads contains around 50,000 incorrect bases — one reason why we check read quality and trim reads before analysis.
Rather than putting all reads into a single FASTQ file, separate files are typically used for:
Each read direction (for paired-end data)
| Read direction | File name identifier |
|---|---|
| Forward | _R1 |
| Reverse | _R2 |
Counting reads
Say that file sample1_R1.fastq has 2,000,000 lines.
sample1_R2.fastq to have?>) instead.Genome annotations go in the highly similar, tabular GTF (.gtf) and GFF (.gff) formats, with:
After a metadata header, the tabular part looks like this (column names added for clarity):
seqname source feature start end score strand frame attributes
NC_068937.1 Gnomon gene 2046 110808 . + . gene_id "LOC120427725"; transcript_id ""; db_xref "GeneID:120427725"; description "homeotic protein deformed"; gbkey "Gene"; gene "LOC120427725"; gene_biotype "protein_coding";
NC_068937.1 Gnomon transcript 2046 110808 . + . gene_id "LOC120427725"; transcript_id "XM_052707445.1"; db_xref "GeneID:120427725"; gbkey "mRNA"; gene "LOC120427725"; model_evidence "Supporting evidence includes similarity to: 25 Proteins"; product "homeotic protein deformed, transcript variant X3"; transcript_biotype "mRNA";
NC_068937.1 Gnomon exon 2046 2531 . + . gene_id "LOC120427725"; transcript_id "XM_052707445.1"; db_xref "GeneID:120427725"; gene "LOC120427725"; model_evidence "Supporting evidence includes similarity to: 25 Proteins"; product "homeotic protein deformed, transcript variant X3"; transcript_biotype "mRNA"; exon_number "1";
NC_068937.1 Gnomon exon 52113 52136 . + . gene_id "LOC120427725"; transcript_id "XM_052707445.1"; db_xref "GeneID:120427725"; gene "LOC120427725"; model_evidence "Supporting evidence includes similarity to: 25 Proteins"; product "homeotic protein deformed, transcript variant X3"; transcript_biotype "mRNA"; exon_number "2";Details for a few columns:
Throughout the course, we will use an example/practice dataset from Garrigós et al. (2025):
This paper uses RNA-Seq data to study gene expression in Culex pipiens mosquitoes infected with avian malaria-causing Plasmodium protozoans — specifically, it compares mosquitoes according to:
The following numbers of biological replicates were used for each treatment combination:
| Control | P. cathemerium | P. relictum | |
|---|---|---|---|
| 24 hpi | 3 | 3 | 4 |
| 10 dpi | 4 | 4 | 4 |
| 21 dpi | 4 | 4 | 3 |
To keep things manageable while practicing, I have subset the data to omit the 21 dpi samples and only keep 500,000 reads per FASTQ file.
All in all, the set of files, available through GitHub, consists of:
We’ll download the reference genome assembly FASTA file separately.
Next slide: steps to obtain a count table from raw reads
Click here to go to the next lecture, Working with files in the Unix shell I