Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Calculate read depth and coverage across genomic intervals using bedtools genomecov and coverage. Generate bedGraph files, compute per-base depth, and summarize coverage statistics. Use when assessing sequencing depth, creating coverage tracks, or evaluating target capture efficiency.
.claude/skills/bio-genome-intervals-coverage-analysis/SKILL.md| Model | Eval pass | Runs |
|---|---|---|
| gemini-3.6-flash | 100% | 12 |
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-09 | ✗→✓ | ▲ Improved | 77% | 0% |
| case-11 | ✓→✓ | = Same ✓ | 75% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 342% | 0% |
| case-16 | ✓→✓ | = Same ✓ | 130% | 0% |
| case-17 | ✓→✓ | = Same ✓ | 226% | 0% |
<!--
#
#
-->
Calculate coverage and depth across genomic regions using bedtools and pybedtools.
bash# Generate bedGraph from BAM (per-base depth) bedtools genomecov -ibam alignments.bam -bg > coverage.bedGraph # Include zero-coverage regions bedtools genomecov -ibam alignments.bam -bga > coverage_with_zeros.bedGraph # Split by strand bedtools genomecov -ibam alignments.bam -bg -strand + > plus_strand.bedGraph bedtools genomecov -ibam alignments.bam -bg -strand - > minus_strand.bedGraph # Scale by total reads (RPM normalization) TOTAL=$(samtools view -c alignments.bam) SCALE=$(echo "scale=10; 1000000/$TOTAL" | bc) bedtools genomecov -ibam alignments.bam -bg -scale $SCALE > normalized.bedGraph # Use only 5' end of reads bedtools genomecov -ibam alignments.bam -bg -5 > five_prime.bedGraph # Use only 3' end of reads bedtools genomecov -ibam alignments.bam -bg -3 > three_prime.bedGraph
bash# Genome-wide coverage histogram bedtools genomecov -ibam alignments.bam > coverage_hist.txt # Output format: chr, depth, bases_at_depth, chr_size, fraction # genome 0 1000000 10000000 0.1 # genome 1 5000000 10000000 0.5 # ...
bash# Coverage from BED intervals bedtools genomecov -i regions.bed -g genome.txt -bg > coverage.bedGraph # BED must be sorted bedtools sort -i regions.bed | bedtools genomecov -i stdin -g genome.txt -bg > coverage.bedGraph
pythonimport pybedtools # From BAM bam = pybedtools.BedTool('alignments.bam') coverage = bam.genome_coverage(bg=True) coverage.saveas('coverage.bedGraph') # With zeros coverage = bam.genome_coverage(bga=True) # Normalized coverage = bam.genome_coverage(bg=True, scale=0.001) # From BED bed = pybedtools.BedTool('regions.bed') coverage = bed.genome_coverage(bg=True, g='genome.txt')
bash# Calculate how much of each region in A is covered by B bedtools coverage -a targets.bed -b reads.bed > coverage_per_target.bed # Output adds 4 columns: overlaps, bases_covered, region_length, fraction # chr1 100 200 region1 5 50 100 0.5 # From BAM bedtools coverage -a targets.bed -b alignments.bam > coverage.bed # Count only (no coverage calculation) bedtools coverage -a targets.bed -b reads.bed -counts > counts.bed
bash# Mean coverage per region bedtools coverage -a targets.bed -b alignments.bam -mean > mean_coverage.bed # Same strand only bedtools coverage -a targets.bed -b alignments.bam -s > same_strand.bed # Report depth at each position (histogram) bedtools coverage -a targets.bed -b alignments.bam -d > per_base.bed # Require minimum overlap bedtools coverage -a targets.bed -b reads.bed -f 0.5 > min_overlap.bed # Split alignments (for RNA-seq) bedtools coverage -a exons.bed -b alignments.bam -split > exon_coverage.bed
pythonimport pybedtools a = pybedtools.BedTool('targets.bed') b = pybedtools.BedTool('alignments.bam') # Basic coverage result = a.coverage(b) # Mean coverage result = a.coverage(b, mean=True) # Counts only result = a.coverage(b, counts=True) # Per-base depth result = a.coverage(b, d=True) result.saveas('coverage.bed')
bash# Count reads in regions across multiple samples bedtools multicov -bams sample1.bam sample2.bam sample3.bam -bed regions.bed > counts.txt # Require mapping quality bedtools multicov -bams sample1.bam sample2.bam -bed regions.bed -q 30 > counts.txt # Split alignments bedtools multicov -bams sample1.bam sample2.bam -bed regions.bed -s -split > counts.txt
pythonimport pybedtools import pandas as pd import numpy as np # Load coverage BED (from bedtools coverage -d) bed = pybedtools.BedTool('per_base_coverage.bed') df = bed.to_dataframe() # Calculate stats per region stats = df.groupby(['chrom', 'start', 'end']).agg({ 'score': ['mean', 'median', 'std', 'max'] }).reset_index() print(stats)
pythonimport pybedtools # Get coverage histogram bam = pybedtools.BedTool('alignments.bam') hist = bam.genome_coverage() # Parse histogram depths = [] fractions = [] for line in open(hist.fn): fields = line.strip().split('\t') if fields[0] == 'genome': depths.append(int(fields[1])) fractions.append(float(fields[4])) # Calculate metrics import numpy as np mean_depth = sum(d * f for d, f in zip(depths, fractions)) print(f'Mean depth: {mean_depth:.1f}x')
bash# Get per-region coverage stats bedtools coverage -a targets.bed -b alignments.bam | \ awk -v OFS='\t' '{ mean = ($NF > 0) ? $5/$6 : 0; print $1, $2, $3, $4, $7, mean }' > summary.bed # Regions with low coverage bedtools coverage -a targets.bed -b alignments.bam | \ awk '$NF < 0.8' > low_coverage.bed
pythonimport pybedtools bam = pybedtools.BedTool('alignments.bam') # Get total reads import subprocess result = subprocess.run(['samtools', 'view', '-c', 'alignments.bam'], capture_output=True, text=True) total_reads = int(result.stdout.strip()) # Generate CPM-normalized bedGraph scale_factor = 1000000 / total_reads coverage = bam.genome_coverage(bg=True, scale=scale_factor) coverage.saveas('cpm_normalized.bedGraph')
bash# Calculate coverage across exons (handling spliced reads) bedtools coverage -a exons.bed -b alignments.bam -split > exon_coverage.bed # Summarize by gene awk -v OFS='\t' '{ gene = $4; gsub(/_exon.*/, "", gene); sum[gene] += $NF * ($3-$2); len[gene] += $3-$2; } END { for (g in sum) print g, sum[g]/len[g]; }' exon_coverage.bed > gene_coverage.txt
# bedGraph: chr, start, end, value (0-based coordinates)
chr1 0 100 0
chr1 100 200 5.5
chr1 200 300 10.2
chr1 300 400 3.1| Tool | Parameter | Description | |------|-----------|-------------| | genomecov -bg | bedGraph | Output bedGraph format | | genomecov -bga | bedGraph all | Include zero coverage | | genomecov -scale | Normalize | Scale values by factor | | coverage -mean | Mean | Report mean coverage | | coverage -d | Per-base | Report per-position depth | | coverage -counts | Count | Count overlaps only | | multicov -q | Quality | Minimum mapping quality |
<!-- AUTHOR_SIGNATURE: 9a7f3c2e-MD-BABU-MIA-2026-MSSM-SECURE -->
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-11 | pass→pass | 8,230 | 1,683 | -80% | 1 | 1 | 0% | 1,431 | 2,505 | +75% | 0 | 0 | — |
case-06 | pass→pass | 3,290 | 3,255 | -1% | 1 | 1 | 0% | 655 | 2,896 | +342% | 0 | 0 | — |
case-16 | pass→pass | 6,302 | 2,927 | -54% | 1 | 1 | 0% | 1,235 | 2,844 | +130% | 0 | 0 | — |
case-17 | pass→pass | 4,564 | 2,891 | -37% | 1 | 1 | 0% | 824 | 2,686 | +226% | 0 | 0 | — |
case-18 | pass→pass | 4,677 | 3,063 | -35% | 1 | 1 | 0% | 863 | 2,887 | +235% | 0 | 0 | — |
case-01 | pass→pass | 3,323 | 2,696 | -19% | 1 | 1 | 0% | 644 | 2,770 | +330% | 0 | 0 | — |
case-02 | fail→fail | 7,240 | 3,518 | -51% | 1 | 1 | 0% | 1,347 | 2,864 | +113% | 0 | 0 | — |
case-03 | pass→pass | 7,966 | 5,235 | -34% | 1 | 1 | 0% | 1,617 | 3,172 | +96% | 0 | 0 | — |
case-04 | pass→pass | 3,057 | 2,204 | -28% | 1 | 1 | 0% | 546 | 2,627 | +381% | 0 | 0 | — |
case-05 | pass→pass | 10,300 | 2,881 | -72% | 1 | 1 | 0% | 1,761 | 2,813 | +60% | 0 | 0 | — |
case-07 | pass→pass | 2,492 | 2,403 | -4% | 1 | 1 | 0% | 371 | 2,606 | +602% | 0 | 0 | — |
case-08 | pass→pass | 8,979 | 7,282 | -19% | 1 | 1 | 0% | 1,703 | 3,753 | +120% | 0 | 0 | — |
case-09 | fail→pass | 9,616 | 4,100 | -57% | 1 | 1 | 0% | 1,722 | 3,040 | +77% | 0 | 0 | — |
case-10 | pass→pass | 4,502 | 3,971 | -12% | 1 | 1 | 0% | 861 | 2,746 | +219% | 0 | 0 | — |
case-12 | pass→pass | 4,593 | 1,793 | -61% | 1 | 1 | 0% | 806 | 2,505 | +211% | 0 | 0 | — |
case-13 | pass→pass | 5,832 | 2,005 | -66% | 1 | 1 | 0% | 1,027 | 2,567 | +150% | 0 | 0 | — |
case-14 | pass→pass | 7,059 | 3,674 | -48% | 1 | 1 | 0% | 1,212 | 2,864 | +136% | 0 | 0 | — |
case-15 | pass→pass | 7,463 | 2,843 | -62% | 1 | 1 | 0% | 1,311 | 2,697 | +106% | 0 | 0 | — |
case-19 | pass→pass | 7,464 | 5,617 | -25% | 1 | 1 | 0% | 1,382 | 3,279 | +137% | 0 | 0 | — |
case-20 | pass→pass | 11,014 | 6,240 | -43% | 1 | 1 | 0% | 2,030 | 3,454 | +70% | 0 | 0 | — |
case-21 | fail→fail | 16,521 | 13,952 | -16% | 1 | 1 | 0% | 2,993 | 5,002 | +67% | 0 | 0 | — |
case-22 | pass→pass | 4,395 | 1,575 | -64% | 1 | 1 | 0% | 814 | 2,517 | +209% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 7/26/2026 | +5% |
Other measured skills in the registry, with their headline benchmark lift.