bio-bam-statistics
БесплатноЗапускает вложенные скриптыНе проверенGenerate alignment statistics using samtools flagstat, stats, depth, coverage, and mosdepth. Use when assessing alignment quality, calculating coverage, or…
от gabrielmoreira★ 23 звезды на GitHubОб этом скилле
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>thenhelp(module.function)to check signatures - CLI:
<tool> --versionthen<tool> --helpto 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.AlignmentFilewithpileup()andget_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, GC | samtools stats -r ref.fa |
Comprehensive; feeds MultiQC |
| Per-position depth (small region) | samtools depth or pysam pileup |
Slow on full genome |
| Per-position depth (genome-wide) | mosdepth |
3-10x faster than samtools depth |
| Per-region coverage (BED) | mosdepth --by regions.bed |
Production default |
| Coverage histogram / cumulative | mosdepth -t 4 --no-per-base |
Single-pass histogram |
| Breadth at depth thresholds | mosdepth --thresholds 1,10,30,100 |
Standard exome QC |
| Targeted enrichment QC | picard CollectHsMetrics |
PCT_OFF_BAIT, FOLD_80_BASE_PENALTY, AT/GC dropout |
| Cross-sample contamination | verifybamid2, somalier |
FREEMIX < 0.01 expected |
What Each Tool Counts (and Doesn't)
| Counting category | flagstat | stats | idxstats |
|---|---|---|---|
| Primary alignments | in total minus supp |
raw total sequences |
mapped column |
| Secondary | secondary line |
filtered out | counted in mapped |
| Supplementary | supplementary line |
filtered out | counted in mapped |
| Mapping rate denominator | total including supp | primary only | mapped+unmapped |
For long-read data where one read produces many supplementary alignments, the senior cross-check:
input_read_count = flagstat_total - secondary - supplementary
= stats_raw_total_sequences
Reports of "the file has 1.2M reads" where the input was actually 800k with 400k supplementary chimeric splits trace to flagstat misinterpretation.
samtools flagstat
Fast summary of alignment flags.
samtools flagstat input.bam
Output:
10000000 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
50000 + 0 supplementary
0 + 0 duplicates
9800000 + 0 mapped (98.00% : N/A)
9950000 + 0 paired in sequencing
4975000 + 0 read1
4975000 + 0 read2
9700000 + 0 properly paired (97.49% : N/A)
9750000 + 0 with itself and mate mapped
100000 + 0 singletons (1.01% : N/A)
25000 + 0 with mate mapped to a different chr
10000 + 0 with mate mapped to a different chr (mapQ>=5)
Multi-threaded
samtools flagstat -@ 4 input.bam
Output to File
samtools flagstat input.bam > flagstat.txt
samtools idxstats
Per-chromosome read counts (requires index).
samtools idxstats input.bam
Output format: chrom length mapped unmapped
chr1 248956422 5000000 1000
chr2 242193529 4800000 800
chrM 16569 50000 100
* 0 0 150000
Parse idxstats
# Total mapped reads
samtools idxstats input.bam | awk '{sum += $3} END {print sum}'
# Mitochondrial percentage
samtools idxstats input.bam | awk '
/^chrM/ {mt = $3}
{total += $3}
END {print mt/total*100 "% mitochondrial"}'
samtools stats
Comprehensive statistics including insert size, base quality, and more.
samtools stats input.bam > stats.txt
View Summary Numbers
samtools stats input.bam | grep "^SN"
Key summary fields:
raw total sequences- Total readsreads mapped- Mapped readsreads mapped and paired- Properly pairedinsert size average- Mean insert sizeinsert size standard deviation- Insert size spreadaverage length- Mean read lengtherror rate- Mismatch rate
Generate Plots (with plot-bamstats)
samtools stats input.bam > stats.txt
plot-bamstats -p plots/ stats.txt
Stats for Specific Region
samtools stats input.bam chr1:1000000-2000000 > region_stats.txt
samtools depth
Per-position read depth.
Basic Depth
samtools depth input.bam > depth.txt
Output: chrom position depth
Depth at Specific Positions
samtools depth -r chr1:1000-2000 input.bam
`
Установить bio-bam-statistics в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл 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.
Как установить скилл bio-bam-statistics?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bio-bam-statistics запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic