bio-bam-statistics
Generate alignment statistics using samtools flagstat, stats, depth, coverage, and mosdepth. Use when assessing alignment quality, calculating coverage, or generating QC reports.
npx skills add BioTender-max/awesome-bio-agent-skills --skill bam-statistics --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
## Version Compatibility Reference examples tested with: pysam 0.22+, samtools 1.19+ Before using code patterns, verify installed versions match. If versions differ: - Python: `pip show <package>` then `help(module.function)` to check signatures - CLI: `<tool> --version` then `<tool> --help` to confirm flags If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying. # BAM Statistics **"Get alignment statistics and coverage from my BAM file"** → Generate read counts, mapping rates, per-chromosome statistics, depth profiles, and coverage summaries. - CLI: `samtools flagstat`, `samtools stats`, `samtools depth`, `samtools coverage` (samtools) - Python: `pysam.AlignmentFile` with `pileup()` and `get_index_statistics()` (pysam) Generate alignment statistics using samtools and pysam. ## Quick Summary Commands | Question | Best tool | Why | |----------|-----------|-----| | Quick read counts by FLAG category | `samtools flagstat` | Fast; counts secondary+supp in totals | | Per-chromosome counts | `samtools idxstats` | Fast (needs index); **counts secondary+supp** | | Insert size, MAPQ, error
- Version Compatibility
- Quick Summary Commands
- What Each Tool Counts (and Doesn't)
- samtools flagstat
- Multi-threaded
- Output to File
- samtools idxstats
- Parse idxstats
- samtools stats
- View Summary Numbers
- Generate Plots (with plot-bamstats)
- Stats for Specific Region
- samtools depth
- Basic Depth
samtools flagstat input.bam
samtools flagstat -@ 4 input.bam
samtools flagstat input.bam > flagstat.txt
samtools idxstats input.bam
Total mapped reads
samtools idxstats input.bam | awk '{sum += $3} END {print sum}'
Mitochondrial percentage
samtools idxstats input.bam | awk '
END {print mt/total*100 "% mitochondrial"}'
samtools stats input.bam > stats.txtWhat does the bio-bam-statistics skill do?
Generate alignment statistics using samtools flagstat, stats, depth, coverage, and mosdepth. Use when assessing alignment quality, calculating coverage, or generating QC reports.
How do I install it?
Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill bam-statistics --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From BioTender-max/awesome-bio-agent-skills, a repository with 135 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
