FASTQ format explained

FASTQ format
Extensions:-->
Developer:Wellcome Trust Sanger Institute
Released:~2000
Genre:Bioinformatics
Extended From:ASCII and FASTA format
Standards:-->

FASTQ format is a text-based format for storing both a biological sequence (usually nucleotide sequence) and its corresponding quality scores. Both the sequence letter and quality score are each encoded with a single ASCII character for brevity.

It was originally developed at the Wellcome Trust Sanger Institute to bundle a FASTA formatted sequence and its quality data, but has become the de facto standard for storing the output of high-throughput sequencing instruments such as the Illumina Genome Analyzer.[1]

Format

A FASTQ file has four line-separated fields per sequence:

A FASTQ file containing a single sequence might look like this:

@SEQ_ID
GATTTGGGGTTCAAAGCAGTATCGATCAAATAGTAAATCCATTTGTTCAACTCACAGTTT
+
!''*((((***+))%%%++)(%%%%).1***-+*''))**55CCF>>>>>>CCCCCCC65

The byte representing quality runs from 0x21 (lowest quality; '!' in ASCII) to 0x7e (highest quality; '~' in ASCII).Here are the quality value characters in left-to-right increasing order of quality (ASCII):

!"#$%&'*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

The original Sanger FASTQ files split long sequences and quality strings over multiple lines, as is typically done for FASTA files. Accounting for this makes parsing more complicated due to the choice of "@" and "+" as markers (as these characters can also occur in the quality string). Multi-line FASTQ files (and consequently multi-line FASTQ parsers) are less common now that the majority of sequencing carried out is short-read Illumina sequencing, with typical sequence lengths of around 100bp.

Illumina sequence identifiers

Sequences from the Illumina software use a systematic identifier:

HWUSI-EAS100Rthe unique instrument name
6flowcell lane
73tile number within the flowcell lane
941'x'-coordinate of the cluster within the tile
1973'y'-coordinate of the cluster within the tile
  1. 0
index number for a multiplexed sample (0 for no indexing)
/1the member of a pair, /1 or /2 (paired-end or mate-pair reads only)

Versions of the Illumina pipeline since 1.4 appear to use #NNNNNN instead of #0 for the multiplex ID, where NNNNNN is the sequence of the multiplex tag.

With Casava 1.8 the format of the '@' line has changed:

EAS139the unique instrument name
136the run id
FC706VJthe flowcell id
2flowcell lane
2104tile number within the flowcell lane
15343'x'-coordinate of the cluster within the tile
197393'y'-coordinate of the cluster within the tile
1the member of a pair, 1 or 2 (paired-end or mate-pair reads only)
YY if the read is filtered (did not pass), N otherwise
180 when none of the control bits are on, otherwise it is an even number
ATCACGindex sequence

Note that more recent versions of Illumina software output a sample number (defined by the order of the samples in the sample sheet) in place of an index sequence when an index sequence is not explicitly specified for a sample in the sample sheet. For example, the following header might appear in a FASTQ file belonging to the first sample of a batch of samples:

NCBI Sequence Read Archive

FASTQ files from the INSDC Sequence Read Archive often include a description, e.g.

In this example there is an NCBI-assigned identifier, and the description holds the original identifier from Solexa/Illumina (as described above) plus the read length. Sequencing was performed in paired-end mode (~500bp insert size), see SRR001666. The default output format of fastq-dump produces entire spots, containing any technical reads and typically single or paired-end biological reads.

$ fastq-dump.2.9.0 -Z -X 2 SRR001666Read 2 spots for SRR001666Written 2 spots for SRR001666@SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=72GGGTGATGGCCGCTGCCGATGGCGTCAAATCCCACCAAGTTACCCTTAACAACTTAAGGGTTTTCAAATAGA+SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=72IIIIIIIIIIIIIIIIIIIIIIIIIIIIII9IG9ICIIIIIIIIIIIIIIIIIIIIDIIIIIII>IIIIII/@SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=72GTTCAGGGATACGACGTTTGTATTTTAAGAATCTGAAGCAGAAGTCGATGATAATACGCGTCGTTTTATCAT+SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=72IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII6IBIIIIIIIIIIIIIIIIIIIIIIIGII>IIIII-I)8I

