omics.co.in logo omics.co.in

Module 8: Alignment Quality Assessment: Samtools Stats, Depth & Mosdepth Profiling

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 8 of 12 0% Course Completed

1. Key Post-Alignment Quality Indicators

After alignment, bioinformaticians must assess whether reads have mapped uniquely or if repetitive regions have caused multi-mapping artifacts:

  • Mapping Quality (MAPQ): A score of $60$ represents a uniquely anchored alignment with error probability $\le 10^{-6}$. A MAPQ of $0$ indicates the read maps with equal likelihood to two or more identical genomic loci (e.g. segmental duplications).
  • Chimeric / Split Alignments: Reads broken into primary and supplementary alignments. While genuine structural variants create split reads, high chimera rates ($> 5\%$) across the entire genome indicate wet-lab ligation artifacts during library prep.
  • Depth Uniformity: Long-read sequencing demonstrates near-perfect depth uniformity across extreme GC-rich ($> 75\%$) and AT-rich ($< 25\%$) regions, where short-read PCR amplification fails completely.

2. Fast Genome-Wide Coverage Profiling with Mosdepth

Standard samtools depth is computationally prohibitive for high-coverage genomes. mosdepth utilizes window-based depth calculation to generate comprehensive coverage profiles in under 2 minutes:

# Run mosdepth with 500 bp windows and targeted exome/amplicon regions
mosdepth \
    --threads 8 \
    --by 500 \
    --fast-mode \
    ./coverage_qc/hg002_ont \
    aligned_sorted.bam

# Review summary statistics
cat ./coverage_qc/hg002_ont.mosdepth.summary.txt

3. Extracting Detailed Alignment Statistics with Samtools

# Generate comprehensive alignment flags and error rate summaries
samtools stats -@ 8 aligned_sorted.bam > alignment_stats.txt

# Extract key summary metrics via grep
grep ^SN alignment_stats.txt | cut -f 2-3 | head -n 20
⚠️

Common Pitfalls & Troubleshooting Checklist

  • Java Heap Exhaustion (GATK / Picard): If processes terminate with java.lang.OutOfMemoryError, set your environment variable explicitly: export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp".
  • Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with samtools index -@ 4 sample.bam.
  • Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority: conda config --set channel_priority strict.
  • Chromosome Naming Contamination: Always verify whether reference FASTA headers use chr1 or 1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.
📝 Propose Edit on GitHub ↗