Samtools: Flagstat

Accepted format: .sam, .bam, .cram

samtools flagstat

Function:

samtools flagstat is a command-line utility that provides a quick summary of alignment statistics from SAM, BAM, or CRAM files. It counts reads belonging to different FLAG categories and reports important metrics such as mapped reads, properly paired reads, duplicates, and supplementary alignments.

Input Format:

  • SAM (Sequence Alignment/Map) file
  • BAM (Binary Alignment/Map) file
  • CRAM (Compressed Reference-oriented Alignment Map) file

Output Format:

  • Text-based alignment statistics report containing:
    • Total reads
    • Mapped reads
    • Properly paired reads
    • Duplicate reads
    • Singleton reads
    • Secondary alignments
    • Supplementary alignments

Example Output:

100000 + 0 in total
95000 + 0 mapped
92000 + 0 properly paired
3000 + 0 duplicates
500 + 0 singletons

Output Explanation:

  • Total Reads: Total number of reads present in the alignment file.
  • Mapped Reads: Reads successfully aligned to the reference genome.
  • Properly Paired Reads: Paired-end reads aligned according to expected orientation and insert size.
  • Duplicate Reads: Reads marked as PCR or optical duplicates.
  • Singleton Reads: Reads where only one mate of a pair is mapped.
  • Secondary/Supplementary Alignments: Additional alignments associated with the same read.

Applications:

  • Alignment quality assessment.
  • Sequencing data quality control (QC).
  • Evaluating mapping efficiency.
  • Detecting duplicate reads.
  • Checking paired-end alignment statistics.
  • Preparing reports for downstream analysis.

Suggested Reading:

Official Samtools Manual Pages: Samtools Flagstat Manual

Citation:

If you use samtools flagstat in your work, please cite the following reference:

Li, H., Handsaker, B., Wysoker, A., Fennell, T., Ruan, J., Homer, N., et al. (2009). The Sequence Alignment/Map (SAM) format and SAMtools. Bioinformatics, 25(16), 2078–2079. doi:10.1093/bioinformatics/btp352