Skip to content

02. From a Library to FASTQ

Putting a cDNA library into a sequencer produces FASTQ files containing nucleotide sequences and confidence for each character. This lesson follows only the process by which one fragment becomes two FASTQ reads.

Question for this lesson: How does a sequencer read a cDNA fragment, and how does it record how confident each reading is?

Think of a large parallel job that stores a result and execution metadata for every input record. A sequencer processes millions of fragments at once and serializes not only the string read from each fragment but also its physical address and confidence for every character.

Systems viewSequencing equivalent
Work unitOne cluster on the flow cell
Repeated loopCall one base in every cycle
Result dataA, C, G, T, and N string
Observation metadataCluster address and per-base Phred score
Output formatFASTQ record

Suppose an instrument reads 100 bp from each end of a 500 bp fragment. It reads the first 100 bp and the last 100 bp, leaving the middle 300 bp unread.

Reading both ends of one fragment separately is called paired-end sequencing. The two reads share an ID indicating that they came from the same fragment. The first is saved in the R1 file and the second in the R2 file.

The two files are not independent logs; they contain pairs from the same jobs. Records at the same position in R1 and R2 represent opposite ends of one fragment. Deleting or reordering records in only one file breaks that relationship.

Read length is not the length of the original mRNA. It is the length the instrument actually read from the end of the fragment, usually 100 to 150 bp from each end.

This short animation gives an intuitive view of how paired-end sequencing reads both ends of one fragment (Simple Science):

A sequencer does not hold one fragment and read fragments in sequence. It attaches millions of fragments to the surface of a glass chip called a flow cell and photographs them together during the same cycle.

The fluorescence from one fragment molecule is too weak for a camera to distinguish. The attached fragment is therefore copied thousands of times in place, creating a bright spot containing the same sequence. This spot is a cluster. In paired-end sequencing, R1 and R2 are produced from the one library fragment attached in each cluster.

A flow cell is divided into lanes, independent channels through which reagents flow. The camera does not capture an entire lane in one image. It divides the lane into smaller imaging areas called tiles. Use the widget below to move step by step down to the physical address where one fragment sits.

A string such as C5GAPACXX:4:1101:2723:1997 in a FASTQ header records this address.

Header segmentLocation it identifies
C5GAPACXXflow cell ID
4lane number
1101tile number
2723:1997x:y coordinates of the cluster within the tile

Multiple samples can share one lane. Each sample is given a unique index sequence before they are mixed. After reading, FASTQ files are separated again according to the index. These processes are called multiplexing and demultiplexing. The sample-specific FASTQ files we receive have usually already been demultiplexed.

The structure resembles repartitioning distributed-job results by sample_id. An index is itself a short DNA sequence that the instrument reads, so calling errors can occur. Indexes that are too similar can cause a record to be assigned to the wrong sample.

3. Selecting one base from fluorescence signals

Section titled “3. Selecting one base from fluorescence signals”

Suppose only the T signal glows strongly at the first position in a fragment. The instrument records the first character as T. If A and C glow with similar strength at the next position, the instrument still chooses one but records lower confidence.

Illumina instruments repeat a cycle of adding one nucleotide and photographing its fluorescence. Because the sequence is read while it is synthesized, this method is called SBS (sequencing by synthesis).

Illumina’s official animation makes the process inside the instrument much clearer:

Photograph fluorescence → select the strongest base → record the probability that the selection is wrong

Choosing one of A, C, G, and T from the fluorescence is called base calling. If no base can be selected confidently, it is recorded as N.

The Phred quality score Q represents the probability that a base call is wrong. Q30 means an average probability of about one error for every 1,000 bases read under the same conditions.

Phred QError probabilityAccuracy
Q201/10099%
Q301/100099.9%
Q401/1000099.99%

Probability and Phred scores explains why a 10-point increase in Q reduces the error probability by a factor of ten, along with the logarithmic formula.

FASTQ stores Q values as ASCII characters. Because every base has one corresponding quality score, the sequence and quality strings have the same length.

A FASTQ record has four lines.

@read42/1
TACGTTAG
+
IIIII5II

The eight bases on the second line correspond position by position to the eight quality characters on the fourth. You can read sequence[i] together with quality[i] as parallel arrays. The header stores the record ID and instrument address.

The raw FASTQ inspection stage of the RNA-seq exercise examines these four-line records and their quality distributions in real paired-end files.

Instruments such as PacBio and Oxford Nanopore produce long reads. This note focuses on Illumina instruments that produce short paired-end reads.

A sequencer reads both ends of a fragment over multiple cycles. In every cycle, it selects one base from the fluorescence signal and calculates a Phred score for the probability that the choice is wrong.

cDNA fragment → repeated fluorescence imaging and base calling → nucleotide sequence + quality scores → FASTQ

The next lesson, FASTQ quality control and trimming, checks FASTQ quality and prepares reads for alignment.