Skip to content

Add ld_loader() for on-demand block-wise LD retrieval#460

Merged
gaow merged 1 commit intomainfrom
move-ld-loader-from-susieann
Apr 7, 2026
Merged

Add ld_loader() for on-demand block-wise LD retrieval#460
gaow merged 1 commit intomainfrom
move-ld-loader-from-susieann

Conversation

@gaow
Copy link
Copy Markdown
Contributor

@gaow gaow commented Apr 7, 2026

Summary

  • Add ld_loader() function factory for lazy, on-demand LD block loading
  • Moved from susieAnn/R/ld_loader.R to share across packages (susieAnn, OTTERS pipeline, etc.)
  • Three modes: pre-loaded R matrices, pre-loaded genotype X matrices, or on-the-fly loading via load_LD_matrix() from metadata TSV
  • Optional max_variants subsampling for memory control
  • susieAnn updated to re-export from pecotmr (separate commit in susieAnn repo)

Usage

# Pre-loaded LD
loader <- ld_loader(R_list = list(R1, R2, R3))
loader(1)  # returns R1

# On-the-fly from pecotmr metadata
loader <- ld_loader(ld_meta_path = "ld_meta.tsv",
                    regions = c("chr1:1-1000000", "chr1:1000001-2000000"))
loader(1)  # loads LD for first region

Test plan

  • R CMD check passes
  • susieAnn vignettes still work with re-exported ld_loader()

🤖 Generated with Claude Code

Move ld_loader() from susieAnn to pecotmr as a shared utility.
This function factory creates a closure for lazy LD loading with
three modes:
- List mode (R matrices): pre-loaded LD correlation matrices
- List mode (X matrices): pre-loaded genotype matrices
- File mode: loads LD on-the-fly via load_LD_matrix() from a
  pecotmr metadata TSV, avoiding loading all blocks into memory

Useful for genome-wide analyses (OTTERS, susie_ann) that process
hundreds of LD blocks sequentially.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gaow gaow merged commit ba0102b into main Apr 7, 2026
4 of 5 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.

1 participant