[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ECCFXV6789Q43BPN5KC85Y":3,"skill-same:01M7ECCFXV6789Q43BPN5KC85Y":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7ECCFXV6789Q43BPN5KC85Y","bio-copy-number-cnv-annotation",null,"Annotate copy number variant segments with overlapping genes, dosage-sensitivity scores, cancer driver databases, population frequencies, and clinical-variant content. Covers bedtools\u002Fpybedtools interval intersection, AnnotSV comprehensive annotation and ranking, ClinGen haploinsufficiency\u002Ftriplosensitivity scoring, gnomAD-SV\u002FDGV frequency filtering, COSMIC Cancer Gene Census, and ClinVar overlap. Use when interpreting which genes a CNV affects, distinguishing the driver gene of a focal event from passengers, filtering against population CNVs, separating whole-gene from partial-gene overlap, or preparing CNVs for clinical classification.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-copy-number-cnv-annotation\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-copy-number-cnv-annotation\ndescription: Annotate copy number variant segments with overlapping genes, dosage-sensitivity scores, cancer driver databases, population frequencies, and clinical-variant content. Covers bedtools\u002Fpybedtools interval intersection, AnnotSV comprehensive annotation and ranking, ClinGen haploinsufficiency\u002Ftriplosensitivity scoring, gnomAD-SV\u002FDGV frequency filtering, COSMIC Cancer Gene Census, and ClinVar overlap. Use when interpreting which genes a CNV affects, distinguishing the driver gene of a focal event from passengers, filtering against population CNVs, separating whole-gene from partial-gene overlap, or preparing CNVs for clinical classification.\ntool_type: mixed\nprimary_tool: bedtools\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"copy-number\u002Fcnv-annotation\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n## Version Compatibility\n\nReference examples tested with: bedtools 2.31+, AnnotSV 3.4+, Python 3.10+ with pybedtools 0.9+, pandas 2.2+, pysam 0.22+; R 4.3+ with clusterProfiler 4.10+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `bedtools --version`, `AnnotSV --version`\n- Python: `pip show pybedtools pandas pysam`\n- R: `packageVersion('clusterProfiler')`\n\nIf code throws an error, introspect the installed package and adapt the example. AnnotSV output column names change between major versions — verify against the installed version.\n\n# CNV Annotation\n\n**\"Annotate my CNV calls with the genes they affect\"** -> Overlap CNV segments with gene models, dosage-sensitivity maps, and clinical databases. The hard part is not the intersection — it is deciding *which* genes matter. A focal amplification overlapping 30 genes usually has one driver (the peak gene); a deletion's consequence depends on whether each gene is dosage-sensitive and whether the whole gene or only part is removed.\n\n- CLI: `bedtools intersect -a cnvs.bed -b genes.bed -wa -wb`; `AnnotSV` for full annotation\n- Python: `pybedtools` for interval logic; `pysam` for VCF database queries\n\n## Annotation Strategy — Pick the Database for the Question\n\n| Question | Resource | What it answers |\n|----------|----------|-----------------|\n| Which genes does this CNV span? | RefSeq\u002FGENCODE gene BED | Raw overlap (not yet consequence) |\n| Is loss of this gene damaging? | ClinGen haploinsufficiency (HI) score | Dosage sensitivity to deletion |\n| Is gain of this gene damaging? | ClinGen triplosensitivity (TS) score | Dosage sensitivity to duplication |\n| Is this CNV common in the population? | gnomAD-SV, DGV, 1000G CNV | Benign-frequency filtering |\n| Is this a known recurrent disorder locus? | ClinGen dosage regions, DECIPHER | Genomic-disorder context |\n| Is this a cancer driver? | COSMIC Cancer Gene Census, OncoKB | Oncogene vs tumor-suppressor role |\n| Is there pathogenic small-variant content? | ClinVar | Coincident SNV\u002Findel pathogenicity |\n| One-shot comprehensive annotation + ranking | AnnotSV | Aggregates most of the above |\n\nFor constitutional CNV *classification* (assigning pathogenic\u002FVUS\u002Fbenign), the annotated output feeds the ACMG\u002FClinGen points framework — see germline-cnv-interpretation. For cohort-level recurrence and driver-peak identification, see recurrent-cnv.\n\n## The Core Distinction: Overlap Is Not Consequence\n\nA CNV overlapping a gene does not necessarily change that gene's dosage in a way that matters. Three refinements separate annotation from interpretation:\n\n1. **Whole-gene vs partial overlap.** A deletion spanning an entire gene removes one copy (clean haploinsufficiency test). A deletion removing only the last two exons creates a truncated allele — a different, often more damaging, consequence. Always record the fraction of each gene covered and whether coding exons or only introns\u002FUTRs are hit.\n2. **Dosage sensitivity.** Most genes tolerate single-copy loss. ClinGen HI\u002FTS scores (3 = sufficient evidence for dosage sensitivity, 0 = no evidence, 30 = gene associated with an autosomal-recessive phenotype, 40 = dosage sensitivity unlikely) indicate which genes' loss\u002Fgain is actually consequential.\n3. **Driver vs passenger in focal events.** A focal amplification carries many genes; the driver is the one under selection, typically at the recurrence peak across a cohort (GISTIC) and a known oncogene. Annotating all 30 genes as \"amplified\" overstates.\n\n## Gene Overlap with bedtools\n\n**Goal:** Find genes overlapping each CNV segment, recording overlap extent.\n\n**Approach:** Convert segments to BED, intersect with a gene model, keep both feature sets (`-wo` reports the overlap length) so partial vs whole-gene overlap is recoverable.\n\n```bash\n# Segments to BED (CNVkit .cns example; columns chrom\u002Fstart\u002Fend\u002Flog2)\nawk 'NR>1 {print $1\"\\t\"$2\"\\t\"$3\"\\t\"$5}' sample.cns > sample.cnv.bed\n\n# Intersect; -wo appends the number of overlapping bases\nbedtools intersect -a sample.cnv.bed -b gencode.genes.bed -wo > cnv_gene_overlap.txt\n```\n\n## Comprehensive Annotation with AnnotSV\n\n**Goal:** Annotate CNVs against genes, dosage maps, population frequency, and clinical databases in one pass, with a built-in pathogenicity ranking.\n\n**Approach:** Export CNVs to VCF or BED and run AnnotSV; it returns a \"full\" line per gene plus a \"split\" summary, with an ACMG-aligned rank (1-5).\n\n```bash\nAnnotSV \\\n    -SVinputFile sample.cnv.vcf \\\n    -genomeBuild GRCh38 \\\n    -annotationMode both \\\n    -outputFile sample_annotated.tsv\n\n# Output includes: overlapped genes, ClinGen HI\u002FTS, gnomAD-SV\u002FDGV frequency, OMIM,\n# ClinVar, DECIPHER, and an ACMG-class rank per SV.\n```\n\nAnnotSV's rank is a useful triage signal, not a final classification — confirm against the ClinGen points framework for clinical reporting.\n\n## Dosage-Sensitivity and Driver Annotation\n\n**Goal:** Tag each affected gene with its dosage sensitivity and, for tumors, its driver role, so passengers can be separated from drivers.\n\n**Approach:** Join the gene-overlap table to the ClinGen dosage map (HI\u002FTS scores) and to the COSMIC Cancer Gene Census; flag CNVs whose direction matches a known mechanism (oncogene amplified, tumor suppressor deleted).\n\n```python\nimport pandas as pd\n\ndef annotate_dosage_and_drivers(overlap_tsv, clingen_dosage, cgc_file):\n    '''Tag overlapped genes with ClinGen HI\u002FTS and COSMIC driver role.'''\n    cols = ['cnv_chrom', 'cnv_start', 'cnv_end', 'log2',\n            'gene_chrom', 'gene_start', 'gene_end', 'gene', 'overlap_bp']\n    df = pd.read_csv(overlap_tsv, sep='\\t', names=cols)\n    df['gene_len'] = df['gene_end'] - df['gene_start']\n    df['gene_frac_covered'] = (df['overlap_bp'] \u002F df['gene_len']).clip(upper=1.0)\n    df['whole_gene'] = df['gene_frac_covered'] >= 0.99\n\n    dosage = pd.read_csv(clingen_dosage, sep='\\t')  # gene, HI_score, TS_score\n    df = df.merge(dosage, on='gene', how='left')\n\n    cgc = pd.read_csv(cgc_file, sep='\\t')\n    role = dict(zip(cgc['Gene Symbol'], cgc['Role in Cancer']))\n    df['driver_role'] = df['gene'].map(role)\n\n    # Direction-consistent driver hits: oncogene amplified or TSG deleted.\n    df['driver_hit'] = (\n        ((df['log2'] > 0.3) & df['driver_role'].fillna('').str.contains('oncogene')) |\n        ((df['log2'] \u003C -0.3) & df['driver_role'].fillna('').str.contains('TSG')))\n    return df\n```\n\n## Population-Frequency Filtering\n\n**Goal:** Remove common, presumed-benign CNVs before clinical interpretation.\n\n**Approach:** Reciprocal-overlap match each CNV against a population SV catalog (gnomAD-SV, DGV); a CNV with high reciprocal overlap to a common population CNV of the same type is likely benign.\n\n```bash\n# 50% reciprocal overlap (-f 0.5 -r): same-type, similar-extent population match.\n# Reciprocal overlap, not one-sided, prevents a tiny CNV inside a huge population CNV\n# (or vice versa) from being wrongly matched.\nbedtools intersect -a sample.cnv.bed -b gnomad_sv.bed -f 0.5 -r -wa -wb \\\n    > cnv_population_match.txt\n```\n\n## Pathway Enrichment of Affected Genes\n\n**Goal:** Test whether genes in amplified (or deleted) regions are enriched for pathways.\n\n**Approach:** Extract genes by CNV direction, map to Entrez IDs, run GO\u002FKEGG enrichment. Caveat: CNVs are large and gene-dense, so enrichment is biased toward whatever pathways cluster in CNV-prone genomic regions — interpret as hypothesis-generating.\n\n```r\nlibrary(clusterProfiler)\nlibrary(org.Hs.eg.db)\n\namp_genes \u003C- unique(cnv_annot$gene[cnv_annot$log2 > 0.3])\nentrez \u003C- na.omit(mapIds(org.Hs.eg.db, keys = amp_genes,\n                         keytype = 'SYMBOL', column = 'ENTREZID'))\ngo_bp \u003C- enrichGO(gene = entrez, OrgDb = org.Hs.eg.db, ont = 'BP',\n                  pAdjustMethod = 'BH', qvalueCutoff = 0.05)\n```\n\n## Failure Modes\n\n### Genome-build mismatch between CNVs and annotation\n\n**Trigger:** CNV coordinates on GRCh37 intersected with a GRCh38 gene model (or vice versa).\n\n**Mechanism:** Coordinates silently shift; the intersection succeeds and returns wrong genes.\n\n**Symptom:** Implausible gene assignments; a known driver locus annotated with the wrong gene; systematic offset.\n\n**Fix:** Confirm both inputs are the same build. If not, liftOver the CNVs (note that liftOver can split or drop segments across assembly gaps) and verify a known landmark.\n\n### Annotating all overlapped genes as the \"affected\" genes\n\n**Trigger:** Reporting every gene a focal amplification spans as amplified\u002Fdriver.\n\n**Mechanism:** Focal events are megabases wide and gene-dense; only the selected gene is the driver.\n\n**Symptom:** A 2 Mb amplicon \"amplifies\" 40 genes; the report cannot distinguish ERBB2 from its passengers.\n\n**Fix:** For focal events, prioritize the gene at the cohort recurrence peak (GISTIC, see recurrent-cnv) and known drivers (CGC\u002FOncoKB). Report passengers separately or not at all.\n\n### ClinVar CLNSIG parsing errors\n\n**Trigger:** Naive string matching on the ClinVar `CLNSIG` INFO field.\n\n**Mechanism:** `CLNSIG` is multi-valued, mixes terms (\"Conflicting_classifications\", \"Pathogenic\u002FLikely_pathogenic\", \"Benign\u002FLikely_benign\"), and is per-small-variant — not per-CNV. A substring match for \"pathogenic\" silently captures \"Likely_pathogenic\" (intended) but a careless match also fires on records that are conflicting or benign once underscores and slashes are involved.\n\n**Symptom:** Benign or conflicting variants reported as pathogenic; CNV flagged on incidental nearby SNVs.\n\n**Fix:** Parse `CLNSIG` against the controlled vocabulary; exclude \"Conflicting\" and benign terms explicitly. Remember ClinVar SNV\u002Findel pathogenicity does not transfer to a CNV — use it as context, and use ClinVar's own CNV records or ClinGen dosage regions for the CNV itself.\n\n### Equating overlap with consequence\n\n**Trigger:** Treating any gene-overlapping CNV as functionally significant.\n\n**Mechanism:** Most single-copy losses are tolerated; partial overlaps may hit only introns\u002FUTRs.\n\n**Symptom:** Long lists of \"affected\" dosage-insensitive genes; benign CNVs over-called as significant.\n\n**Fix:** Require dosage evidence (ClinGen HI\u002FTS) and record coding-exon overlap and whole-gene-vs-partial status before calling a gene affected.\n\n## Quantitative Thresholds\n\n| Threshold | Value | Source \u002F Rationale |\n|-----------|-------|--------------------|\n| Population-CNV reciprocal overlap | >= 50% (`-f 0.5 -r`) | Standard reciprocal-overlap match for benign filtering (convention traces to gnomAD-SV \u002F DGV workflows; Collins RL et al 2020 *Nature* 581:444 uses comparable reciprocal-overlap thresholds for benign-population matching) |\n| Common-CNV benign frequency | > 1% population frequency | ACMG\u002FClinGen: high frequency supports benign |\n| ClinGen HI\u002FTS dosage-sensitive | score = 3 | ClinGen: sufficient evidence for dosage sensitivity |\n| Whole-gene overlap | >= 99% gene length covered | Distinguishes clean haploinsufficiency from partial\u002Ftruncating |\n| AnnotSV pathogenic ranks | rank 4-5 | AnnotSV ACMG-aligned ranking (1 benign - 5 pathogenic) |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Wrong genes assigned to a CNV | hg19\u002Fhg38 build mismatch | Match builds; liftOver and verify a landmark |\n| 40 genes called \"amplified\" for one amplicon | All overlapped genes reported as drivers | Prioritize recurrence-peak + known-driver genes |\n| Benign variants flagged pathogenic | Substring match on ClinVar CLNSIG | Parse the controlled vocabulary explicitly |\n| Tiny CNV matched to a huge population CNV | One-sided overlap used for frequency filter | Use reciprocal overlap (`-f 0.5 -r`) |\n| AnnotSV columns not found | Column names differ across AnnotSV versions | Check `head` of the output for the installed version |\n| Enrichment dominated by gene-dense loci | CNVs span gene clusters | Treat CNV-gene enrichment as hypothesis-generating |\n\n## References\n\n- Geoffroy V et al 2018. AnnotSV: an integrated tool for structural variations annotation. Bioinformatics 34:3572\n- Riggs ER et al 2020. Technical standards for the interpretation and reporting of constitutional copy-number variants: ACMG and ClinGen. Genet Med 22:245\n- Collins RL et al 2020. A structural variation reference for medical and population genetics (gnomAD-SV). Nature 581:444\n- Sondka Z et al 2018. The COSMIC Cancer Gene Census. Nat Rev Cancer 18:696\n\n## Related Skills\n\n- copy-number\u002Fgermline-cnv-interpretation - ACMG\u002FClinGen points-based CNV classification\n- copy-number\u002Frecurrent-cnv - GISTIC2 recurrence peaks and driver-gene identification\n- copy-number\u002Fcnvkit-analysis - Generates the CNV segments to annotate\n- copy-number\u002Fcnv-visualization - Visualizing annotated CNVs\n- pathway-analysis\u002Fgo-enrichment - GO\u002FKEGG enrichment methodology and caveats\n- genome-intervals\u002Fbed-file-basics - BED interval operations\n- clinical-databases\u002Fclinvar-lookup - Querying ClinVar for variant pathogenicity\n","## Version Compatibility\n\nReference examples tested with: bedtools 2.31+, AnnotSV 3.4+, Python 3.10+ with pybedtools 0.9+, pandas 2.2+, pysam 0.22+; R 4.3+ with clusterProfiler 4.10+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `bedtools --version`, `AnnotSV --version`\n- Python: `pip show pybedtools pandas pysam`\n- R: `packageVersion('clusterProfiler')`\n\nIf code throws an error, introspect the installed package and adapt the example. AnnotSV output column names change between major versions — verify against the installed version.\n\n# CNV Annotation\n\n**\"Annotate my CNV calls with the genes they affect\"** -> Overlap CNV segments with gene models, dosage-sensitivity maps, and clinical databases. The hard part is not the intersection — it is deciding *which* genes matter. A focal amplification overlapping 30 genes usually has one driver (the peak gene); a deletion's consequence depends on whether each gene is dosage-sensitive and whether the whole gene or only part is removed.\n\n- CLI: `bedtools intersect -a cnvs.bed -b genes.bed -wa -wb`; `AnnotSV` for full annotation\n- Python: `pybedtools` for interval logic; `pysam` for VCF database queries\n\n## Annotation Strategy — Pick the Database for the Question\n\n| Question | Resource | What it answers |\n|----------|----------|-----------------|\n| Which genes does this CNV span? | RefSeq\u002FGENCODE gene BED | Raw overlap (not yet consequence) |\n| Is loss of this gene damaging? | ClinGen haploinsufficiency (HI) score | Dosage sensitivity to deletion |\n| Is gain of this gene damaging? | ClinGen triplosensitivity (TS) score | Dosage sensitivity to duplication |\n| Is this CNV common in the population? | gnomAD-SV, DGV, 1000G CNV | Benign-frequency filtering |\n| Is this a known recurrent disorder locus? | ClinGen dosage regions, DECIPHER | Genomic-disorder context |\n| Is this a cancer driver? | COSMIC Cancer Gene Census, OncoKB | Oncogene vs tumor-suppressor role |\n| Is there pathogenic small-variant content? | ClinVar | Coincident SNV\u002Findel pathogenicity |\n| One-shot comprehensive annotation + ranking | AnnotSV | Aggregates most of the above |\n\nFor constitutional CNV *classification* (assigning pathogenic\u002FVUS\u002Fbenign), the annotated output feeds the ACMG\u002FClinGen points framework — see germline-cnv-interpretation. For cohort-level recurrence and driver-peak identification, see recurrent-cnv.\n\n## The Core Distinction: Overlap Is Not Consequence\n\nA CNV overlapping a gene does not necessarily change that gene's dosage in a way that matters. Three refinements separate annotation from interpretation:\n\n1. **Whole-gene vs partial overlap.** A deletion spanning an entire gene removes one copy (clean haploinsufficiency test). A deletion removing only the last two exons creates a truncated allele — a different, often more damaging, consequence. Always record the fraction of each gene covered and whether coding exons or only introns\u002FUTRs are hit.\n2. **Dosage sensitivity.** Most genes tolerate single-copy loss. ClinGen HI\u002FTS scores (3 = sufficient evidence for dosage sensitivity, 0 = no evidence, 30 = gene associated with an autosomal-recessive phenotype, 40 = dosage sensitivity unlikely) indicate which genes' loss\u002Fgain is actually consequential.\n3. **Driver vs passenger in focal events.** A focal amplification carries many genes; the driver is the one under selection, typically at the recurrence peak across a cohort (GISTIC) and a known oncogene. Annotating all 30 genes as \"amplified\" overstates.\n\n## Gene Overlap with bedtools\n\n**Goal:** Find genes overlapping each CNV segment, recording overlap extent.\n\n**Approach:** Convert segments to BED, intersect with a gene model, keep both feature sets (`-wo` reports the overlap length) so partial vs whole-gene overlap is recoverable.\n\n```bash\n# Segments to BED (CNVkit .cns example; columns chrom\u002Fstart\u002Fend\u002Flog2)\nawk 'NR>1 {print $1\"\\t\"$2\"\\t\"$3\"\\t\"$5}' sample.cns > sample.cnv.bed\n\n# Intersect; -wo appends the number of overlapping bases\nbedtools intersect -a sample.cnv.bed -b gencode.genes.bed -wo > cnv_gene_overlap.txt\n```\n\n## Comprehensive Annotation with AnnotSV\n\n**Goal:** Annotate CNVs against genes, dosage maps, population frequency, and clinical databases in one pass, with a built-in pathogenicity ranking.\n\n**Approach:** Export CNVs to VCF or BED and run AnnotSV; it returns a \"full\" line per gene plus a \"split\" summary, with an ACMG-aligned rank (1-5).\n\n```bash\nAnnotSV \\\n    -SVinputFile sample.cnv.vcf \\\n    -genomeBuild GRCh38 \\\n    -annotationMode both \\\n    -outputFile sample_annotated.tsv\n\n# Output includes: overlapped genes, ClinGen HI\u002FTS, gnomAD-SV\u002FDGV frequency, OMIM,\n# ClinVar, DECIPHER, and an ACMG-class rank per SV.\n```\n\nAnnotSV's rank is a useful triage signal, not a final classification — confirm against the ClinGen points framework for clinical reporting.\n\n## Dosage-Sensitivity and Driver Annotation\n\n**Goal:** Tag each affected gene with its dosage sensitivity and, for tumors, its driver role, so passengers can be separated from drivers.\n\n**Approach:** Join the gene-overlap table to the ClinGen dosage map (HI\u002FTS scores) and to the COSMIC Cancer Gene Census; flag CNVs whose direction matches a known mechanism (oncogene amplified, tumor suppressor deleted).\n\n```python\nimport pandas as pd\n\ndef annotate_dosage_and_drivers(overlap_tsv, clingen_dosage, cgc_file):\n    '''Tag overlapped genes with ClinGen HI\u002FTS and COSMIC driver role.'''\n    cols = ['cnv_chrom', 'cnv_start', 'cnv_end', 'log2',\n            'gene_chrom', 'gene_start', 'gene_end', 'gene', 'overlap_bp']\n    df = pd.read_csv(overlap_tsv, sep='\\t', names=cols)\n    df['gene_len'] = df['gene_end'] - df['gene_start']\n    df['gene_frac_covered'] = (df['overlap_bp'] \u002F df['gene_len']).clip(upper=1.0)\n    df['whole_gene'] = df['gene_frac_covered'] >= 0.99\n\n    dosage = pd.read_csv(clingen_dosage, sep='\\t')  # gene, HI_score, TS_score\n    df = df.merge(dosage, on='gene', how='left')\n\n    cgc = pd.read_csv(cgc_file, sep='\\t')\n    role = dict(zip(cgc['Gene Symbol'], cgc['Role in Cancer']))\n    df['driver_role'] = df['gene'].map(role)\n\n    # Direction-consistent driver hits: oncogene amplified or TSG deleted.\n    df['driver_hit'] = (\n        ((df['log2'] > 0.3) & df['driver_role'].fillna('').str.contains('oncogene')) |\n        ((df['log2'] \u003C -0.3) & df['driver_role'].fillna('').str.contains('TSG')))\n    return df\n```\n\n## Population-Frequency Filtering\n\n**Goal:** Remove common, presumed-benign CNVs before clinical interpretation.\n\n**Approach:** Reciprocal-overlap match each CNV against a population SV catalog (gnomAD-SV, DGV); a CNV with high reciprocal overlap to a common population CNV of the same type is likely benign.\n\n```bash\n# 50% reciprocal overlap (-f 0.5 -r): same-type, similar-extent population match.\n# Reciprocal overlap, not one-sided, prevents a tiny CNV inside a huge population CNV\n# (or vice versa) from being wrongly matched.\nbedtools intersect -a sample.cnv.bed -b gnomad_sv.bed -f 0.5 -r -wa -wb \\\n    > cnv_population_match.txt\n```\n\n## Pathway Enrichment of Affected Genes\n\n**Goal:** Test whether genes in amplified (or deleted) regions are enriched for pathways.\n\n**Approach:** Extract genes by CNV direction, map to Entrez IDs, run GO\u002FKEGG enrichment. Caveat: CNVs are large and gene-dense, so enrichment is biased toward whatever pathways cluster in CNV-prone genomic regions — interpret as hypothesis-generating.\n\n```r\nlibrary(clusterProfiler)\nlibrary(org.Hs.eg.db)\n\namp_genes \u003C- unique(cnv_annot$gene[cnv_annot$log2 > 0.3])\nentrez \u003C- na.omit(mapIds(org.Hs.eg.db, keys = amp_genes,\n                         keytype = 'SYMBOL', column = 'ENTREZID'))\ngo_bp \u003C- enrichGO(gene = entrez, OrgDb = org.Hs.eg.db, ont = 'BP',\n                  pAdjustMethod = 'BH', qvalueCutoff = 0.05)\n```\n\n## Failure Modes\n\n### Genome-build mismatch between CNVs and annotation\n\n**Trigger:** CNV coordinates on GRCh37 intersected with a GRCh38 gene model (or vice versa).\n\n**Mechanism:** Coordinates silently shift; the intersection succeeds and returns wrong genes.\n\n**Symptom:** Implausible gene assignments; a known driver locus annotated with the wrong gene; systematic offset.\n\n**Fix:** Confirm both inputs are the same build. If not, liftOver the CNVs (note that liftOver can split or drop segments across assembly gaps) and verify a known landmark.\n\n### Annotating all overlapped genes as the \"affected\" genes\n\n**Trigger:** Reporting every gene a focal amplification spans as amplified\u002Fdriver.\n\n**Mechanism:** Focal events are megabases wide and gene-dense; only the selected gene is the driver.\n\n**Symptom:** A 2 Mb amplicon \"amplifies\" 40 genes; the report cannot distinguish ERBB2 from its passengers.\n\n**Fix:** For focal events, prioritize the gene at the cohort recurrence peak (GISTIC, see recurrent-cnv) and known drivers (CGC\u002FOncoKB). Report passengers separately or not at all.\n\n### ClinVar CLNSIG parsing errors\n\n**Trigger:** Naive string matching on the ClinVar `CLNSIG` INFO field.\n\n**Mechanism:** `CLNSIG` is multi-valued, mixes terms (\"Conflicting_classifications\", \"Pathogenic\u002FLikely_pathogenic\", \"Benign\u002FLikely_benign\"), and is per-small-variant — not per-CNV. A substring match for \"pathogenic\" silently captures \"Likely_pathogenic\" (intended) but a careless match also fires on records that are conflicting or benign once underscores and slashes are involved.\n\n**Symptom:** Benign or conflicting variants reported as pathogenic; CNV flagged on incidental nearby SNVs.\n\n**Fix:** Parse `CLNSIG` against the controlled vocabulary; exclude \"Conflicting\" and benign terms explicitly. Remember ClinVar SNV\u002Findel pathogenicity does not transfer to a CNV — use it as context, and use ClinVar's own CNV records or ClinGen dosage regions for the CNV itself.\n\n### Equating overlap with consequence\n\n**Trigger:** Treating any gene-overlapping CNV as functionally significant.\n\n**Mechanism:** Most single-copy losses are tolerated; partial overlaps may hit only introns\u002FUTRs.\n\n**Symptom:** Long lists of \"affected\" dosage-insensitive genes; benign CNVs over-called as significant.\n\n**Fix:** Require dosage evidence (ClinGen HI\u002FTS) and record coding-exon overlap and whole-gene-vs-partial status before calling a gene affected.\n\n## Quantitative Thresholds\n\n| Threshold | Value | Source \u002F Rationale |\n|-----------|-------|--------------------|\n| Population-CNV reciprocal overlap | >= 50% (`-f 0.5 -r`) | Standard reciprocal-overlap match for benign filtering (convention traces to gnomAD-SV \u002F DGV workflows; Collins RL et al 2020 *Nature* 581:444 uses comparable reciprocal-overlap thresholds for benign-population matching) |\n| Common-CNV benign frequency | > 1% population frequency | ACMG\u002FClinGen: high frequency supports benign |\n| ClinGen HI\u002FTS dosage-sensitive | score = 3 | ClinGen: sufficient evidence for dosage sensitivity |\n| Whole-gene overlap | >= 99% gene length covered | Distinguishes clean haploinsufficiency from partial\u002Ftruncating |\n| AnnotSV pathogenic ranks | rank 4-5 | AnnotSV ACMG-aligned ranking (1 benign - 5 pathogenic) |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Wrong genes assigned to a CNV | hg19\u002Fhg38 build mismatch | Match builds; liftOver and verify a landmark |\n| 40 genes called \"amplified\" for one amplicon | All overlapped genes reported as drivers | Prioritize recurrence-peak + known-driver genes |\n| Benign variants flagged pathogenic | Substring match on ClinVar CLNSIG | Parse the controlled vocabulary explicitly |\n| Tiny CNV matched to a huge population CNV | One-sided overlap used for frequency filter | Use reciprocal overlap (`-f 0.5 -r`) |\n| AnnotSV columns not found | Column names differ across AnnotSV versions | Check `head` of the output for the installed version |\n| Enrichment dominated by gene-dense loci | CNVs span gene clusters | Treat CNV-gene enrichment as hypothesis-generating |\n\n## References\n\n- Geoffroy V et al 2018. AnnotSV: an integrated tool for structural variations annotation. Bioinformatics 34:3572\n- Riggs ER et al 2020. Technical standards for the interpretation and reporting of constitutional copy-number variants: ACMG and ClinGen. Genet Med 22:245\n- Collins RL et al 2020. A structural variation reference for medical and population genetics (gnomAD-SV). Nature 581:444\n- Sondka Z et al 2018. The COSMIC Cancer Gene Census. Nat Rev Cancer 18:696\n\n## Related Skills\n\n- copy-number\u002Fgermline-cnv-interpretation - ACMG\u002FClinGen points-based CNV classification\n- copy-number\u002Frecurrent-cnv - GISTIC2 recurrence peaks and driver-gene identification\n- copy-number\u002Fcnvkit-analysis - Generates the CNV segments to annotate\n- copy-number\u002Fcnv-visualization - Visualizing annotated CNVs\n- pathway-analysis\u002Fgo-enrichment - GO\u002FKEGG enrichment methodology and caveats\n- genome-intervals\u002Fbed-file-basics - BED interval operations\n- clinical-databases\u002Fclinvar-lookup - Querying ClinVar for variant pathogenicity\n",{"name":5,"source":24,"license":15,"tool_type":25,"description":7,"imported_at":26,"source_path":27,"primary_tool":28,"source_repository":29},"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills","mixed","2026-09-20","copy-number\u002Fcnv-annotation\u002FSKILL.md","bedtools","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fbiology\u002Fbio-copy-number-cnv-annotation","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-copy-number-cnv-annotation",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-copy-number-cnv-annotation",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-copy-number-cnv-annotation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-copy-number-cnv-annotation\u002FSKILL.md",true,[50,56],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Fannotate_cnvs.py","SCRIPT","脚本",2774,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-copy-number-cnv-annotation\u002Fexamples\u002Fannotate_cnvs.py",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"usage-guide.md","REFERENCE","参考文档",4080,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-copy-number-cnv-annotation\u002Fusage-guide.md",[63,71,78,85,92,99],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":70},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":70},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":70},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":70},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":70},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":70},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]