bio-copy-number-cnvkit-analysis
Detect copy number variants from targeted/exome sequencing using CNVkit. Supports tumor-normal pairs, tumor-only, and germline CNV calling. Use when detecting CNVs from WES or targeted panel sequencing data.
Best use case
bio-copy-number-cnvkit-analysis is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Detect copy number variants from targeted/exome sequencing using CNVkit. Supports tumor-normal pairs, tumor-only, and germline CNV calling. Use when detecting CNVs from WES or targeted panel sequencing data.
Teams using bio-copy-number-cnvkit-analysis should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/bio-copy-number-cnvkit-analysis/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How bio-copy-number-cnvkit-analysis Compares
| Feature / Agent | bio-copy-number-cnvkit-analysis | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Detect copy number variants from targeted/exome sequencing using CNVkit. Supports tumor-normal pairs, tumor-only, and germline CNV calling. Use when detecting CNVs from WES or targeted panel sequencing data.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Marketing
Discover AI agents for marketing workflows, from SEO and content production to campaign research, outreach, and analytics.
Best AI Agents for Marketing
A curated list of the best AI agents and skills for marketing teams focused on SEO, content systems, outreach, and campaign execution.
Best AI Skills for ChatGPT
Find the best AI skills to adapt into ChatGPT workflows for research, writing, summarization, planning, and repeatable assistant tasks.
SKILL.md Source
## Version Compatibility
Reference examples tested with: GATK 4.5+, bedtools 2.31+
Before using code patterns, verify installed versions match. If versions differ:
- Python: `pip show <package>` then `help(module.function)` to check signatures
- CLI: `<tool> --version` then `<tool> --help` to 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.
# CNVkit CNV Analysis
**"Detect copy number variants from my exome data"** → Run a read-depth-based pipeline that normalizes on/off-target coverage against a reference, segments the log2 ratio profile, and calls gains/losses.
- CLI: `cnvkit.py batch tumor.bam --normal normal.bam`
## Basic Workflow
**Goal:** Run the complete CNVkit pipeline on a tumor-normal pair to detect copy number variants.
**Approach:** Execute the batch command which wraps target/antitarget generation, coverage calculation, reference building, and segmentation into one step.
```bash
# Complete pipeline for tumor-normal pair
cnvkit.py batch tumor.bam \
--normal normal.bam \
--targets targets.bed \
--fasta reference.fa \
--output-reference my_reference.cnn \
--output-dir results/
```
## Build Reference from Normal Samples
**Goal:** Create a robust reference from pooled normal samples, then run tumor samples against it.
**Approach:** Build a panel-of-normals reference first, then batch-process tumors using the pre-built reference.
```bash
# Step 1: Build reference from multiple normals (recommended)
cnvkit.py batch \
--normal normal1.bam normal2.bam normal3.bam \
--targets targets.bed \
--fasta reference.fa \
--output-reference pooled_reference.cnn
# Step 2: Run on tumor samples using pre-built reference
cnvkit.py batch tumor1.bam tumor2.bam \
--reference pooled_reference.cnn \
--output-dir results/
```
## Flat Reference (No Matched Normal)
**Goal:** Call CNVs when no matched normal sample is available.
**Approach:** Generate a flat reference from target regions and the reference genome, assuming diploid baseline.
```bash
# When no matched normal is available
cnvkit.py batch tumor.bam \
--targets targets.bed \
--fasta reference.fa \
--output-reference flat_reference.cnn \
--output-dir results/
```
## WGS Mode
**Goal:** Detect CNVs from whole genome sequencing data without a targets file.
**Approach:** Run CNVkit batch with `--method wgs` to use genome-wide binning instead of target/antitarget regions.
```bash
# For whole genome sequencing (no targets file)
cnvkit.py batch tumor.bam \
--normal normal.bam \
--fasta reference.fa \
--method wgs \
--output-dir results/
```
## bedGraph Input (Privacy-Preserving)
**Goal:** Run CNVkit from bedGraph coverage files instead of BAM files for privacy-sensitive data sharing.
**Approach:** Pre-compute coverage from BAM, then feed compressed bedGraph to the coverage step.
```bash
# Generate bedGraph: bedtools genomecov -ibam sample.bam -bg | bgzip > sample.bed.gz && tabix -p bed sample.bed.gz
cnvkit.py coverage sample.bed.gz targets.target.bed -o sample.targetcoverage.cnn
```
## Step-by-Step Pipeline
**Goal:** Execute CNVkit as individual steps for fine-grained control over each stage.
**Approach:** Run target/antitarget generation, coverage, reference building, fix, segment, and call sequentially.
```bash
# 1. Generate target and antitarget regions
cnvkit.py target targets.bed --annotate refFlat.txt -o targets.target.bed
cnvkit.py antitarget targets.bed -o targets.antitarget.bed
# 2. Calculate coverage
cnvkit.py coverage tumor.bam targets.target.bed -o tumor.targetcoverage.cnn
cnvkit.py coverage tumor.bam targets.antitarget.bed -o tumor.antitargetcoverage.cnn
cnvkit.py coverage normal.bam targets.target.bed -o normal.targetcoverage.cnn
cnvkit.py coverage normal.bam targets.antitarget.bed -o normal.antitargetcoverage.cnn
# 3. Build reference
cnvkit.py reference normal.targetcoverage.cnn normal.antitargetcoverage.cnn \
--fasta reference.fa -o reference.cnn
# 4. Fix and call
cnvkit.py fix tumor.targetcoverage.cnn tumor.antitargetcoverage.cnn reference.cnn -o tumor.cnr
cnvkit.py segment tumor.cnr -o tumor.cns
cnvkit.py call tumor.cns -o tumor.call.cns
```
## Segmentation Options
**Goal:** Choose the optimal segmentation algorithm for the sample type.
**Approach:** Select from CBS, HMM, or HMM variants tuned for tumor heterogeneity or germline tightness.
```bash
# Default CBS (Circular Binary Segmentation)
cnvkit.py segment sample.cnr -o sample.cns
# Use HMM for better performance
cnvkit.py segment sample.cnr --method hmm -o sample.cns
# HMM for tumor samples (broader state transitions for heterogeneity)
cnvkit.py segment sample.cnr --method hmm-tumor -o sample.cns
# HMM for germline (tighter priors around diploid)
cnvkit.py segment sample.cnr --method hmm-germline -o sample.cns
# Adjust smoothing
cnvkit.py segment sample.cnr --smooth-cbs -o sample.cns
```
## CNV Calling with Ploidy/Purity
**Goal:** Convert segmented log2 ratios into integer copy number states accounting for tumor composition.
**Approach:** Supply tumor purity and ploidy estimates (and optionally B-allele frequencies from a VCF) to the call step.
```bash
# Specify tumor purity and ploidy
cnvkit.py call sample.cns \
--purity 0.7 \
--ploidy 2 \
-o sample.call.cns
# With B-allele frequencies (from VCF)
cnvkit.py call sample.cns \
--vcf sample.vcf \
--purity 0.7 \
-o sample.call.cns
```
## Export Results
**Goal:** Convert CNVkit output to standard formats for downstream tools or databases.
**Approach:** Export called segments to BED, VCF, SEG (for GISTIC2), or Nexus format.
```bash
# Export to BED format
cnvkit.py export bed sample.call.cns -o sample.cnv.bed
# Export to VCF
cnvkit.py export vcf sample.call.cns -o sample.cnv.vcf
# Export segments for GISTIC2
cnvkit.py export seg *.cns -o samples.seg
# Markers file for GISTIC2 (pairs with 'export seg' above: segments + markers)
cnvkit.py export gistic *.cnr -o samples.markers
# Export for Nexus
cnvkit.py export nexus-basic sample.cnr -o sample.nexus.txt
```
## Visualization
**Goal:** Generate CNV profile plots for visual inspection and publication.
**Approach:** Use CNVkit built-in commands for scatter, diagram, and heatmap views.
```bash
# Scatter plot with segments
cnvkit.py scatter sample.cnr -s sample.cns -o sample_scatter.png
# Single chromosome
cnvkit.py scatter sample.cnr -s sample.cns -c chr17 -o sample_chr17.png
# Diagram (ideogram style)
cnvkit.py diagram sample.cnr -s sample.cns -o sample_diagram.pdf
# Heatmap across samples
cnvkit.py heatmap *.cns -o heatmap.pdf
```
## Key Output Files
| Extension | Description |
|-----------|-------------|
| .cnn | Reference or coverage file |
| .cnr | Copy ratios (log2) per bin |
| .cns | Segmented copy ratios |
| .call.cns | Called copy number states |
## Python API
**Goal:** Programmatically load and filter CNVkit results for custom downstream analysis.
**Approach:** Use cnvlib to read .cnr/.cns files as DataFrames, filter by chromosome or log2 ratio, and export.
```python
import cnvlib
# Load data
cnr = cnvlib.read('sample.cnr')
cns = cnvlib.read('sample.cns')
# Filter by chromosome
chr17 = cnr[cnr.chromosome == 'chr17']
# log2 > 0.5 (~3+ copies): moderate amplification filter
amps = cns[cns['log2'] > 0.5]
# log2 < -0.5 (~1 copy): moderate deletion filter
dels = cns[cns['log2'] < -0.5]
# Export
cnr.to_csv('sample.cnr.tsv', sep='\t', index=False)
```
## Quality Control
**Goal:** Assess CNVkit run quality, check for sex mismatches, and compute per-segment confidence intervals.
**Approach:** Run metrics, sex, segmetrics, and genemetrics commands on output files.
```bash
# Check reference quality
cnvkit.py metrics *.cnr -s *.cns
# Check for gender mismatches
cnvkit.py sex *.cnr *.cnn
# Median absolute deviation (lower is better)
# Biweight midvariance (sample heterogeneity)
# Per-segment confidence intervals
cnvkit.py segmetrics sample.cnr -s sample.cns --ci --pi -o sample.segmetrics.cns
# Gene-level CNV detection with confidence intervals
# 10 bootstrap iterations (default 100); reduce for speed, increase for publication CIs
cnvkit.py genemetrics sample.cnr -s sample.cns --threshold 0.2 --ci --bootstrap 10 -o sample.genemetrics.tsv
```
## Key Parameters
| Parameter | Default | Description |
|-----------|---------|-------------|
| --method | hybrid | hybrid, wgs, amplicon |
| --segment-method | cbs | cbs, hmm, hmm-tumor, hmm-germline, haar, flasso, none |
| --drop-low-coverage | off | Drop low-coverage bins |
| --purity | 1.0 | Tumor purity (0-1) |
| --ploidy | 2 | Sample ploidy |
| --center | none | Log2 centering for call: mean, median, mode, biweight |
| --thresholds | -1.1,-0.25,0.2,0.7 | CN state thresholds |
## Related Skills
- alignment-files/bam-statistics - QC of input BAMs
- copy-number/cnv-visualization - Advanced plotting
- copy-number/cnv-annotation - Gene-level annotation
- copy-number/gatk-cnv - GATK alternative CNV caller
- long-read-sequencing/structural-variants - Complementary SV callingRelated Skills
tooluniverse-variant-analysis
Production-ready VCF processing, variant annotation, mutation analysis, and structural variant (SV/CNV) interpretation for bioinformatics questions. Parses VCF files (streaming, large files), classifies mutation types (missense, nonsense, synonymous, frameshift, splice, intronic, intergenic) and structural variants (deletions, duplications, inversions, translocations), applies VAF/depth/quality/consequence filters, annotates with ClinVar/dbSNP/gnomAD/CADD via ToolUniverse, interprets SV/CNV clinical significance using ClinGen dosage sensitivity scores, computes variant statistics, and generates reports. Solves questions like "What fraction of variants with VAF < 0.3 are missense?", "How many non-reference variants remain after filtering intronic/intergenic?", "What is the pathogenicity of this deletion affecting BRCA1?", or "Which dosage-sensitive genes overlap this CNV?". Use when processing VCF files, annotating variants, filtering by VAF/depth/consequence, classifying mutations, interpreting structural variants, assessing CNV pathogenicity, comparing cohorts, or answering variant analysis questions.
tooluniverse-structural-variant-analysis
Comprehensive structural variant (SV) analysis skill for clinical genomics. Classifies SVs (deletions, duplications, inversions, translocations), assesses pathogenicity using ACMG-adapted criteria, evaluates gene disruption and dosage sensitivity, and provides clinical interpretation with evidence grading. Use when analyzing CNVs, large deletions/duplications, chromosomal rearrangements, or any structural variants requiring clinical interpretation.
tooluniverse-spatial-omics-analysis
Computational analysis framework for spatial multi-omics data integration. Given spatially variable genes (SVGs), spatial domain annotations, tissue type, and disease context from spatial transcriptomics/proteomics experiments (10x Visium, MERFISH, DBiTplus, SLIDE-seq, etc.), performs comprehensive biological interpretation including pathway enrichment, cell-cell interaction inference, druggable target identification, immune microenvironment characterization, and multi-modal integration. Produces a detailed markdown report with Spatial Omics Integration Score (0-100), domain-by-domain characterization, and validation recommendations. Uses 70+ ToolUniverse tools across 9 analysis phases. Use when users ask about spatial transcriptomics analysis, spatial omics interpretation, tissue heterogeneity, spatial gene expression patterns, tumor microenvironment mapping, tissue zonation, or cell-cell communication from spatial data.
tooluniverse-proteomics-analysis
Analyze mass spectrometry proteomics data including protein quantification, differential expression, post-translational modifications (PTMs), and protein-protein interactions. Processes MaxQuant, Spectronaut, DIA-NN, and other MS platform outputs. Performs normalization, statistical analysis, pathway enrichment, and integration with transcriptomics. Use when analyzing proteomics data, comparing protein abundance between conditions, identifying PTM changes, studying protein complexes, integrating protein and RNA data, discovering protein biomarkers, or conducting quantitative proteomics experiments.
protein-interaction-network-analysis
Analyze protein-protein interaction networks using STRING, BioGRID, and SASBDB databases. Maps protein identifiers, retrieves interaction networks with confidence scores, performs functional enrichment analysis (GO/KEGG/Reactome), and optionally includes structural data. No API key required for core functionality (STRING). Use when analyzing protein networks, discovering interaction partners, identifying functional modules, or studying protein complexes.
tooluniverse-metabolomics-analysis
Analyze metabolomics data including metabolite identification, quantification, pathway analysis, and metabolic flux. Processes LC-MS, GC-MS, NMR data from targeted and untargeted experiments. Performs normalization, statistical analysis, pathway enrichment, metabolite-enzyme integration, and biomarker discovery. Use when analyzing metabolomics datasets, identifying differential metabolites, studying metabolic pathways, integrating with transcriptomics/proteomics, discovering metabolic biomarkers, performing flux balance analysis, or characterizing metabolic phenotypes in disease, drug response, or physiological conditions.
tooluniverse-immune-repertoire-analysis
Comprehensive immune repertoire analysis for T-cell and B-cell receptor sequencing data. Analyze TCR/BCR repertoires to assess clonality, diversity, V(D)J gene usage, CDR3 characteristics, convergence, and predict epitope specificity. Integrate with single-cell data for clonotype-phenotype associations. Use for adaptive immune response profiling, cancer immunotherapy research, vaccine response assessment, autoimmune disease studies, or repertoire diversity analysis in immunology research.
tooluniverse-image-analysis
Production-ready microscopy image analysis and quantitative imaging data skill for colony morphometry, cell counting, fluorescence quantification, and statistical analysis of imaging-derived measurements. Processes ImageJ/CellProfiler output (area, circularity, intensity, cell counts), performs Dunnett's test, Cohen's d effect size, power analysis, Shapiro-Wilk normality tests, two-way ANOVA, polynomial regression, natural spline regression with confidence intervals, and comparative morphometry. Supports CSV/TSV measurement tables, multi-channel fluorescence data, colony swarming assays, and neuron counting datasets. Use when analyzing microscopy measurement data, colony area/circularity, cell count statistics, swarming assays, co-culture ratio optimization, or answering questions about imaging-derived quantitative data.
tooluniverse-crispr-screen-analysis
Comprehensive CRISPR screen analysis for functional genomics. Analyze pooled or arrayed CRISPR screens (knockout, activation, interference) to identify essential genes, synthetic lethal interactions, and drug targets. Perform sgRNA count processing, gene-level scoring (MAGeCK, BAGEL), quality control, pathway enrichment, and drug target prioritization. Use for CRISPR screen analysis, gene essentiality studies, synthetic lethality detection, functional genomics, drug target validation, or identifying genetic vulnerabilities.
statistical-analysis
Statistical analysis toolkit. Hypothesis tests (t-test, ANOVA, chi-square), regression, correlation, Bayesian stats, power analysis, assumption checks, APA reporting, for academic research.
single-trajectory-analysis
Guide to reproducing OmicVerse trajectory workflows spanning PAGA, Palantir, VIA, velocity coupling, and fate scoring notebooks.
single-cell-downstream-analysis
Checklist-style reference for OmicVerse downstream tutorials covering AUCell scoring, metacell DEG, and related exports.