cnvkit-copy-number
Detect somatic CNVs from WES/WGS/targeted BAMs (CNVkit v0.9.x). Bin coverage in target/antitarget regions, normalize vs reference, segment with CBS/HMM, call amps/dels, scatter/diagram plots, purity/ploidy, VCF/SEG export. CLI plus Python API (cnvlib). Use GATK CNV for deep WGS with population controls; use CNVkit for targeted/exome where antitarget bins matter.
npx skills add BioTender-max/awesome-bio-agent-skills --skill cnvkit-copy-number --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.
What it does
Detect somatic CNVs from WES/WGS/targeted BAMs using targeted and antitarget binning, GC/depth normalization, CBS or HMM segmentation, and CNV calling. Provides CLI (cnvkit.py) and Python API (cnvlib) to produce plots and export VCF, SEG, and BED files.
How it works
- Build a reference from normal BAMs or use a flat/pooled normal reference to correct biases. 2) Bin read depth for on-target and off-target regions (target/antitarget). 3) Normalize tumor coverage against the reference, correcting GC bias and library depth. 4) Segment the log2 copy ratio using CBS or HMM. 5) Call CNVs with optional purity/ploidy parameters. 6) Export results (VO, CNV states) and generate visualizations (scatter, diagram, heatmaps). 7) Optional purity/ploidy estimation and segmentation metrics via cnvlib. 8) Export to VCF, SEG, and BED formats for downstream tools. 9) Provide examples in Python for loading, inspecting, and plotting CNV data via cnvlib. 10) Include parameters to control method, segmentation, ploidy, and other preprocessing steps.
When to use it
- Calling somatic CNVs from tumor-normal paired exome/WES or targeted panel sequencing
- Tumor-only analyses using pooled normals; WGS with wgs method; identifying focal amplifications/deletions
- Estimating tumor purity and ploidy to interpret copy ratios
- Generating SEG files for GISTIC2, cBioPortal, or IGV visualization; exporting VCF/BED for integration
What it can touch
- Command-line tool: cnvkit.py
- Python API: cnvlib (via Python scripts shown in examples)
- External dependencies: R DNAcopy for CBS segmentation, Bioconductor packages for CBS; samtools for BAM indexing
Caveats
- Requires CNVkit v0.9.x and Python 3.8+; CBS segmentation relies on R with DNAcopy
- Accuracy depends on quality of reference and input BAMs; deep WGS with PoN may benefit from GATK CNV instead of CNVkit
- Results depend on chosen parameters (method, segment-method, ploidy, purity) and thresholds in classification
# CNVkit Copy Number Analysis ## Overview CNVkit detects somatic copy number variants (CNVs) from whole-exome sequencing (WES), whole-genome sequencing (WGS), or targeted panel BAM files. It calculates read depth in both on-target (capture) bins and off-target (antitarget) bins, corrects for GC bias and library depth, segments the log2 copy ratio profile with circular binary segmentation (CBS) or a hidden Markov model (HMM), and calls amplifications and deletions. CNVkit provides both a CLI (`cnvkit.py`) and a Python API (`cnvlib`) for integration into analysis pipelines, and produces scatter plots, chromosome diagrams, heatmaps, and export files in VCF, BED, and SEG formats. ## When to Use - Calling somatic copy number variants from tumor-normal paired exome (WES) or targeted panel sequencing - Detecting copy number alterations in tumor-only samples using a pooled normal reference - Running CNV analysis on whole-genome sequencing (WGS) data with the `--method wgs` mode - Estimating tumor purity and ploidy for samples where purity is unknown, to interpret copy ratio calls - Generating SEG format copy number files for GISTIC2, cBioPortal, or IGV visualization - Identifying focal amp
- Overview
- When to Use
- Prerequisites
- Quick Start
- Workflow
- Step 1: Create Copy Number Reference
- Step 2: Calculate Coverage in Target and Antitarget Bins
- Step 3: Normalize and Correct Copy Ratios
- Step 4: Segment Copy Number Ratios
- Step 5: Call CNV States
- Step 6: Visualize CNV Profile
- Step 7: Estimate Tumor Purity and Ploidy
- Step 8: Export to VCF, BED, and SEG Formats
- Key Parameters
Install CNVkit via conda (recommended — handles R/DNAcopy dependency)
conda install -c bioconda cnvkit
Or via pip (requires R + DNAcopy already installed)
pip install cnvkit
Verify
cnvkit.py version
cnvkit 0.9.10
Install R DNAcopy (for CBS segmentation)
Rscript -e 'if (!requireNamespace("BiocManager")) install.packages("BiocManager"); BiocManager::install("DNAcopy")'
Index BAM files if not already indexedWhat does the cnvkit-copy-number skill do?
Detect somatic CNVs from WES/WGS/targeted BAMs (CNVkit v0.9.x). Bin coverage in target/antitarget regions, normalize vs reference, segment with CBS/HMM, call amps/dels, scatter/diagram plots, purity/ploidy, VCF/SEG export. CLI plus Python API (cnvlib). Use GATK CNV for deep WGS with population controls; use CNVkit for targeted/exome where antitarget bins matter.
How do I install it?
Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill cnvkit-copy-number --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.