Modern usage of FASTQ almost always involves splitting the spot into its biological reads, as described in submitter-provided metadata:

$ fastq-dump -X 2 SRR001666 --split-3Read 2 spots for SRR001666Written 2 spots for SRR001666$ head SRR001666_1.fastq SRR001666_2.fastq

> SRR001666_1.fastq <

@SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36GGGTGATGGCCGCTGCCGATGGCGTCAAATCCCACC+SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36IIIIIIIIIIIIIIIIIIIIIIIIIIIIII9IG9IC@SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36GTTCAGGGATACGACGTTTGTATTTTAAGAATCTGA+SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII6IBI

> SRR001666_2.fastq <

@SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36AAGTTACCCTTAACAACTTAAGGGTTTTCAAATAGA+SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36IIIIIIIIIIIIIIIIIIIIDIIIIIII>IIIIII/@SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36AGCAGAAGTCGATGATAATACGCGTCGTTTTATCAT+SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36IIIIIIIIIIIIIIIIIIIIIIGII>IIIII-I)8I

When present in the archive, fastq-dump can attempt to restore read names to original format. NCBI does not store original read names by default:

$ fastq-dump -X 2 SRR001666 --split-3 --origfmtRead 2 spots for SRR001666Written 2 spots for SRR001666$ head SRR001666_1.fastq SRR001666_2.fastq

> SRR001666_1.fastq <

@071112_SLXA-EAS1_s_7:5:1:817:345GGGTGATGGCCGCTGCCGATGGCGTCAAATCCCACC+071112_SLXA-EAS1_s_7:5:1:817:345IIIIIIIIIIIIIIIIIIIIIIIIIIIIII9IG9IC@071112_SLXA-EAS1_s_7:5:1:801:338GTTCAGGGATACGACGTTTGTATTTTAAGAATCTGA+071112_SLXA-EAS1_s_7:5:1:801:338IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII6IBI

> SRR001666_2.fastq <

@071112_SLXA-EAS1_s_7:5:1:817:345AAGTTACCCTTAACAACTTAAGGGTTTTCAAATAGA+071112_SLXA-EAS1_s_7:5:1:817:345IIIIIIIIIIIIIIIIIIIIDIIIIIII>IIIIII/@071112_SLXA-EAS1_s_7:5:1:801:338AGCAGAAGTCGATGATAATACGCGTCGTTTTATCAT+071112_SLXA-EAS1_s_7:5:1:801:338IIIIIIIIIIIIIIIIIIIIIIGII>IIIII-I)8I

In the example above, the original read names were used rather than the accessioned read name. NCBI accessions runs and the reads they contain. Original read names, assigned by sequencers, are able to function as locally unique identifiers of a read, and convey exactly as much information as a serial number. The ids above were algorithmically assigned based upon run information and geometric coordinates. Early SRA loaders parsed these ids and stored their decomposed components internally. NCBI stopped recording read names because they are frequently modified from the vendors' original format in order to associate some additional information meaningful to a particular processing pipeline, and this caused name format violations that resulted in a high number of rejected submissions. Without a clear schema for read names, their function remains that of a unique read id, conveying the same amount of information as a read serial number. See various SRA Toolkit issues for details and discussions.

Also note that fastq-dump converts this FASTQ data from the original Solexa/Illumina encoding to the Sanger standard (see encodings below). This is because the SRA serves as a repository for NGS information, rather than format. The various *-dump tools are capable of producing data in several formats from the same source. The requirements for doing so have been dictated by users over several years, with the majority of early demand coming from the 1000 Genomes Project.

Variations

Quality

A quality value Q is an integer mapping of p (i.e., the probability that the corresponding base call is incorrect). Two different equations have been in use. The first is the standard Sanger variant to assess reliability of a base call, otherwise known as Phred quality score:

Qsanger=-10log10p

The Solexa pipeline (i.e., the software delivered with the Illumina Genome Analyzer) earlier used a different mapping, encoding the odds p/(1-p) instead of the probability p:

