Skip to content

Empty the LD sketch for zero-variant sumstats entries - #571

Open
Yining97 wants to merge 1 commit into
StatFunGen:mainfrom
Yining97:rss-empty-entry-sketch-trim
Open

Empty the LD sketch for zero-variant sumstats entries#571
Yining97 wants to merge 1 commit into
StatFunGen:mainfrom
Yining97:rss-empty-entry-sketch-trim

Conversation

@Yining97

Copy link
Copy Markdown
Contributor

Problem

When a study has zero variants in the analysis window, its entry early-exits QC ("fewer than two variants after pre-harmonization QC") with variantsIn = 0 — correct — but the retained ldSketch keeps the full genome-wide panel (13,205,438 rows, ~135 MB serialized) instead of being trimmed. Cause: .subsetSketchToRange and .subsetSketchToIds build their keep-set from the entries' variant positions/ids, so with zero variants they hit if (length(...) == 0L) return(ldSketch) and return the full sketch. Version-independent (0.6.9, 0.6.11). Results/audit are unaffected — only the serialized slot. Cost scales with the panel, not the region (a study missing 100 blocks writes ~13.5 GB of overhead).

Fix

A zero-variant object references no LD, so its sketch should be empty. Added .emptySketch() (zeros @snpInfo, preserves all other slots) and made both trimmers empty on genuinely-zero variants. .subsetSketchToIds stays conservative (full sketch) only for the pathological "ranges present but SNP mcol absent" case, so a malformed-but-non-empty entry is never blanked. Populated studies are unchanged.

Validation

  • Zero-variant → 0-row sketch on both trimmers; emptied handle valid, getNSamples preserved, serializes/reloads. 200k-row synthetic sketch: 1.139 MB → 0.00052 MB (2199x smaller).
  • Populated study byte-identical ([min,max] span / matched-id keep-set); conservative no-mcol case; NULL-safe.
  • test_sumstatsQc.R: 328 tests, 0 failed (3 new tests, 16 expectations).

No API change; no change to results or the early-exit audit.

🤖 Generated with Claude Code

A study with no variants in the analysis window early-exits QC, but the sketch
trimmers no-op on empty input and left the full genome-wide panel in the object
(~135 MB serialized, scaling with the panel not the region). Empty the sketch in
that case; populated studies are unchanged.
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.

1 participant