Empty the LD sketch for zero-variant sumstats entries - #571
Open
Yining97 wants to merge 1 commit into
Open
Conversation
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.
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.
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 retainedldSketchkeeps the full genome-wide panel (13,205,438 rows, ~135 MB serialized) instead of being trimmed. Cause:.subsetSketchToRangeand.subsetSketchToIdsbuild their keep-set from the entries' variant positions/ids, so with zero variants they hitif (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..subsetSketchToIdsstays conservative (full sketch) only for the pathological "ranges present butSNPmcol absent" case, so a malformed-but-non-empty entry is never blanked. Populated studies are unchanged.Validation
getNSamplespreserved, serializes/reloads. 200k-row synthetic sketch: 1.139 MB → 0.00052 MB (2199x smaller).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