Samtools: Index

Accepted format: .sam, .bam, .cram

samtools index

Function:

samtools index is a command-line utility used to create index files for BAM and CRAM alignment files. These indexes enable rapid random access to specific genomic regions without reading the entire alignment file, making downstream analyses and visualization significantly faster.

Input Format:

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

The input alignment file should typically be coordinate-sorted before indexing.

Output Format:

  • BAI File (.bam.bai) for standard BAM files.
  • CSI File (.csi) for very large BAM files requiring extended indexing support.
  • CRAI File (.cram.crai) for CRAM files.

Example Usage:

# Index a BAM file
samtools index sample.bam

# Specify output index file
samtools index -o sample.bai sample.bam

# Create CSI index
samtools index -c sample.bam

# Index a CRAM file
samtools index sample.cram

Applications:

  • Fast retrieval of reads from specific genomic regions.
  • Required for genome browsers such as IGV and JBrowse.
  • Supports efficient variant calling workflows.
  • Enables rapid access in downstream bioinformatics pipelines.
  • Improves performance when processing large alignment files.

Output Example:

sample.bam
sample.bam.bai

After indexing, the generated index file allows tools to jump directly to genomic regions instead of scanning the entire file.

Suggested Reading:

Official Samtools Documentation: Samtools Index Manual

Citation:

If you use samtools index in your work, please cite:

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