bio-genome-intervals-coverage-analysis
Analyzes genomic sequencing read depth and coverage uniformity for QC and target-capture assessment.
Install
mkdir -p .claude/skills/bio-genome-intervals-coverage-analysis && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11281" && unzip -o skill.zip -d .claude/skills/bio-genome-intervals-coverage-analysis && rm skill.zipInstalls to .claude/skills/bio-genome-intervals-coverage-analysis
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Computes and interprets sequencing read depth and coverage over a genome, windows, or target regions with mosdepth (windowed depth, cumulative distribution, --quantize callable BEDs), bedtools genomecov/coverage (bedGraph tracks, per-target stats), samtools depth/coverage (per-base depth, per-contig depth+breadth). Covers the breadth-vs-mean distinction, the cumulative-coverage curve, evenness (CV/Fano/fold-80/Gini), what each tool silently counts (duplicates, secondary/supplementary, MAPQ, read span vs fragment, mate-overlap), the samtools-depth 8000-cap version trap, and the bedtools coverage -a/-b orientation flip. Use when assessing sequencing adequacy, building coverage tracks, computing breadth at a depth threshold, defining callable regions, or QCing target-capture uniformity.Key capabilities
- →Measure sequencing read depth as a distribution
- →Report median depth instead of mean
- →Report breadth / cumulative-coverage curve
- →Quantify evenness using CV, Fano factor, Picard fold-80, or Gini
- →Specify what was counted in depth numbers
- →Generate bedGraph tracks for genome-wide depth
How it works
This skill computes and interprets sequencing read depth and coverage using tools like mosdepth, bedtools, and samtools. It focuses on reporting median, breadth, and evenness rather than just mean depth.
Inputs & outputs
When to use bio-genome-intervals-coverage-analysis
- →Assess sequencing coverage depth
- →Calculate breadth of coverage
- →QC target capture uniformity
- →Generate coverage tracks
About this skill
Version Compatibility
Reference examples tested with: bedtools 2.31+, mosdepth 0.3+, samtools 1.19+, pybedtools 0.10+, numpy 1.26+.
Before using code patterns, verify installed versions match. If versions differ:
- CLI:
<tool> --versionthen<tool> --helpto confirm flags - Python:
pip show <package>thenhelp(module.function)to check signatures
samtools depth behaviour changed across versions: pre-1.13 capped depth at 8000 and truncated silently (-d 0 = unlimited); 1.13+ rewrote the subcommand with NO cap and -d/-m deprecated/ignored. Always check samtools --version before trusting a max-depth number. If code throws an error, introspect the installed tool and adapt rather than retrying.
Coverage Analysis
"Is my sequencing deep enough to answer the question?" -> Measure depth as a distribution over positions, then report median, breadth at a depth threshold, and an evenness number -- never the mean alone.
- CLI:
mosdepth --by 500 prefix in.bam(windowed depth + cumulative dist),samtools coverage in.bam(per-contig depth+breadth),bedtools genomecov -ibam in.bam -bga(bedGraph track) - Python:
pybedtools.BedTool('in.bam').genome_coverage(bga=True)(pybedtools); parseprefix.mosdepth.global.dist.txtfor the breadth curve
The Single Most Important Modern Insight -- Mean Depth Is a Budget, Not a Result; Report Breadth Off a Cumulative Curve
"30x WGS" describes what was paid for, not what was achieved. Coverage is a distribution over positions, and the mean is its worst summary: it is dragged up by a fat right tail (repeats, rDNA, mitochondria, PCR pileups, segmental dups) while staying blind to a hard left wall of zeros and near-zeros (GC-extreme exons, poorly-mappable regions, capture dropout). Two libraries with identical mean 30x can differ completely -- one even and callable everywhere, one spiky with 20% of the target uncallable. The mean hides both failures. Four load-bearing moves:
- Report MEDIAN, not mean. The median is robust to the right tail. When mean/median exceeds ~1.1-1.2 the distribution is skewed and the mean is overstating typical depth -- that gap is a free evenness diagnostic.
- Report a BREADTH / cumulative-coverage curve. "% of target >= 1x, >= 10x, >= 20x, >= 30x" is the honest summary, because adequacy is a breadth statement: a base that was not covered deeply enough is uncallable no matter how deep the rest of the genome is. mosdepth's
*.mosdepth.global.dist.txtIS this curve. The killer question for any "mean = 30x" claim is "breadth at 20x?". - Quantify EVENNESS (CV, Fano factor, Picard fold-80, or Gini) -- an even 30x and a spiky 30x are different experiments, and a spiky library cannot be rescued by sequencing deeper (extra reads follow the same biased distribution; the holes stay holes). Fix the library (PCR-free, better capture, UMIs), not the lane count.
- Say WHAT WAS COUNTED. A depth number is meaningless until the recipe is stated: duplicates dropped (only if MARKED first)? secondary/supplementary included? MAPQ filter? read span or fragment? mate-overlap corrected? per-base or per-region? The tools disagree on every one of these by default.
Tool Taxonomy
| Tool | Counts what (defaults) | Per-base or region | When |
|---|---|---|---|
| mosdepth | corrects mate-overlap by default (off under --fast-mode/-x); -Q MAPQ filter; emits cumulative dist + summary | windowed (--by), per-region, or callable bins (--quantize) | the modern fast default for WGS/WES/targeted; gives the breadth curve directly |
| samtools coverage | per-reference summary (added 1.10); coverage column = breadth %, meandepth = depth | per-contig | quick "is this contig actually covered?" -- spots high-mean/low-breadth pileups |
| samtools depth | drops UNMAP/SECONDARY/QCFAIL/DUP by default; -Q/-q filters; -s de-double-counts overlap; CRAM needs --reference | per-base | exact per-base depth over small regions; watch the 8000-cap version trap |
| bedtools genomecov | counts READ coverage by default (double-counts mate overlap); -pc = fragment; -split for spliced | per-base / bedGraph / histogram | bedGraph tracks, genome-wide depth histogram |
| bedtools coverage | per-A-interval stats from B reads; -a/-b flipped at v2.24.0 | per-region (or -d per-base) | per-target counts/breadth/mean over a BED |
| Picard CollectHsMetrics | capture-kit QC | per-target panel | exome/panel uniformity: on-target %, fold-80, PCT_TARGET_BASES_20X |
Decision Tree by Scenario
| Scenario | Recommended | Why |
|---|---|---|
| WGS / WES breadth + adequacy | mosdepth --by then parse *.global.dist.txt | emits the cumulative curve + median directly; fast |
| Quick per-contig depth & breadth glance | samtools coverage | one line/contig; coverage col = breadth, meandepth = depth |
| Exact per-base depth, small region | samtools depth -a -r chr:from-to | per-base; add -s for short-insert; check version for 8000 cap |
| bedGraph coverage TRACK for a browser | bedtools genomecov -ibam -bga (or -bg) | -bga marks zero-coverage gaps; convert to bigWig -> bigwig-tracks |
| Per-target counts/breadth/mean over a BED | bedtools coverage -a targets.bed -b in.bam | A = targets, B = reads (post-v2.24.0); -mean for mean depth |
| Callable-region BED (NO/LOW/CALLABLE/HIGH) | mosdepth --quantize 0:1:4:150: | lightweight CallableLoci replacement at scale |
| Target-capture uniformity QC | -> Picard CollectHsMetrics (fold-80, on-target %) | the capture-QC standard; off-target loss + bait unevenness |
| Spliced/RNA-seq depth | add -split (genomecov/coverage) | without it an intron (N CIGAR) is counted as covered |
| Short-insert VAF (amplicon/cfDNA) | correct mate-overlap: samtools depth -s / genomecov -pc / mosdepth default | naive per-base double-counts the overlap, corrupting VAFs |
| Normalized cross-sample track | -> chip-seq/chipseq-visualization (deepTools bamCoverage) | library-size correction (RPGC/CPM/BPM) for comparison |
| Pileup/variant evidence from BAM | -> alignment-files/pileup-generation | depth is upstream of per-call DP/AD |
mosdepth -- The Modern Default
Goal: Get the median depth and the full breadth curve for a BAM in one fast pass.
Approach: Run mosdepth windowed (or whole-genome), then read the cumulative distribution file -- it already holds breadth at every depth threshold; no histogram integration needed.
mosdepth --by 500 -Q 20 sample in.bam # --by 500 = 500 bp windows; -Q 20 = drop MAPQ<20 (repeat coverage collapses, intentionally)
# Outputs: sample.mosdepth.summary.txt (mean/min/max per chrom + total)
# sample.mosdepth.global.dist.txt (cumulative: chrom, depth, proportion >= depth)
# sample.regions.bed.gz (per-window mean depth)
The *.global.dist.txt rows are chrom depth proportion_of_bases_at_least_this_depth -- the breadth curve directly. Read median as the depth where proportion crosses 0.5. --fast-mode/-x is ~2x faster but SILENTLY disables mate-overlap correction -- fine for a rough WGS glance, wrong for VAF-sensitive short-insert data.
Goal: Emit a callable-region BED (NO_COVERAGE / LOW / CALLABLE / HIGH) without GATK3.
Approach: Use --quantize to bin depth and merge adjacent equal-bin runs into a compact BED.
mosdepth --quantize 0:1:4:150: callable in.bam # bins: [0,1)=NO_COVERAGE, [1,4)=LOW, [4,150)=CALLABLE, [150,inf)=HIGH
# 4 = min callable depth (tune to caller); 150 = excessive-depth ceiling (flags rDNA/artifact pileups)
zcat callable.quantized.bed.gz | head
bedtools genomecov -- Tracks and the Histogram Default
bedtools genomecov -ibam in.bam -bga > cov.bedGraph # -bga = bedGraph INCLUDING zero-coverage runs; -bg omits zeros
bedtools genomecov -ibam in.bam -pc -bg > frag.bedGraph # -pc = FRAGMENT coverage (mate overlap counted once); default counts reads (double-counts overlap)
bedtools genomecov -ibam in.bam -split -bg > rna.bedGraph # -split = skip N-CIGAR gaps (introns); MANDATORY for spliced RNA-seq
bedtools genomecov -ibam in.bam > hist.txt # NO output flag = a 5-col HISTOGRAM, not a track
The bare default is a histogram, not a bedGraph -- 5 columns: chrom depth bases_at_that_depth chrom_size fraction_of_chrom, with a final genome block for the whole genome. Breadth/mean must be integrated from it yourself (sum fraction over depth >= threshold) -- which is exactly why mosdepth's ready-made dist file is preferred.
bedtools coverage -- Per-Target Stats (mind the orientation)
bedtools coverage -a targets.bed -b in.bam > per_target.bed # stats reported FOR each A interval
bedtools coverage -a targets.bed -b in.bam -mean > mean.bed # -mean = mean depth per A interval
As of bedtools v2.24.0 coverage is computed for the -a file (it was -b before) -- A = the regions stats are wanted for (targets), B = the reads. The default appends 4 columns to each A interval: (1) count of B features overlapping, (2) bases in A covered >=1x, (3) length of A, (4) fraction of A covered (col2/col3 = per-interval breadth). -d = per-base depth within each interval; -hist = depth histogram per interval plus an all summary; -counts = just the overlap count (faster).
samtools depth / coverage
samtools coverage in.bam # per-contig: rname..numreads covbases coverage(=breadth%) meandepth meanbaseq meanmapq
samtools depth -a -Q 20 -r chr1:1-100000 in.bam # -a = report zero-depth positions; -Q = min MAPQ; -r = region
samtools depth -s in.bam # -s = count overlapping mate pair only ONCE (short-insert de-double-count)
samtools depth -a --reference ref.fa in.cram # CRAM REQUIRES --reference
In samtools coverage the column literally named coverage is breadth (% bases >=1x), and `meandep
Content truncated.
When not to use it
- →When only mean depth is considered sufficient
- →When the installed `samtools` version is pre-1.13 and depth capping is not desired
- →When the goal is to fix a spiky library by sequencing deeper
Prerequisites
Limitations
- →Mean depth is a budget, not a result
- →A depth number is meaningless until the recipe is stated
- →Extra reads follow the same biased distribution; the holes stay holes
How it compares
This skill emphasizes reporting median depth, breadth, and evenness from a cumulative curve, providing a more accurate assessment of sequencing adequacy than relying solely on mean depth.
Compared to similar skills
bio-genome-intervals-coverage-analysis side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| bio-genome-intervals-coverage-analysis (this skill) | 0 | 2mo | Review | Advanced |
| backtesting-trading-strategies | 10 | 24d | Review | Intermediate |
| extract-test-set | 1 | 6mo | No flags | Intermediate |
| llm-evaluation | 0 | 3mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by FridrichMethod
View all by FridrichMethod →You might also like
backtesting-trading-strategies
jeremylongshore
Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".
extract-test-set
tradingstrategy-ai
Extract raw price dataframe for a test case
llm-evaluation
H4D3ZS
Implement comprehensive evaluation strategies for LLM applications using automated metrics, human feedback, and benchmarking. Use when testing LLM performance, measuring AI application quality, or establishing evaluation frameworks.
Plate Evaluation
ShArAvaNPai
Runs current model against validation set and returns JSON metrics with automated recommendations
model-change
connorkitchings
Use for prediction logic, feature usage, backtests, or metrics changes.
dataframely
Quantco
Best practices for polars data processing with dataframely. Covers definitions of Schema and Collection, usage of