PolyGenius
Contents

generate$algorithms$LDpred2

LDpred2 algorithm specification

Declares an LDpred2 algorithm for generate$models(). Fitting is delegated to bigsnpr and happens during execution, not here.

Usage

generate$algorithms$LDpred2(
  reference.panel,
  variant.space = NULL,
  mode = c("auto", "grid", "inf"),
  pval = 1,
  p = 10^seq(log10(1e-4), log10(0.2), length.out = 30),
  ld.size = 3000,
  ld.thr = 0.002,
  ncores = 1,
  grid_param = NULL,
  ...
)

Arguments

ArgumentDescription
reference.panelCharacter scalar. Reference panel LD is built from, named as in workspace$catalogs$referencePanels$view().
variant.spaceCharacter scalar or NULL (default). Variant space narrowing reference.panel: PolyGenius derives a restricted panel from the two and builds LD from that. Either the display name shown by workspace$catalogs$variantSpaces$view() or the catalog key selects the same space and the same cached panel; an unknown name, or a reference.panel that is already restricted, aborts.
modeOne of "auto" (default), "grid", "inf". Which LDpred2 estimator to fit: "auto" — bigsnpr::snp_ldpred2_auto(), returning one model built by tutorial-style chain filtering and averaging. PolyGenius defaults vec_p_init to 30 log-spaced values from 1e-4 to 0.2, allow_jump_sign = FALSE, shrink_corr = 0.95 and use_MLE = FALSE; override these, or h2_init, burn_in, num_iter, sparse, p_bounds, alpha_bounds, through .... "grid" — bigsnpr::snp_ldpred2_grid(), returning one PGS per grid row. "inf" — bigsnpr::snp_ldpred2_inf(), returning one model. Pass h2 through ... to skip internal LD-score heritability estimation.
pvalNumeric scalar in [0, 1], default 1. GWAS p-value filter applied before fitting. A vector aborts; sweep thresholds with generate$algorithms$ClumpingThresholding() instead.
pNumeric vector, default 30 log-spaced values from 1e-4 to 0.2. Causal-fraction values forming the "grid" mode grid. Ignored by the other modes, and when grid_param is supplied.
ld.sizeInteger scalar, default 3000. LD-construction control, passed to bigsnpr LD storage as window.
ld.thrNumeric scalar, default 0.002. LD-construction control, passed to bigsnpr LD storage as threshold.
ncoresInteger scalar, default 1. Worker cores requested for this algorithm. A runtime hint that does not enter model cache identity; a value above the workspace core budget aborts generate$models() before anything is scheduled.
grid_paramData frame with columns p, h2, sparse, or NULL (default). The exact "grid" mode grid; NULL builds a tutorial-style grid from p, an internally estimated h2, and an internal h2 multiplier. A data frame missing any of the three columns aborts.
...Native LDpred2 arguments for the selected bigsnpr mode. Forwarded only when the installed bigsnpr version declares them.

Value

A ResourceSpecSet holding one unresolved generate-algorithm specification, for generate$models(algorithms = ). In "grid" mode that one specification expands during execution into one model per grid row.

Details

The rule consumes gwas.sumstats and ld.bigsnpr storage and produces polygenius.model outputs. Native bigsnpr arguments given through ... are forwarded only when the installed bigsnpr mode function declares them; the rest are dropped. Native arguments left unsupplied keep PolyGenius' own defaults, which mirror bigsnpr's except where mode says otherwise, and required arguments with no native default, such as h2, are estimated inside the rule.

Parameter guidance: https://privefl.github.io/bigsnpr/articles/LDpred2.html and https://privefl.github.io/bigsnpr-extdoc/polygenic-scores-pgs.html.

Rules behind this algorithm

BuildLDBigsnprRule materializes the ld.bigsnpr correlation storage from the reference panel, then RunLdPred2Rule fits against it.

Prerequisites, resolved and cached on demand: a bfile reference panel and the bigsnpr package family (SetupBigsnprRule).

Examples

models <- generate$models(
  sources    = generate$sources$opengwas("ieu-b-2"),
  algorithms = generate$algorithms$LDpred2(
    reference.panel = "EUR",
    variant.space   = "HapMap3+",
    mode            = "auto"
  )
)

See Also

Aliases: generate-ldpred2, generate.algorithm.LDpred2, generate$algorithms$LDpred2