plot-bamstats
Perl-based visualization tool bundled with samtools for plotting BAM alignment statistics.
Quick Start
- Command:
plot-bamstats [options] file.bam.bc - Local executable:
/home/vimalinx/miniforge3/envs/bio/bin/plot-bamstats - Expected input:
samtools statsoutput, historically calledbamcheck
When To Use This Tool
- Visualizing output from
samtools statsas graphical plots - Generating publication-quality alignment statistic figures
- Merging multiple bamstats files into one stream before plotting
- Incorporating reference GC expectations through
-s/-r
Common Patterns
# 1) Basic BAM QC plotting
samtools stats aln.bam > aln.bam.bc
plot-bamstats -p outdir/ aln.bam.bc
# 2) Merge multiple bamstats files to stdout
plot-bamstats -m sample1.bc sample2.bc > merged.bc
# 3) Prepare reference GC statistics for later plotting
plot-bamstats -s ref.fa
plot-bamstats -p outdir/ -r ref.fa.gc aln.bam.bc
Recommended Workflow
- Produce a clean
samtools statsfile first and keep it alongside the source BAM. - Decide whether you want a fresh plot directory (
-p outdir/) or a simple prefixed file set. - If GC bias matters, precompute reference stats with
-sand pass the resulting.gcfile back with-r. - Inspect the generated PNG/HTML outputs for insert size, coverage, GC, mismatch, and length-shape anomalies.
Guardrails
- Local runtime is currently blocked before normal help or plotting because Perl cannot load
URI::Escape.pm. - The built-in source help says this parser expects
samtools statsoutput, not raw BAM files and notsamtools flagstat. - The script also relies on
gnuplotfor figure generation; plan for both Perl-module and plotting-tool dependencies. --helpcould not be exercised cleanly here because the missing Perl module aborts compilation first; the available option surface was recovered from the script's ownerror()usage block.-mis a merge-to-stdout mode, so do not expect plots when that switch is present.