Alignment (BWA/Bowtie2) and What the Numbers Mean
Alignment places reads onto a reference genome/transcriptome. You should treat alignment as a probabilistic statement—especially in repeats and low-complexity regions.
- Primary vs secondary alignments for multi-mapping reads
- Soft clipping indicates partial matches (adapters, SVs, errors)
- MAPQ reflects placement ambiguity, not base-call quality
- Proper pair depends on orientation and insert size expectations
Typical commands
# Index reference (BWA)
bwa index reference.fa
# Align paired-end reads
bwa mem -t 8 reference.fa trimmed_R1.fastq.gz trimmed_R2.fastq.gz \
| samtools sort -@ 4 -o sample.bam
# Quick stats
samtools flagstat sample.bam
samtools stats sample.bam | head
| Metric | Interpretation |
|---|---|
| % mapped | Low mapping may indicate contamination, wrong reference, or low quality |
| % duplicates | High duplicates suggest low library complexity or over-amplification |
| Insert size | Unexpected distribution can signal library prep issues |
| Coverage uniformity | Bias suggests GC/capture effects or mapping problems |
High mapping, expected insert sizes, stable coverage.
Low MAPQ reads pile up in repeats; filter carefully.
Mapped and unmapped partition all reads. Proper-pair rate and duplicate rate are separate flagstat lines; they overlap mapped reads and must not be drawn as a fourth slice of 100%.
Always align to the correct genome build and annotation version. For RNA-seq, align to genome + spliced aligner (STAR/HISAT2), or use pseudoalignment (Salmon/Kallisto) to a transcriptome. Mixing builds invalidates coordinates and downstream interpretation.
After samtools flagstat, open a short interval in a genome browser and ask whether the BAM you just made looks like the numbers. IGV is the usual choice; the browser lesson walks the same check. Lightweight aligners such as JapalityAligner are listed next to BWA-MEM2 on the tools page for the index discussion — they do not replace BWA-MEM2 on a production human genome.