[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ECC5FXVQN14P6KAQ9JV6Z8":3,"skill-same:01M7ECC5FXVQN14P6KAQ9JV6Z8":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},"01M7ECC5FXVQN14P6KAQ9JV6Z8","bio-copy-number-allele-specific-copy-number",null,"Infer integer allele-specific copy number, tumor purity, and ploidy from tumor sequencing by jointly modeling read depth (logR) and B-allele frequency (BAF) with ASCAT, Sequenza, FACETS, PURPLE, and PureCN (tumor-only). Covers the purity-ploidy identifiability problem, the diploid-baseline (dipLogR) anchor, major\u002Fminor copy number, loss of heterozygosity, sunrise\u002Fcontour fit diagnostics, and reconciliation of conflicting fits. Use when tumor analysis needs absolute copy number rather than relative log2, when estimating purity and ploidy, calling LOH or copy-neutral LOH, resolving whole-genome doubling, running tumor-only allele-specific calling, or choosing among ASCAT, Sequenza, FACETS, and PureCN.","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-allele-specific-copy-number\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-copy-number-allele-specific-copy-number\ndescription: Infer integer allele-specific copy number, tumor purity, and ploidy from tumor sequencing by jointly modeling read depth (logR) and B-allele frequency (BAF) with ASCAT, Sequenza, FACETS, PURPLE, and PureCN (tumor-only). Covers the purity-ploidy identifiability problem, the diploid-baseline (dipLogR) anchor, major\u002Fminor copy number, loss of heterozygosity, sunrise\u002Fcontour fit diagnostics, and reconciliation of conflicting fits. Use when tumor analysis needs absolute copy number rather than relative log2, when estimating purity and ploidy, calling LOH or copy-neutral LOH, resolving whole-genome doubling, running tumor-only allele-specific calling, or choosing among ASCAT, Sequenza, FACETS, and PureCN.\ntool_type: mixed\nprimary_tool: ascat\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"copy-number\u002Fallele-specific-copy-number\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n## Version Compatibility\n\nReference examples tested with: ASCAT 3.1+, Sequenza 3.0+ (sequenza-utils 3.0+), FACETS 0.6+ (snp-pileup), PureCN 2.6+, R 4.3+, Python 3.10+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- R: `packageVersion('ASCAT')` \u002F `'sequenza'` \u002F `'facets'` \u002F `'PureCN'`, then `?function`\n- CLI: `sequenza-utils --version`, `snp-pileup --help`\n\nSequenza 3.0 depends on the `copynumber` Bioconductor package, REMOVED from Bioconductor 3.18+ (2023). Install a maintained fork (`ShixiangWang\u002Fcopynumber` or `igordot\u002Fcopynumber`) before Sequenza will load. ASCAT's GC-correction function was renamed across 2.x->3.x (`ascat.GCcorrect` -> `ascat.correctLogR`) — verify against the installed version.\n\n# Allele-Specific Copy Number\n\n**\"How many copies of each allele, in what fraction of cells, at what tumor purity\"** -> Jointly model read depth and B-allele frequency to fit tumor purity, ploidy, and integer major\u002Fminor copy number per segment. Depth alone gives only *relative* copy ratio; depth + BAF gives *absolute* allele-specific copy number. This skill is required whenever the question involves LOH, absolute copy number, purity, ploidy, or whole-genome doubling — CNVkit and GATK somatic CNV cannot answer those.\n\n- R: `ASCAT` (WGS, SNP array), `sequenza` (WES\u002FWGS), `facets` (panel\u002FWES\u002FWGS), `PureCN` (tumor-only panel\u002FWES)\n- CLI: `purple` (Hartwig WGS pipeline, with AMBER + COBALT)\n\n## The Identifiability Problem — Why This Is Hard\n\nPurity and ploidy are **not identifiable from depth alone**. The same log-ratio profile is explained equally well by many (purity, ploidy) pairs: a homozygous deletion at 30% purity looks identical to a heterozygous deletion at 60% purity; an entire profile can be reinterpreted at 2x ploidy with halved purity. Every allele-specific caller breaks this degeneracy by adding BAF — allelic imbalance constrains which solution is real. The consequence: the likelihood surface is **multimodal**, the fit can lock onto an integer-multiple of the true ploidy, and a single point estimate must never be trusted without inspecting the fit diagnostic (ASCAT sunrise plot, Sequenza cellularity\u002Fploidy contour, FACETS dipLogR). A documented example: the same tumor scored ploidy 4.27 by FACETS (WGS) and 2.42 by ASCAT (SNP array).\n\n## Caller Taxonomy\n\n| Tool | Input | Segmentation | Best for | Fails when |\n|------|-------|--------------|----------|------------|\n| ASCAT | SNP array or WGS logR+BAF | ASPCF (allele-specific PCF) | WGS, SNP6, large cohorts | Near-diploid genome with few aberrations cannot anchor purity -> defaults toward purity ~100% |\n| Sequenza | Tumor-normal WES\u002FWGS (seqz) | `copynumber` PCF | Exome, accessible install | Picks a near-diploid local optimum; needs manual review of alternative solutions |\n| FACETS | Tumor-normal, snp-pileup | Joint logR+BAF CBS | Targeted panels, WES, clinical NGS | `cval` too low -> hyperfragmentation; EM locks onto an integer-multiple ploidy |\n| PURPLE | WGS, AMBER+COBALT+SVs | Integrates SV breakpoints | WGS with matched SV calls | Targeted\u002FWES (designed for WGS); needs the Hartwig tool stack |\n| PureCN | Tumor-only WES\u002Fpanel + PoN | Coverage + VCF, normal DB | No matched normal | Sparse hets; small panels; needs a well-built normal database |\n| Battenberg | WGS logR+BAF, phased | ASCAT-based clonal + subclonal | Subclonal CN, clonal evolution | Heavy; needs phasing reference — see subclonal-copy-number |\n\n## Decision Tree by Data Type\n\n| Scenario | Recommended caller | Rationale |\n|----------|--------------------|-----------|\n| Tumor-normal WGS | ASCAT or PURPLE | PURPLE if SV calls available (resolves breakpoints); ASCAT otherwise |\n| Tumor-normal WES | Sequenza or FACETS | Both joint logR+BAF; FACETS faster, Sequenza reports alternative solutions |\n| Targeted panel (tumor-normal) | FACETS | Designed for panel het density; clinical-NGS standard |\n| Tumor-only panel \u002F WES | PureCN | Models a normal database; the standard tumor-only solution |\n| SNP array (legacy) | ASCAT | ASCAT was built for SNP arrays |\n| Subclonal CN \u002F clonal evolution | Battenberg \u002F TITAN | See subclonal-copy-number |\n| Only relative gain\u002Floss needed | CNVkit \u002F GATK | Allele-specific machinery is unnecessary |\n\n## FACETS — Tumor-Normal Allele-Specific CN\n\n**Goal:** Fit purity, ploidy, and integer allele-specific CN for a panel or WES pair.\n\n**Approach:** Pile up read counts at common SNPs with `snp-pileup`, then run the two-pass FACETS workflow — a high-`cval` purity run whose `dipLogR` seeds a low-`cval` sensitivity run for focal events.\n\n```bash\n# Step 1: pileup at dbSNP common sites (normal first, then tumor)\nsnp-pileup -g -q15 -Q20 -P100 -r25,0 dbsnp_common.vcf.gz \\\n    sample.snp_pileup.csv.gz normal.bam tumor.bam\n```\n\n```r\nlibrary(facets)\nset.seed(1234)                                  # FACETS uses random initialization\nrcmat \u003C- readSnpMatrix('sample.snp_pileup.csv.gz')\nxx \u003C- preProcSample(rcmat)                      # gbuild default 'hg19'; pass gbuild='hg38' for GRCh38\n\n# Pass 1: purity\u002Fploidy at a coarse cval (panels ~150-300; WGS ~25-100)\noo1 \u003C- procSample(xx, cval = 300)\nfit1 \u003C- emcncf(oo1)\n\n# Pass 2: focal sensitivity, seeded by the diploid baseline from pass 1\noo2 \u003C- procSample(xx, cval = 150, dipLogR = oo1$dipLogR)\nfit2 \u003C- emcncf(oo2)\n\ncat('purity', fit2$purity, 'ploidy', fit2$ploidy, 'dipLogR', oo2$dipLogR, '\\n')\n# fit2$cncf has per-segment tcn.em (total CN) and lcn.em (minor CN); lcn.em == 0 -> LOH\nplotSample(x = oo2, emfit = fit2)               # ALWAYS inspect this diagnostic plot\n```\n\n## Sequenza — Exome Tumor-Normal\n\n**Goal:** Estimate cellularity\u002Fploidy and allele-specific CN from a WES pair, with explicit alternative solutions.\n\n**Approach:** Build a `seqz` file from the BAMs, bin it, then run the extract\u002Ffit\u002Fresults chain; inspect the cellularity\u002Fploidy contour and the reported alternative solutions.\n\n```bash\nsequenza-utils bam2seqz -n normal.bam -t tumor.bam --fasta ref.fa \\\n    -gc hg38.gc50.wig.gz -o sample.seqz.gz\nsequenza-utils seqz_binning --seqz sample.seqz.gz -w 50 -o sample.bin.seqz.gz\n```\n\n```r\nlibrary(sequenza)\nseqz \u003C- sequenza.extract('sample.bin.seqz.gz')\nCP \u003C- sequenza.fit(seqz)                        # grid search over cellularity x ploidy\nsequenza.results(seqz, CP, 'sampleID', out.dir = 'sequenza_out')\n# Inspect *_CP_contours.pdf and *_alternative_solutions.txt before accepting the fit.\n```\n\n## ASCAT — WGS \u002F SNP Array\n\n**Goal:** Fit purity (rho), ploidy (psi), and allele-specific CN genome-wide.\n\n**Approach:** Load logR\u002FBAF, correct for GC (and optionally replication timing), segment with ASPCF, run the ASCAT fit, and read the sunrise plot.\n\n```r\nlibrary(ASCAT)\nascat.bc \u003C- ascat.loadData('Tumor_LogR.txt', 'Tumor_BAF.txt',\n                           'Germline_LogR.txt', 'Germline_BAF.txt')\nascat.bc \u003C- ascat.correctLogR(ascat.bc, GCcontentfile = 'GC_G1000.txt',\n                              replictimingfile = 'RT_G1000.txt')   # RT optional\nascat.bc \u003C- ascat.aspcf(ascat.bc)\nascat.output \u003C- ascat.runAscat(ascat.bc, gamma = 1)   # gamma=1 for NGS; ~0.55 for arrays\n# ascat.output$purity, $ploidy, $goodnessOfFit; $nA \u002F $nB are major\u002Fminor CN per segment\n# Inspect the sunrise plot: banding at multiples of ploidy signals an ambiguous fit.\n```\n\n## PureCN — Tumor-Only\n\n**Goal:** Recover purity, ploidy, allele-specific CN, and LOH without a matched normal.\n\n**Approach:** Build a normal database (PoN) once, then run `runAbsoluteCN` with the tumor coverage and a VCF; PureCN uses the normal DB and a mapping-bias model in place of a matched normal.\n\n```r\nlibrary(PureCN)\nret \u003C- runAbsoluteCN(\n    tumor.coverage.file = 'tumor_coverage.txt.gz',\n    vcf.file = 'tumor.vcf.gz',\n    normalDB = readRDS('normalDB.rds'),       # built once from >= ~20 process-matched normals\n    genome = 'hg38', sampleid = 'tumor',\n    interval.file = 'baits_intervals.txt')\n# ret$results[[1]]$purity \u002F $ploidy; createCurationFile() flags fits needing manual review\n```\n\n## Failure Modes\n\n### ASCAT defaults to ~100% purity on a near-diploid genome\n\n**Trigger:** A tumor with very few copy-number aberrations and overall ploidy near 2.\n\n**Mechanism:** ASCAT infers purity from the depth\u002FBAF deviation of aberrant segments. With almost no aberrant segments there is nothing to anchor purity against, so the grid search drifts to the boundary.\n\n**Symptom:** Reported purity ~1.0 (or implausibly high) with an almost flat profile; the sunrise plot is nearly featureless.\n\n**Fix:** Treat purity as indeterminate, not 100%. Cross-check with an orthogonal estimate (SNV VAF mode for clonal mutations, pathology estimate). A genuinely quiet genome simply does not support a confident purity call.\n\n### FACETS hyperfragmentation from too-low cval\n\n**Trigger:** `cval` set too low for the data (e.g. panel data run at WGS-scale cval).\n\n**Mechanism:** `cval` is the segmentation critical value; low values let the segmenter split on noise, shattering the profile into spurious micro-segments.\n\n**Symptom:** Hundreds of tiny segments; `tcn.em`\u002F`lcn.em` incoherent with `cnlr.median`; jagged `plotSample` output.\n\n**Fix:** Use cval ~150-300 for panels\u002FWES, ~25-100 for WGS. Run the two-pass workflow (coarse purity run -> dipLogR-seeded sensitivity run). If naive `tcn` and EM `tcn.em` disagree wildly, the fit is bad — re-tune cval.\n\n### Integer-multiple ploidy flip\n\n**Trigger:** Any allele-specific caller on a genome where the diploid baseline is ambiguous (few hets, low purity, or genuine WGD).\n\n**Mechanism:** The likelihood surface has near-equal modes at ploidy P and 2P; the optimizer can select the wrong one, halving or doubling all copy numbers.\n\n**Symptom:** Two callers disagree by a factor of ~2 in ploidy; \"balanced\" CN states that should be odd come out even (or vice versa); SNV multiplicities inconsistent with the called CN.\n\n**Fix:** Inspect the fit diagnostic (sunrise\u002Fcontour). Cross-check ploidy against the fraction of the genome at odd vs even CN and against clonal-SNV VAF. Prefer the solution consistent with known biology; if truly ambiguous, report both.\n\n### Sequenza fails to load \u002F picks a near-diploid optimum\n\n**Trigger:** Fresh Sequenza install on Bioconductor 3.18+; or accepting `sequenza.fit`'s point estimate without review.\n\n**Mechanism:** Sequenza depends on `copynumber`, removed from Bioconductor 3.18+. Separately, the LPP grid search can settle on a near-diploid local optimum when a higher-ploidy solution fits comparably.\n\n**Symptom:** `copynumber` not available at load; or a ploidy ~2 call that conflicts with visible large-scale imbalance.\n\n**Fix:** Install a maintained `copynumber` fork. Always inspect `*_CP_contours.pdf` and `*_alternative_solutions.txt`; if a non-diploid alternative fits nearly as well and matches the BAF pattern, prefer it.\n\n### Low-purity death zone\n\n**Trigger:** Tumor purity below ~40% (common in breast, lung adenocarcinoma, melanoma).\n\n**Mechanism:** Allelic imbalance and depth deviation both shrink with purity; below ~40% the signal approaches the noise floor and segmentation fails.\n\n**Symptom:** No confident fit; purity estimate unstable across reruns; flat BAF.\n\n**Fix:** Below ~40% purity, allele-specific calling is unreliable; below ~20% it is not possible with bulk sequencing. Report indeterminate; consider deeper sequencing or microdissection.\n\n## Reconciliation: When Callers Disagree\n\n| Pattern | Likely cause | Action |\n|---------|--------------|--------|\n| Caller A ploidy ~= 2x caller B | Integer-multiple ploidy flip | Check odd\u002Feven CN fraction and SNV multiplicity; pick the biology-consistent fit |\n| Purity differs widely, ploidy agrees | One caller hit a boundary on a quiet genome | Trust the caller whose diagnostic plot shows real structure |\n| FACETS vs ASCAT integer CN differ | Different segmentation (CBS vs ASPCF) at boundaries | Compare segment edges; arm-level calls usually agree, focal may not |\n| Tumor-only (PureCN) vs tumor-normal differ | Tumor-only has weaker purity constraint | Prefer the matched-normal fit when available |\n\n**Operational rule:** Report an allele-specific fit as confident only when (1) the fit diagnostic (sunrise\u002Fcontour\u002FdipLogR) shows clear, non-degenerate structure, (2) purity is above ~40%, (3) ploidy is consistent with the odd\u002Feven CN fraction and with clonal-SNV multiplicity, and (4) for ambiguous cases, the alternative solutions have been reviewed. A bare purity\u002Fploidy number with no diagnostic inspection is not a result.\n\n## Quantitative Thresholds\n\n| Threshold | Value | Source \u002F Rationale |\n|-----------|-------|--------------------|\n| Purity floor | ~40% reliable; ~20% absolute floor | Below ~40% segmentation fails (Gusnanto 2012; sCNAphase) |\n| FACETS cval (panel\u002FWES) | 150-300 | FACETS docs; lower -> hyperfragmentation |\n| FACETS cval (WGS) | 25-100 | FACETS docs; scales with marker density |\n| ASCAT gamma | 1.0 (NGS); ~0.55 (SNP array) | ASCAT docs; platform-specific logR shrinkage |\n| LOH definition | minor CN (lcn) = 0 | Minor allele lost; total CN may still be >= 2 (CN-neutral LOH) |\n| PureCN normal DB size | >= ~20 process-matched normals | PureCN docs; mapping-bias and coverage model |\n| Het SNP density for stable BAF | thousands genome-wide \u002F hundreds per arm | Sparse hets give noisy allele-fraction segmentation |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Sequenza: `copynumber` not found | Removed from Bioconductor 3.18+ | Install a maintained `copynumber` fork |\n| `ascat.GCcorrect` not found | Renamed in ASCAT 3.x | Use `ascat.correctLogR` |\n| FACETS profile shattered | cval too low | Raise cval; two-pass workflow |\n| Purity reported ~1.0, flat genome | Near-diploid, unanchored | Report indeterminate; cross-check with SNV VAF |\n| All CN halved or doubled vs expectation | Integer-multiple ploidy flip | Inspect fit diagnostic; check SNV multiplicity |\n| PureCN unstable tumor-only fit | Sparse hets \u002F weak normal DB | Larger normal DB; deeper sequencing; flag for curation |\n\n## References\n\n- Van Loo P et al 2010. Allele-specific copy number analysis of tumors. PNAS 107:16910 (ASCAT)\n- Ross EM et al 2021. Allele-specific multi-sample copy number segmentation in ASCAT. Bioinformatics 37:1909\n- Favero F et al 2015. Sequenza: allele-specific copy number and mutation profiles from tumor sequencing data. Ann Oncol 26:64\n- Shen R, Seshan VE 2016. FACETS: allele-specific copy number and clonal heterogeneity analysis. Nucleic Acids Res 44:e131\n- Riester M et al 2016. PureCN: copy number calling and SNV classification using targeted short read sequencing. Source Code Biol Med 11:13\n- Priestley P et al 2019. Pan-cancer whole-genome analyses of metastatic solid tumours (PURPLE). Nature 575:210\n\n## Related Skills\n\n- copy-number\u002Fcopy-ratio-segmentation - logR normalization and segmentation feeding these callers\n- copy-number\u002Fsubclonal-copy-number - Battenberg\u002FTITAN subclonal CN, whole-genome doubling\n- copy-number\u002Fhrd-scoring - LOH\u002FLST\u002FTAI scars computed from allele-specific output\n- copy-number\u002Fcnvkit-analysis - Relative depth-only calling (when allelic resolution is not needed)\n- copy-number\u002Fgatk-cnv - GATK somatic CNV (relative; no purity\u002Fploidy)\n- variant-calling\u002Fvcf-basics - SNV VCFs supplying BAF and clonal-mutation cross-checks\n","## Version Compatibility\n\nReference examples tested with: ASCAT 3.1+, Sequenza 3.0+ (sequenza-utils 3.0+), FACETS 0.6+ (snp-pileup), PureCN 2.6+, R 4.3+, Python 3.10+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- R: `packageVersion('ASCAT')` \u002F `'sequenza'` \u002F `'facets'` \u002F `'PureCN'`, then `?function`\n- CLI: `sequenza-utils --version`, `snp-pileup --help`\n\nSequenza 3.0 depends on the `copynumber` Bioconductor package, REMOVED from Bioconductor 3.18+ (2023). Install a maintained fork (`ShixiangWang\u002Fcopynumber` or `igordot\u002Fcopynumber`) before Sequenza will load. ASCAT's GC-correction function was renamed across 2.x->3.x (`ascat.GCcorrect` -> `ascat.correctLogR`) — verify against the installed version.\n\n# Allele-Specific Copy Number\n\n**\"How many copies of each allele, in what fraction of cells, at what tumor purity\"** -> Jointly model read depth and B-allele frequency to fit tumor purity, ploidy, and integer major\u002Fminor copy number per segment. Depth alone gives only *relative* copy ratio; depth + BAF gives *absolute* allele-specific copy number. This skill is required whenever the question involves LOH, absolute copy number, purity, ploidy, or whole-genome doubling — CNVkit and GATK somatic CNV cannot answer those.\n\n- R: `ASCAT` (WGS, SNP array), `sequenza` (WES\u002FWGS), `facets` (panel\u002FWES\u002FWGS), `PureCN` (tumor-only panel\u002FWES)\n- CLI: `purple` (Hartwig WGS pipeline, with AMBER + COBALT)\n\n## The Identifiability Problem — Why This Is Hard\n\nPurity and ploidy are **not identifiable from depth alone**. The same log-ratio profile is explained equally well by many (purity, ploidy) pairs: a homozygous deletion at 30% purity looks identical to a heterozygous deletion at 60% purity; an entire profile can be reinterpreted at 2x ploidy with halved purity. Every allele-specific caller breaks this degeneracy by adding BAF — allelic imbalance constrains which solution is real. The consequence: the likelihood surface is **multimodal**, the fit can lock onto an integer-multiple of the true ploidy, and a single point estimate must never be trusted without inspecting the fit diagnostic (ASCAT sunrise plot, Sequenza cellularity\u002Fploidy contour, FACETS dipLogR). A documented example: the same tumor scored ploidy 4.27 by FACETS (WGS) and 2.42 by ASCAT (SNP array).\n\n## Caller Taxonomy\n\n| Tool | Input | Segmentation | Best for | Fails when |\n|------|-------|--------------|----------|------------|\n| ASCAT | SNP array or WGS logR+BAF | ASPCF (allele-specific PCF) | WGS, SNP6, large cohorts | Near-diploid genome with few aberrations cannot anchor purity -> defaults toward purity ~100% |\n| Sequenza | Tumor-normal WES\u002FWGS (seqz) | `copynumber` PCF | Exome, accessible install | Picks a near-diploid local optimum; needs manual review of alternative solutions |\n| FACETS | Tumor-normal, snp-pileup | Joint logR+BAF CBS | Targeted panels, WES, clinical NGS | `cval` too low -> hyperfragmentation; EM locks onto an integer-multiple ploidy |\n| PURPLE | WGS, AMBER+COBALT+SVs | Integrates SV breakpoints | WGS with matched SV calls | Targeted\u002FWES (designed for WGS); needs the Hartwig tool stack |\n| PureCN | Tumor-only WES\u002Fpanel + PoN | Coverage + VCF, normal DB | No matched normal | Sparse hets; small panels; needs a well-built normal database |\n| Battenberg | WGS logR+BAF, phased | ASCAT-based clonal + subclonal | Subclonal CN, clonal evolution | Heavy; needs phasing reference — see subclonal-copy-number |\n\n## Decision Tree by Data Type\n\n| Scenario | Recommended caller | Rationale |\n|----------|--------------------|-----------|\n| Tumor-normal WGS | ASCAT or PURPLE | PURPLE if SV calls available (resolves breakpoints); ASCAT otherwise |\n| Tumor-normal WES | Sequenza or FACETS | Both joint logR+BAF; FACETS faster, Sequenza reports alternative solutions |\n| Targeted panel (tumor-normal) | FACETS | Designed for panel het density; clinical-NGS standard |\n| Tumor-only panel \u002F WES | PureCN | Models a normal database; the standard tumor-only solution |\n| SNP array (legacy) | ASCAT | ASCAT was built for SNP arrays |\n| Subclonal CN \u002F clonal evolution | Battenberg \u002F TITAN | See subclonal-copy-number |\n| Only relative gain\u002Floss needed | CNVkit \u002F GATK | Allele-specific machinery is unnecessary |\n\n## FACETS — Tumor-Normal Allele-Specific CN\n\n**Goal:** Fit purity, ploidy, and integer allele-specific CN for a panel or WES pair.\n\n**Approach:** Pile up read counts at common SNPs with `snp-pileup`, then run the two-pass FACETS workflow — a high-`cval` purity run whose `dipLogR` seeds a low-`cval` sensitivity run for focal events.\n\n```bash\n# Step 1: pileup at dbSNP common sites (normal first, then tumor)\nsnp-pileup -g -q15 -Q20 -P100 -r25,0 dbsnp_common.vcf.gz \\\n    sample.snp_pileup.csv.gz normal.bam tumor.bam\n```\n\n```r\nlibrary(facets)\nset.seed(1234)                                  # FACETS uses random initialization\nrcmat \u003C- readSnpMatrix('sample.snp_pileup.csv.gz')\nxx \u003C- preProcSample(rcmat)                      # gbuild default 'hg19'; pass gbuild='hg38' for GRCh38\n\n# Pass 1: purity\u002Fploidy at a coarse cval (panels ~150-300; WGS ~25-100)\noo1 \u003C- procSample(xx, cval = 300)\nfit1 \u003C- emcncf(oo1)\n\n# Pass 2: focal sensitivity, seeded by the diploid baseline from pass 1\noo2 \u003C- procSample(xx, cval = 150, dipLogR = oo1$dipLogR)\nfit2 \u003C- emcncf(oo2)\n\ncat('purity', fit2$purity, 'ploidy', fit2$ploidy, 'dipLogR', oo2$dipLogR, '\\n')\n# fit2$cncf has per-segment tcn.em (total CN) and lcn.em (minor CN); lcn.em == 0 -> LOH\nplotSample(x = oo2, emfit = fit2)               # ALWAYS inspect this diagnostic plot\n```\n\n## Sequenza — Exome Tumor-Normal\n\n**Goal:** Estimate cellularity\u002Fploidy and allele-specific CN from a WES pair, with explicit alternative solutions.\n\n**Approach:** Build a `seqz` file from the BAMs, bin it, then run the extract\u002Ffit\u002Fresults chain; inspect the cellularity\u002Fploidy contour and the reported alternative solutions.\n\n```bash\nsequenza-utils bam2seqz -n normal.bam -t tumor.bam --fasta ref.fa \\\n    -gc hg38.gc50.wig.gz -o sample.seqz.gz\nsequenza-utils seqz_binning --seqz sample.seqz.gz -w 50 -o sample.bin.seqz.gz\n```\n\n```r\nlibrary(sequenza)\nseqz \u003C- sequenza.extract('sample.bin.seqz.gz')\nCP \u003C- sequenza.fit(seqz)                        # grid search over cellularity x ploidy\nsequenza.results(seqz, CP, 'sampleID', out.dir = 'sequenza_out')\n# Inspect *_CP_contours.pdf and *_alternative_solutions.txt before accepting the fit.\n```\n\n## ASCAT — WGS \u002F SNP Array\n\n**Goal:** Fit purity (rho), ploidy (psi), and allele-specific CN genome-wide.\n\n**Approach:** Load logR\u002FBAF, correct for GC (and optionally replication timing), segment with ASPCF, run the ASCAT fit, and read the sunrise plot.\n\n```r\nlibrary(ASCAT)\nascat.bc \u003C- ascat.loadData('Tumor_LogR.txt', 'Tumor_BAF.txt',\n                           'Germline_LogR.txt', 'Germline_BAF.txt')\nascat.bc \u003C- ascat.correctLogR(ascat.bc, GCcontentfile = 'GC_G1000.txt',\n                              replictimingfile = 'RT_G1000.txt')   # RT optional\nascat.bc \u003C- ascat.aspcf(ascat.bc)\nascat.output \u003C- ascat.runAscat(ascat.bc, gamma = 1)   # gamma=1 for NGS; ~0.55 for arrays\n# ascat.output$purity, $ploidy, $goodnessOfFit; $nA \u002F $nB are major\u002Fminor CN per segment\n# Inspect the sunrise plot: banding at multiples of ploidy signals an ambiguous fit.\n```\n\n## PureCN — Tumor-Only\n\n**Goal:** Recover purity, ploidy, allele-specific CN, and LOH without a matched normal.\n\n**Approach:** Build a normal database (PoN) once, then run `runAbsoluteCN` with the tumor coverage and a VCF; PureCN uses the normal DB and a mapping-bias model in place of a matched normal.\n\n```r\nlibrary(PureCN)\nret \u003C- runAbsoluteCN(\n    tumor.coverage.file = 'tumor_coverage.txt.gz',\n    vcf.file = 'tumor.vcf.gz',\n    normalDB = readRDS('normalDB.rds'),       # built once from >= ~20 process-matched normals\n    genome = 'hg38', sampleid = 'tumor',\n    interval.file = 'baits_intervals.txt')\n# ret$results[[1]]$purity \u002F $ploidy; createCurationFile() flags fits needing manual review\n```\n\n## Failure Modes\n\n### ASCAT defaults to ~100% purity on a near-diploid genome\n\n**Trigger:** A tumor with very few copy-number aberrations and overall ploidy near 2.\n\n**Mechanism:** ASCAT infers purity from the depth\u002FBAF deviation of aberrant segments. With almost no aberrant segments there is nothing to anchor purity against, so the grid search drifts to the boundary.\n\n**Symptom:** Reported purity ~1.0 (or implausibly high) with an almost flat profile; the sunrise plot is nearly featureless.\n\n**Fix:** Treat purity as indeterminate, not 100%. Cross-check with an orthogonal estimate (SNV VAF mode for clonal mutations, pathology estimate). A genuinely quiet genome simply does not support a confident purity call.\n\n### FACETS hyperfragmentation from too-low cval\n\n**Trigger:** `cval` set too low for the data (e.g. panel data run at WGS-scale cval).\n\n**Mechanism:** `cval` is the segmentation critical value; low values let the segmenter split on noise, shattering the profile into spurious micro-segments.\n\n**Symptom:** Hundreds of tiny segments; `tcn.em`\u002F`lcn.em` incoherent with `cnlr.median`; jagged `plotSample` output.\n\n**Fix:** Use cval ~150-300 for panels\u002FWES, ~25-100 for WGS. Run the two-pass workflow (coarse purity run -> dipLogR-seeded sensitivity run). If naive `tcn` and EM `tcn.em` disagree wildly, the fit is bad — re-tune cval.\n\n### Integer-multiple ploidy flip\n\n**Trigger:** Any allele-specific caller on a genome where the diploid baseline is ambiguous (few hets, low purity, or genuine WGD).\n\n**Mechanism:** The likelihood surface has near-equal modes at ploidy P and 2P; the optimizer can select the wrong one, halving or doubling all copy numbers.\n\n**Symptom:** Two callers disagree by a factor of ~2 in ploidy; \"balanced\" CN states that should be odd come out even (or vice versa); SNV multiplicities inconsistent with the called CN.\n\n**Fix:** Inspect the fit diagnostic (sunrise\u002Fcontour). Cross-check ploidy against the fraction of the genome at odd vs even CN and against clonal-SNV VAF. Prefer the solution consistent with known biology; if truly ambiguous, report both.\n\n### Sequenza fails to load \u002F picks a near-diploid optimum\n\n**Trigger:** Fresh Sequenza install on Bioconductor 3.18+; or accepting `sequenza.fit`'s point estimate without review.\n\n**Mechanism:** Sequenza depends on `copynumber`, removed from Bioconductor 3.18+. Separately, the LPP grid search can settle on a near-diploid local optimum when a higher-ploidy solution fits comparably.\n\n**Symptom:** `copynumber` not available at load; or a ploidy ~2 call that conflicts with visible large-scale imbalance.\n\n**Fix:** Install a maintained `copynumber` fork. Always inspect `*_CP_contours.pdf` and `*_alternative_solutions.txt`; if a non-diploid alternative fits nearly as well and matches the BAF pattern, prefer it.\n\n### Low-purity death zone\n\n**Trigger:** Tumor purity below ~40% (common in breast, lung adenocarcinoma, melanoma).\n\n**Mechanism:** Allelic imbalance and depth deviation both shrink with purity; below ~40% the signal approaches the noise floor and segmentation fails.\n\n**Symptom:** No confident fit; purity estimate unstable across reruns; flat BAF.\n\n**Fix:** Below ~40% purity, allele-specific calling is unreliable; below ~20% it is not possible with bulk sequencing. Report indeterminate; consider deeper sequencing or microdissection.\n\n## Reconciliation: When Callers Disagree\n\n| Pattern | Likely cause | Action |\n|---------|--------------|--------|\n| Caller A ploidy ~= 2x caller B | Integer-multiple ploidy flip | Check odd\u002Feven CN fraction and SNV multiplicity; pick the biology-consistent fit |\n| Purity differs widely, ploidy agrees | One caller hit a boundary on a quiet genome | Trust the caller whose diagnostic plot shows real structure |\n| FACETS vs ASCAT integer CN differ | Different segmentation (CBS vs ASPCF) at boundaries | Compare segment edges; arm-level calls usually agree, focal may not |\n| Tumor-only (PureCN) vs tumor-normal differ | Tumor-only has weaker purity constraint | Prefer the matched-normal fit when available |\n\n**Operational rule:** Report an allele-specific fit as confident only when (1) the fit diagnostic (sunrise\u002Fcontour\u002FdipLogR) shows clear, non-degenerate structure, (2) purity is above ~40%, (3) ploidy is consistent with the odd\u002Feven CN fraction and with clonal-SNV multiplicity, and (4) for ambiguous cases, the alternative solutions have been reviewed. A bare purity\u002Fploidy number with no diagnostic inspection is not a result.\n\n## Quantitative Thresholds\n\n| Threshold | Value | Source \u002F Rationale |\n|-----------|-------|--------------------|\n| Purity floor | ~40% reliable; ~20% absolute floor | Below ~40% segmentation fails (Gusnanto 2012; sCNAphase) |\n| FACETS cval (panel\u002FWES) | 150-300 | FACETS docs; lower -> hyperfragmentation |\n| FACETS cval (WGS) | 25-100 | FACETS docs; scales with marker density |\n| ASCAT gamma | 1.0 (NGS); ~0.55 (SNP array) | ASCAT docs; platform-specific logR shrinkage |\n| LOH definition | minor CN (lcn) = 0 | Minor allele lost; total CN may still be >= 2 (CN-neutral LOH) |\n| PureCN normal DB size | >= ~20 process-matched normals | PureCN docs; mapping-bias and coverage model |\n| Het SNP density for stable BAF | thousands genome-wide \u002F hundreds per arm | Sparse hets give noisy allele-fraction segmentation |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| Sequenza: `copynumber` not found | Removed from Bioconductor 3.18+ | Install a maintained `copynumber` fork |\n| `ascat.GCcorrect` not found | Renamed in ASCAT 3.x | Use `ascat.correctLogR` |\n| FACETS profile shattered | cval too low | Raise cval; two-pass workflow |\n| Purity reported ~1.0, flat genome | Near-diploid, unanchored | Report indeterminate; cross-check with SNV VAF |\n| All CN halved or doubled vs expectation | Integer-multiple ploidy flip | Inspect fit diagnostic; check SNV multiplicity |\n| PureCN unstable tumor-only fit | Sparse hets \u002F weak normal DB | Larger normal DB; deeper sequencing; flag for curation |\n\n## References\n\n- Van Loo P et al 2010. Allele-specific copy number analysis of tumors. PNAS 107:16910 (ASCAT)\n- Ross EM et al 2021. Allele-specific multi-sample copy number segmentation in ASCAT. Bioinformatics 37:1909\n- Favero F et al 2015. Sequenza: allele-specific copy number and mutation profiles from tumor sequencing data. Ann Oncol 26:64\n- Shen R, Seshan VE 2016. FACETS: allele-specific copy number and clonal heterogeneity analysis. Nucleic Acids Res 44:e131\n- Riester M et al 2016. PureCN: copy number calling and SNV classification using targeted short read sequencing. Source Code Biol Med 11:13\n- Priestley P et al 2019. Pan-cancer whole-genome analyses of metastatic solid tumours (PURPLE). Nature 575:210\n\n## Related Skills\n\n- copy-number\u002Fcopy-ratio-segmentation - logR normalization and segmentation feeding these callers\n- copy-number\u002Fsubclonal-copy-number - Battenberg\u002FTITAN subclonal CN, whole-genome doubling\n- copy-number\u002Fhrd-scoring - LOH\u002FLST\u002FTAI scars computed from allele-specific output\n- copy-number\u002Fcnvkit-analysis - Relative depth-only calling (when allelic resolution is not needed)\n- copy-number\u002Fgatk-cnv - GATK somatic CNV (relative; no purity\u002Fploidy)\n- variant-calling\u002Fvcf-basics - SNV VCFs supplying BAF and clonal-mutation cross-checks\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\u002Fallele-specific-copy-number\u002FSKILL.md","ascat","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fbiology\u002Fbio-copy-number-allele-specific-copy-number","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-allele-specific-copy-number",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-copy-number-allele-specific-copy-number",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-copy-number-allele-specific-copy-number","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-copy-number-allele-specific-copy-number\u002FSKILL.md",true,[50,56],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Frun_facets.R","OTHER","其他",2350,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-copy-number-allele-specific-copy-number\u002Fexamples\u002Frun_facets.R",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"usage-guide.md","REFERENCE","参考文档",4566,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-copy-number-allele-specific-copy-number\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",[],[]]