Skip to content

Add fallback for proxy VCF construction failures on small/single-sample objects#43

Merged
remlapmot merged 5 commits intoMRCIEU:masterfrom
ywge03:master
Mar 16, 2026
Merged

Add fallback for proxy VCF construction failures on small/single-sample objects#43
remlapmot merged 5 commits intoMRCIEU:masterfrom
ywge03:master

Conversation

@ywge03
Copy link
Copy Markdown
Contributor

@ywge03 ywge03 commented Mar 16, 2026

Summary

This PR keeps the existing proxy_match() proxy-construction logic as the default path, and adds a compatibility fallback that is only used when the original implementation fails during proxy VCF construction.

The goal is to fix a failure mode I encountered in my environment without changing behavior for users whose workflows already succeed with the current implementation.

In particular, the original code path is still attempted first. The fallback is only triggered if VariantAnnotation genotype-slot replacement fails during construction of the proxy VCF object.

Background

proxy_match() currently builds a proxy VCF object and then modifies its geno slot after construction by:

  • appending the PR geno header field
  • flipping ES values when allele orientation requires sign reversal
  • inserting a new PR genotype matrix to track the proxy rsID used

In my case, this post-construction S4 replacement pattern failed with a subscript/dimension-related error during manipulation of geno(prox). The failure appears to be associated with small or effectively single-sample VCF-like objects, where VariantAnnotation's replacement behavior can be fragile.

The functional intent of the original code is correct, so this PR does not replace that logic globally. Instead, it preserves the original implementation and adds a narrowly scoped fallback for the failing case.

What this PR changes

This PR updates only the proxy VCF construction section inside proxy_match().

The new behavior is:

  1. Attempt the original implementation exactly as before.

  2. If that succeeds, return the result unchanged.

  3. If that fails, catch the error and rebuild the proxy VCF using a compatibility path that:

    • extracts genotype fields as plain matrices first
    • applies effect-sign flipping before VCF construction
    • inserts the PR matrix before VCF construction
    • then creates the VCF object once, instead of relying on post-hoc geno slot replacement

This means existing successful cases continue using the original code path, and only problematic cases use the fallback.

ywge03 and others added 5 commits March 16, 2026 00:35
Refactor proxy VCF construction to include error handling and fallback mechanism for compatibility with small/single-sample VCF objects.
@remlapmot
Copy link
Copy Markdown
Collaborator

Thanks for this.

@remlapmot remlapmot merged commit 53daf45 into MRCIEU:master Mar 16, 2026
10 checks passed
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