Skip to content

Add combine_cis_snvs transform and VCF spanning-deletion provenance (11.20.0) - #758

Merged
iskandr merged 1 commit into
mainfrom
feat/cis-snv-and-spanning-deletion
Nov 21, 2026
Merged

iskandr merged 1 commit into
mainfrom
feat/cis-snv-and-spanning-deletion

Conversation

@iskandr

@iskandr iskandr commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #368 and #264, bumping Varcode to 11.20.0.

1. Provenance-preserving combine_cis_snvs transform (#368)

  • Adds varcode.transforms.combine_cis_snvs(vc, phase_resolver=None, *, sample=None) (also exported at the package root and documented in docs/transforms.md and docs/api_variants.md).
  • Enforces all biological and provenance safeguards:
    • Explicit phase/sample scope: requires either phase_resolver or sample (mutually exclusive), using allele/sample-aware query_in_cis rather than raw PS equality.
    • CDS-relative codon membership: uses spliced_offset - transcript.first_start_codon_spliced_offset on complete coding transcripts, verified on both strands including TP53 (- strand, 5' UTR = 190, not divisible by 3).
    • No cross-intron MNV collapse: split codons across exon-exon junctions (CFTR exon 1→2, TP53 exon 2→3) are left as separate SNVs.
    • No lex-first transcript tie-breaking: overlapping transcripts with differing CDS frames (CDKN2A p16INK4a vs p14ARF) decline the reduction with a warning.
    • Reference-validated gap bases: positions 1+3 fill the middle base via reference_range and verify every member's ref base against the reference.
    • Multi-sample & haplotype preservation: declines mixed 1/1 + 1|0 merges that would lose the second haplotype and declines multi-sample phase/genotype conflicts while allowing compatible somatic (0/0 normal) or germline pairs; skips same-position multi-allelic alternatives; idempotent; demonstrates exact consequence equivalence against the haplotype path.

2. VCF * spanning-deletion placeholder provenance (#264)

  • Adds SpanningDeletionRecord (DataclassSerializable, exported at the package root), VariantCollection.spanning_deletion_records, and VariantCollection.spanning_deletions_dataframe().
  • Keeps * excluded as an independently annotatable Variant (no independent protein consequence and no max_variants count), while preserving original VCF coordinates, alt_allele_index, gt_allele_index, vcf_alt_alleles, id, qual, filter, info, sample_info, and source for both placeholder-only and mixed-ALT rows.
  • Links upstream_deletion only when source positional and sample/phase evidence uniquely resolves a loaded deletion ("resolved", "unresolved", or "ambiguous"), leaving filtered/absent/trans-phased/ambiguous deletions explicitly unlinked.
  • Preserves provenance across JSON/pickle serialization, CSV header accounting (# spanning_deletion_records=...), set operations (union/intersection/difference), and collection transforms.

Verification

  • ./lint.sh (ruff + mypy across 16 source files): pass
  • mkdocs build --strict: pass
  • Full ./test.sh suite including new tests/test_transforms_combine_cis_snvs.py and tests/test_spanning_deletion_provenance.py: pass

…11.20.0)

Closes #368, #264.

- Implement varcode.transforms.combine_cis_snvs with explicit phase/sample
  scope, CDS-relative codon membership across both strands and nonzero UTRs,
  single-exon contiguity (no cross-intron MNV collapse), strict cross-transcript
  compatibility (declining dual-frame loci like CDKN2A without lex-first
  tie-breaking), multi-sample/haplotype preservation, reference-validated gap
  bases, and full source_variants/metadata provenance.
- Retain VCF '*' spanning-deletion placeholder provenance via
  SpanningDeletionRecord and VariantCollection.spanning_deletion_records /
  spanning_deletions_dataframe() without creating independent variants, protein
  consequences, or extra max_variants counts; link upstream_deletion only when
  source positional and sample/phase evidence uniquely resolves it.
- Bump version to 11.20.0 and update CHANGELOG, docs, and typing checks.
@iskandr
iskandr merged commit 4b65cde into main Nov 21, 2026
6 checks passed
@iskandr
iskandr deleted the feat/cis-snv-and-spanning-deletion branch November 21, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Combine cis SNVs into MNVs without losing transcript or phase interpretations

1 participant