shiganluo/skill/bioinformatics-coverage-analysis
Claude Code and agent skill by shiganluo/skill
- community
Checking that the SKILL.md file is still in the repository.
Compute gene body / transcript coverage from BAM files with BED annotations. Covers BED loading, BAM coverage extraction, binning, normalization, and plotting. Use for: gene body coverage, transcript coverage curves, coverage QC, RSeQC-style analysis.
Install
npx vskill@latest install shiganluo/skill/bioinformatics-coverage-analysisSKILL.md
Bioinformatics Coverage Analysis
Core Algorithm
1. BED Loading
BED/TSV files with configurable column names. Group intervals by transcript ID, filter by region type (e.g., exclude UTR, IVS).
Key: exclude_region uses exact string matching via isin(). Values must match exactly (e.g., "UTR" not "5UTR").
2. Gene Model Construction
For each transcript:
- Sort exons by genomic coordinate
- Compute total length = sum(end - start)
- Build exon map: (exon_start, exon_end, transcript_offset)
- Pre-compute bin edges:
np.linspace(0, length, bins+1) - Pre-compute bin widths:
np.diff(edges), clamp to >= 1
3. Coverage Extraction (FAST method)
Use `bam.fetch()` + `read.get_blocks()` — NOT `pysam.pileup()`
pileup() builds PileupColumn objects per position (10-50x slower). fetch() + get_blocks() iterates aligned blocks directly:
4. Vectorized Binning
For negative-strand genes: bin_means = bin_means[::-1] to get 5'→3' direction.
5. Normalization (Option A: per-gene max)
Eliminates expression-level differences, preserves coverage distribution shape.
6. Aggregation
- Per BAM: accumulate across genes, divide by gene count
- Across BAMs: average per-BAM curves
- Output both raw (mean_coverage) and normalized (0-1) curves
CLI Interface
Output
TSV: bin mean_coverage normalized_coverage Plot: line chart, X=percentile (5'→3'), Y=normalized coverage (0-1)
Pitfalls
P1: "Batman ears" curve (high at ends, low in middle)
Cause: UTR or IVS (introns) not excluded from gene body.
Gene structure: [exon][intron][exon][intron]...[exon]
First and last positions always land on exons (high coverage), but middle positions often fall in introns (near-zero coverage).
Fix: --exclude-region UTR IVS
P2: Wrong region column values
exclude_region uses isin() (exact match). If BED has "5UTR"/"3UTR" but you exclude "UTR", nothing gets filtered. Check actual values:
P3: pileup() is the bottleneck
For 1000 genes × 10KB average, pileup takes hours. fetch+blocks takes minutes.
P4: Missing supplementary filter
Always filter is_supplementary alongside is_secondary for coverage counting.
P5: Coverage not normalized
Raw coverage curves are dominated by high-expression genes. Normalize per-gene by max to compare distribution shapes across samples.
Performance
| Approach | Speed | Notes | |
|---|---|---|---|
| pysam.pileup() | 1x | Baseline, very slow | |
| fetch + get_blocks | 10-50x | Recommended | |
| samtools depth (C) | 50-100x | External subprocess | |
| numpy reduceat binning | O(L) vectorized | vs O(bins×L) Python loop |
Multiprocessing: one worker per BAM (not per gene). Genes are pickled to workers.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingbioinformatics/bioinformatics-coverage-analysis/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/shiganluo/skill/bioinformatics-coverage-analysis)