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.
samtools quickcheck -v sample.bam
If the BAM or CRAM file is incomplete or corrupted, this will print a warning.
Ensure your index file exists (e.g., sample.bam.bai or sample.cram.crai) and matches the content.
samtools view -H sample.bam
This verifies the file is readable and shows reference info, read groups, etc.
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!
If samtools idxstats returns no entries for some chromosomes, your index file might be outdated or incorrectly built. Reindex with:
samtools index sample.bam