Skip to content

Store the LD-sketch sample axis once and drop it on emptied sketches - #586

Merged
gaow merged 2 commits into
StatFunGen:mainfrom
Yining97:dedup-sketch-sampleids
Aug 30, 2026
Merged

gaow merged 2 commits into
StatFunGen:mainfrom
Yining97:dedup-sketch-sampleids

Conversation

@Yining97

Copy link
Copy Markdown
Contributor

An LD-sketch GhSeed stored the panel sample ids twice: genotypeDelayedArray copied handle@sampleIds into GhSeed@dn[[2]], read by nothing but the dimnames() method. The sample axis is an anonymous projection dimension (LD is a variant x variant statistic), so the copy is pure overhead.

  • (A) genotypeDelayedArray stores only the variant axis; dimnames(GhSeed) derives the sample axis from getSampleIds(handle) on read. handle@sampleIds becomes the single copy and every reader is byte-identical.
  • (B) .emptyGenotypeHandle now empties the sample axis too (sampleIds -> character(0), nSamples -> 0L), so an emptied sketch is a consistent 0 x 0. It is reached only via .emptySketch (the empty / PIP-skip path), so surviving regions and QTL handles are untouched.

Validation (real chr21 ADSP panel + AD_Bellenguez, whole-SoS run, baseline vs fixed): both arms SOS_EXIT=0; surviving-region fine-mapping is byte-identical (max abs PIP diff 0e+00, same 28 loci, identical CS); a PIP-skipped region drops from 75 KB to 1.5 KB (0 x 0, no sample names). New unit tests in test_genotypeHandle.R.

genotypeDelayedArray copied handle@sampleIds into GhSeed@dn[[2]], read by nothing but the dimnames() method. The sample axis is an anonymous projection dimension (LD is a variant x variant statistic), so the copy is dead weight in every serialized sketch.

Store only the variant axis; derive the sample axis from getSampleIds(handle) in dimnames(). Also empty sampleIds and nSamples in .emptyGenotypeHandle (reached only via .emptySketch), so a skipped-region sketch is a consistent 0 x 0 instead of 0 x 10000.
The dedup change makes .emptyGenotypeHandle empty the sample axis too, so an emptied sketch is 0 x 0 rather than 0 x nSamples. The test that pinned emptying as keeping the sample columns no longer holds; assert the new contract instead (both axes empty, panel identity preserved).
@gaow
gaow merged commit b6c931c into StatFunGen:main Aug 30, 2026
3 of 4 checks passed
@Yining97
Yining97 deleted the dedup-sketch-sampleids branch August 30, 2026 04:09
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