Qsolexa-priortov.1.3=-10log10

p
1-p
Although both mappings are asymptotically identical at higher quality values, they differ at lower quality levels (i.e., approximately p > 0.05, or equivalently, Q < 13).

At times there has been disagreement about which mapping Illumina actually uses. The user guide (Appendix B, page 122) for version 1.4 of the Illumina pipeline states that: "The scores are defined as, where is the probability of a base call corresponding to the base in question".[2] In retrospect, this entry in the manual appears to have been an error. The user guide (What's New, page 5) for version 1.5 of the Illumina pipeline lists this description instead: "Important Changes in Pipeline v1.3 . The quality scoring scheme has changed to the Phred [i.e., Sanger] scoring scheme, encoded as an ASCII character by adding 64 to the Phred value. A Phred score of a base is:

Qphred=-10log10e

, where e is the estimated probability of a base being wrong.[3]

Encoding

@HWI-EAS209_0006_FC706VJ:5:58:5894:21141#ATCACG/1
TTAATTGGTAAATAAATCTCCTAATAGCTTAGATNTTACCTTNNNNNNNNNNTAGTTTCTTGAGATTTGTTGGGGGAGACATTTTTGTGATTGCCTTGAT
+HWI-EAS209_0006_FC706VJ:5:58:5894:21141#ATCACG/1
efcfffffcfeefffcffffffddf`feed]`]_Ba_^__[YBBBBBBBBBBRTT\]][]dddd`ddd^dddadd^BBBBBBBBBBBBBBBBBBBBBBBB

An alternative interpretation of this ASCII encoding has been proposed.[11] Also, in Illumina runs using PhiX controls, the character 'B' was observed to represent an "unknown quality score". The error rate of 'B' reads was roughly 3 phred scores lower the mean observed score of a given run.

For raw reads, the range of scores will depend on the technology and the base caller used, but will typically be up to 41 for recent Illumina chemistry. Since the maximum observed quality score was previously only 40, various scripts and tools break when they encounter data with quality values larger than 40. For processed reads, scores may be even higher. For example, quality values of 45 are observed in reads from Illumina's Long Read Sequencing Service (previously Moleculo).

SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS..................................................... ..........................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...................... ...............................IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII...................... .................................JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ..................... LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.................................................... NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN........................................... EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP !"#$%&'*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz
~ | | | | | | | 33 59 64 73 88 104 126 0........................26...31.......40 -5....0........9.............................40 0........9.............................40 3.....9..............................41 0.2......................26...31........41 0..................20........30........40........50 0..................20........30........40........50...55 0..................20........30........40........50..........................................93S - Sanger Phred+33, raw reads typically (0, 40) X - Solexa Solexa+64, raw reads typically (-5, 40) I - Illumina 1.3+ Phred+64, raw reads typically (0, 40) J - Illumina 1.5+ Phred+64, raw reads typically (3, 41) with 0=unused, 1=unused, 2=Read Segment Quality Control Indicator (bold) (Note: See discussion above). L - Illumina 1.8+ Phred+33, raw reads typically (0, 41) N - Nanopore Phred+33, Duplex reads typically (0, 50) E - ElemBio AVITI Phred+33, raw reads typically (0, 55) P - PacBio Phred+33, HiFi reads typically (0, 93)

Color space

For SOLiD data, the format is modified to a color space FASTQ sequence (CSFASTQ), where bases in the sequence are combined with the numbers 0, 1, 2, and 3, indicating how bases are modified relative to the previous base in the sequence (0: no change; 1: transition; 2: non-complementary transversion; 3: complementary transversion). This format matched the different sequencing chemistry used by SOLiD sequencers. Initial representations only used nucleotide bases at the start of the sequence, but later versions included bases embedded at periodic intervals to improve basecalling and mapping accuracy.

The quality values for CSFASTQ are identical to those of the Sanger format. Alignment tools differ in their preferred version of the quality values: some include a quality score (set to 0, i.e. '!') for the leading nucleotide, others do not. The sequence read archive includes this quality score.

FAST5 and HDF5 evolutions

The FAST4 format was invented as a derivative of the FASTQ format where each of the 4 bases (A,C,G,T) had separate probabilities stored. It was part of the Swift basecaller, an open source package for primary data analysis on next-gen sequence data "from images to basecalls".

The FAST5 format was invented as an extension of the FAST4 format. The FAST5 files are Hierarchical Data Format 5 (HDF5) files with a specific schema defined by Oxford Nanopore Technologies (ONT).[12]

Simulation

FASTQ read simulation has been approached by several tools.[13] [14] A comparison of those tools can be seen here.[15]

Compression

General compressors

General-purpose tools such as Gzip and bzip2 regard FASTQ as a plain text file and result in suboptimal compression ratios. NCBI's Sequence Read Archive encodes metadata using the LZ-77 scheme.General FASTQ compressors typically compress distinct fields (read names, sequences, comments, and quality scores) in a FASTQ file separately; these include DSRC and DSRC2, FQC, LFQC, Fqzcomp, and Slimfastq.

Reads

Having a reference genome around is convenient because then instead of storing the nucleotide sequences themselves, one can just align the reads to the reference genome and store the positions (pointers) and mismatches; the pointers can then be sorted according to their order in the reference sequence and encoded, e.g., with run-length encoding. When the coverage or the repeat content of the sequenced genome is high, this leads to a high compression ratio.Unlike the SAM/BAM formats, FASTQ files do not specify a reference genome. Alignment-based FASTQ compressors supports the use of either user-provided or de novo assembled reference: LW-FQZip uses a provided reference genome and Quip, Leon, k-Path and KIC perform de novo assembly using a de Bruijn graph-based approach.

Explicit read mapping and de novo assembly are typically slow. Reordering-based FASTQ compressors first cluster reads that share long substrings and then independently compress reads in each cluster after reordering them or assembling them into longer contigs, achieving perhaps the best trade-off between the running time and compression rate. SCALCE is the first such tool, followed by Orcom and Mince. BEETL uses a generalized Burrows–Wheeler transform for reordering reads, and HARC achieves better performance with hash-based reordering. AssemblTrie instead assembles reads into reference trees with as few total number of symbols as possible in the reference.[16] [17]

Benchmarks for these tools are available in.[18]

Quality values

Quality values account for about half of the required disk space in the FASTQ format (before compression), and therefore the compression of the quality values can significantly reduce storage requirements and speed up analysis and transmission of sequencing data. Both lossless and lossy compression are recently being considered in the literature. For example, the algorithm QualComp[19] performs lossy compression with a rate (number of bits per quality value) specified by the user. Based on rate-distortion theory results, it allocates the number of bits so as to minimize the MSE (mean squared error) between the original (uncompressed) and the reconstructed (after compression) quality values. Other algorithms for compression of quality values include SCALCE[20] and Fastqz.[21] Both are lossless compression algorithms that provide an optional controlled lossy transformation approach. For example, SCALCE reduces the alphabet size based on the observation that “neighboring” quality values are similar in general. For a benchmark, see.[22]

As of the HiSeq 2500 Illumina gives the option to output qualities that have been coarse grained into quality bins. The binned scores are computed directly from the empirical quality score table, which is itself tied to the hardware, software and chemistry that were used during the sequencing experiment.[23]

File extension

There is no standard file extension for a FASTQ file, but .fq and .fastq are commonly used.

Format converters

See also

External links

Notes and References

  1. Cock . P. J. A. . Fields . C. J. . Goto . N. . Heuer . M. L. . Rice . P. M. . The Sanger FASTQ file format for sequences with quality scores, and the Solexa/Illumina FASTQ variants . 10.1093/nar/gkp1137 . Nucleic Acids Research . 38 . 6 . 1767–1771 . 2009 . 20015970 . 2847217 .
  2. Sequencing Analysis Software User Guide: For Pipeline Version 1.4 and CASAVA Version 1.0, dated April 2009 PDF
  3. Sequencing Analysis Software User Guide: For Pipeline Version 1.5 and CASAVA Version 1.0, dated August 2009 PDF
  4. Sequence/Alignment Map format Version 1.0, dated August 2009 PDF
  5. Seqanswer's topic of skruglyak, dated January 2011 website
  6. Elembio AVITI FASTQ format specification https://docs.elembio.io/docs/bases2fastq/outputs/#quality-scores
  7. PacBio BAM format specification 10.0.0 https://pacbiofileformats.readthedocs.io/en/10.0/BAM.html#qual
  8. Dorado duplex basecalling guide [duplex-tools: usage with dorado https://github.com/nanoporetech/duplex-tools#usage-with-dorado-recommended]
  9. Illumina Quality Scores, Tobias Mann, Bioinformatics, San Diego, Illumina http://seqanswers.com/forums/showthread.php?t=4721
  10. Using Genome AnalyzerSequencing Control Software, Version 2.6, Catalog # SY-960-2601, Part # 15009921 Rev. A, November 2009 http://watson.nci.nih.gov/solexa/Using_SCSv2.6_15009921_A.pdf
  11. https://web.archive.org/web/20110724075950/http://solexaqa.sourceforge.net/questions.htm SolexaQA project website
  12. Web site: Introduction_to_Fast5_files . 2022-05-19 . labs.epi2me.io.
  13. 22199392. 3278762. 2012. Huang. W. ART: A next-generation sequencing read simulator. Bioinformatics. 28. 4. 593–4. Li. L. Myers. J. R.. Marth. G. T.. 10.1093/bioinformatics/btr708.
  14. 24433564. 3927261. 2014. Pratas. D. XS: A FASTQ read simulator. BMC Research Notes. 7. 40. Pinho. A. J.. Rodrigues. J. M.. 10.1186/1756-0500-7-40 . free .
  15. 10.1038/nrg.2016.57. 27320129. A comparison of tools for the simulation of genomic next-generation sequencing data. Nature Reviews Genetics. 17. 8. 459–69. 2016. Escalona. Merly. Rocha. Sara. Posada. David. 5224698.
  16. Ginart AA, Hui J, Zhu K, Numanagić I, Courtade TA, Sahinalp SC . etal. Optimal compressed representation of high throughput sequence data via light assembly. . Nat Commun . 2018 . 9 . 1 . 566 . 29422526 . 10.1038/s41467-017-02480-6 . 5805770 . 2018NatCo...9..566G.
  17. Book: Zhu . Kaiyuan . Numanagić . Ibrahim . Sahinalp . S. Cenk . Encyclopedia of Big Data Technologies . Genomic Data Compression . Springer International Publishing . Cham . 2018 . 978-3-319-63962-8 . 10.1007/978-3-319-63962-8_55-1 . 779–783. 61153904 .
  18. Numanagić . Ibrahim . Bonfield . James K . Hach . Faraz . Voges . Jan . Ostermann . Jörn . Alberti . Claudio . Mattavelli . Marco . Sahinalp . S Cenk . Comparison of high-throughput sequencing data compression tools . Nature Methods . Springer Science and Business Media LLC . 13 . 12 . 2016-10-24 . 1548-7091 . 10.1038/nmeth.4037 . 1005–1008. 27776113 . 205425373 .
  19. 10.1186/1471-2105-14-187. 23758828. 3698011. Qual Comp: A new lossy compressor for quality scores based on rate distortion theory. BMC Bioinformatics. 14. 187. 2013. Ochoa. Idoia. Asnani. Himanshu. Bharadia. Dinesh. Chowdhury. Mainak. Weissman. Tsachy. Yona. Golan . free .
  20. 23047557. 3509486. 2012. Hach. F. SCALCE: Boosting sequence compression algorithms using locally consistent encoding. Bioinformatics. 28. 23. 3051–7. Numanagic. I. Alkan. C. Sahinalp. S. C.. 10.1093/bioinformatics/bts593.
  21. fastqz.http://mattmahoney.net/dc/fastqz/
  22. M. Hosseini, D. Pratas, and A. Pinho. 2016. A survey on data compression methods for biological sequences. Information 7(4):(2016): 56
  23. Illumina Tech Note.http://www.illumina.com/content/dam/illumina-marketing/documents/products/technotes/technote_understanding_quality_scores.pdf