Samtools: IdxStats

Chromosome-wise read statistics (mapped & unmapped).

Accepted: .sam, .bam, .cram

samtools idxstats

Function:

samtools idxstats provides alignment statistics for each reference sequence (chromosome, contig, scaffold, etc.) present in an indexed BAM or CRAM file. It reports the number of mapped and unmapped reads associated with each reference, allowing users to quickly assess sequencing coverage and read distribution across the genome.

Input Format:

  • BAM File (.bam)
  • CRAM File (.cram)
  • Input files must be indexed using samtools index.

Output Format:

  • Tab-delimited text file.
  • Four output columns:
    • Reference Sequence Name
    • Reference Length
    • Mapped Reads
    • Unmapped Reads

Example Usage:

# Generate idxstats report
samtools idxstats sample.bam

# Save output to file
samtools idxstats sample.bam > idxstats.txt

# Run on CRAM file
samtools idxstats sample.cram

Output Example:

chr1    248956422    1256789    1254
chr2    242193529    1185423    1102
chr3    198295559    1056321     986
*       0              0        4521

The output shows the chromosome name, chromosome length, number of mapped reads, and number of unmapped reads. The * row summarizes reads that are not assigned to any reference sequence.

Applications:

  • Assess sequencing coverage across chromosomes.
  • Perform alignment quality control (QC).
  • Identify uneven read distribution.
  • Validate genome assemblies and reference mapping.
  • Detect contamination or unexpected alignments.
  • Generate summary reports for sequencing projects.

Advantages:

  • Fast summary generation using BAM/CRAM indexes.
  • Minimal computational resources required.
  • Useful for quick dataset assessment.
  • Supports both BAM and CRAM formats.
  • Easy integration into bioinformatics pipelines.

Suggested Reading:

Official Samtools Documentation: Samtools Idxstats Manual

Citation:

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