How to Quality Check CRAM/BAM Files Using Samtools

Posted on June 10, 2025

Before using BAM or CRAM files for downstream analysis like variant calling, it's critical to ensure they are complete and properly indexed. Here's a quick checklist and commands you can use to verify the integrity of your alignment files using samtools.

1. Check File Integrity

samtools quickcheck -v sample.bam

If the BAM or CRAM file is incomplete or corrupted, this will print a warning.

2. Check Index File

Ensure your index file exists (e.g., sample.bam.bai or sample.cram.crai) and matches the content.

3. Print Header

samtools view -H sample.bam

This verifies the file is readable and shows reference info, read groups, etc.

4. Check Read Distribution

samtools idxstats sample.bam

This prints chromosome-level summary (mapped/unmapped reads per contig). If the index is broken or missing contigs, this will highlight the issue. Variant callers rely on this data, so it's essential!

Quick Tip

If samtools idxstats returns no entries for some chromosomes, your index file might be outdated or incorrectly built. Reindex with:

samtools index sample.bam

← Back to Blog