Native single-sample correctness: multi-sample VariantCaller + aux-field parsing fix#7
Open
nh13 wants to merge 2 commits into
Open
Native single-sample correctness: multi-sample VariantCaller + aux-field parsing fix#7nh13 wants to merge 2 commits into
nh13 wants to merge 2 commits into
Conversation
0cd41f8 to
2724a87
Compare
|
Heads-up @nh13: I had to squash Side effect: this rewrote the base of your 4 open PRs (#3, #4, #6, #7), so they now show an inflated diff against Sorry for the churn, and thanks again for all the fixes. Your authorship is preserved via a |
This was referenced Jun 24, 2026
2724a87 to
a21e4d4
Compare
--parse_sam_aux_fields was set on MakeExamplesOptions but never on the SamReaderOptions used to open the BAM, and sam_reader.cc's ParseAuxFields is a no-op unless aux_field_handling == PARSE_ALL_AUX_FIELDS. So the flag did nothing: no aux fields (MM/ML base modifications, HP, ...) were ever parsed into the Read proto. Set aux_field_handling = PARSE_ALL_AUX_FIELDS on sam_opts when the flag is on; default off keeps the byte-identical baseline (WGS chr20 unchanged at 182 examples; 14/14 ctest green). Found while validating methylation-aware phasing on real PacBio HiFi 5mC data: without this, read.base_modifications() is always empty so the 5mC path can never engage. (It also gates BAM HP-tag parsing used by the phasing fallback.)
The single-sample path used vcf_candidate_importer::VariantCaller
(variant_calling.cc), which does not emit methylated reference sites
(alt='.'); only multi_sample::VariantCaller (variant_calling_multisample.cc)
does. Upstream always routes through the multi-sample VerySensitiveCaller for
every sample count — vcf_candidate_importer is reserved for the special
--variant_caller=vcf_candidate_importer import mode. So methylation-aware
phasing could never get methylated_ref_sites in the single-sample path.
Switch the single-sample path to multi_sample::VariantCaller (matching the
trio path and upstream), calling CallsFromAlleleCounts with a single-element
{sample_name -> AlleleCounter*} map and role 'sample'. This is the change that
makes methylation-aware phasing actually engage.
Validated on the chr20 HG002 WGS fixture (full chr20, b37, vs GIAB v4.2.1):
F1 0.9974 -> 0.9975, recall 0.9955 -> 0.9957, precision 0.9993 unchanged
(57 FP) — the broader candidate set recovers a few true positives the
narrower importer caller missed, with no precision cost, i.e. it is also more
upstream-faithful. On real PacBio HiFi 5mC data the methylated-ref-site path
now engages (6 methylated ref sites/region; PerformMethylationAwarePhasing
runs). 14/14 ctest green. Apple-only; nothing ports upstream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #5 — review after it merges. Two general correctness fixes to the native single-sample make_examples path, found while validating methylation but valuable on their own (they affect all single-sample WGS/WES runs). Apple-only; both realign the port to upstream — nothing ports upstream. Default behavior change is limited to a small, concordance-validated accuracy improvement (item 2).
1.
--parse_sam_aux_fieldswas a no-opIt was set on
MakeExamplesOptionsbut never on theSamReaderOptionsused to open the BAM, andsam_reader.cc'sParseAuxFieldsdoes nothing unlessaux_field_handling == PARSE_ALL_AUX_FIELDS. So no aux fields (MM/ML base modifications, HP, …) were ever parsed into the Read proto —read.base_modifications()was always empty, and the BAMHPtags the phasing fallback reads were never populated. Now wired (gated on the flag; default off = byte-identical).2. Single-sample path used the wrong VariantCaller
The single-sample path constructed
vcf_candidate_importer::VariantCaller(variant_calling.cc). Upstream always routes normal calling through the multi-sampleVerySensitiveCaller(variant_calling_multisample.cc) for every sample count —vcf_candidate_importeris reserved for the special--variant_caller=vcf_candidate_importerimport mode. Switched the single-sample path tomulti_sample::VariantCaller(matching the trio path and upstream), callingCallsFromAlleleCountswith a single-element{sample_name -> AlleleCounter*}map and rolesample.This aligns the single-sample candidate set with upstream's and is a net accuracy improvement.
Validation
ctestgreen.Why this PR exists
These two fixes are prerequisites for native methylation-aware phasing (PR #6, stacked on this one): without them,
read.base_modifications()is empty and the single-sample path never emits methylated reference sites, so the 5mC vote can never engage. But the caller realignment changes all single-sample runs (slightly better accuracy, more upstream-faithful), so it is split out here for review on its own merits rather than buried in an opt-in feature PR.