Skip to content

Special treatment for GRef references in vg haplptypes - #5030

Open
glennhickey wants to merge 1 commit into
masterfrom
gref-haplotypes
Open

Special treatment for GRef references in vg haplptypes#5030
glennhickey wants to merge 1 commit into
masterfrom
gref-haplotypes

Conversation

@glennhickey

Copy link
Copy Markdown
Contributor

When doing haplotype sampling, you usually want to keep the reference (ex for surjecting / genotyping). But if you are working with Graph Reference (GRef), there's a problem: keeping the reference, which covers most of the graph, will prevent haplotype sampling from actually simplifying the graph -- as most nodes and edges will be part of the reference.

My original mindset was to never haplotype sample on GRef. Rather use, ex, CHM13, then downstream link the sampled gam back to a complete graph with GRef paths etc. But this doesn't work properly with @benedictpaten's new vg call, which wants a sampled GAM and a sampled graph to work with all at once.

So this PR changes vg haplotypes's sampling behaviour when faced with a graph reference. It will now only preserve the base contigs of the graph reference, and clip remove the alt contigs as needed.

So the end result of setting gref_CHM13 or CHM13 as a reference for haplotype sampling will be topologically identical. But using gref_CHM13 will keep covering gref (sub) intervals for as much of the sampled graph as possible.

This is all thanks to Claude/Fable and uses existing naming conventions to determine whether paths are GRef or not...

Changelog Entry

To be copied to the draft changelog by merger:

  • Special haplotype sampling logic added for "gref" references. Base contigs are fixed, but "alt" contigs can be clipped or lost.

Sampling with a gref reference (gref_CHM13) copied every gref _alt path through verbatim, which pinned the whole cover and left nothing to remove. Gref fragments are now held out of the reference-inclusion pass and, once each construction job's GBWT is built, clipped to the runs whose nodes and edges already exist there, so the topology is identical to sampling with the base reference. Surviving pieces keep their names and coordinates as subranges (gref_CHM13#0#chr1_7_alt[500]), and --min-gref-len (default 50) drops short ones. Chain naming now prefers a contig from outside the gref namespace, and the guard against a reference contig named like a gref fragment tests the fragment base name, so it fires for subranged reference paths too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01836gaZCYTCFbsHzjUXXFC6
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.

2 participants