LDpred2-grid Weights from Summary Statistics
Source:R/regularizedRegressionWrappers.R
ldpred2GridWeights.RdLDpred2-grid (Prive et al. 2020) runs the point-normal prior's Gibbs
sampler at every combination of the proportion of causal variants
p, the heritability h2 and sparse, and returns one of
the fits. Upstream picks it on a validation sample; here, as for the
penalized summary-statistics methods, it is picked on held-out summary
statistics by default (see Details of lassosumRssWeights). A
grid point has diverged, and is not picked, once a kept draw's squared
effects sum past twice the squared marginal effects; bigsnpr's own
sampler tests every iteration, burn-in included.
Arguments
- stat
A list of summary statistics:
n(per-variant sample sizes) and the marginal effects ascor(standardized),z,bwithseb, orbalone, taken as already standardized. The sampler reads z / sqrt(n) for each variant's own sample size.- ldReference
The LD reference the statistics' variants are matched to by
stat$variantNames: a genotype panel (seereadGenotypes), aGenotypeMixtureor anLdMatrix.- backend
"bigsnpr"or"pecotmr".NULL(default) is pecotmr for a genotype reference and bigsnpr for anLdMatrix; pecotmr's sampler reads only a genotype reference.- p
The proportions of causal variants in the grid.
- h2
The heritabilities in the grid.
NULL(default) is the window's LAVA estimate (seeh2Initofldpred2AutoWeights) times 0.3, 0.7, 1 and 1.4, as the LDpred2 vignette scales LD score regression's.- sparse
Whether each fit sets an effect whose inclusion probability falls below
pto zero; both by default.- nIter, nBurnin
Each chain's iterations, burn-in included, and its burn-in.
- shrinkCorr
The LD shrinkage \(c\): both engines read \(cR + (1 - c)I\). Default 0.95, as for
ldpred2AutoWeights; bigsnpr's grid itself has none.- allowJumpSign
As for
ldpred2AutoWeights; bigsnpr's grid sampler takes onlyTRUE, the default.- selection
How the returned fit is chosen:
"heldOut"(default) or"ldQuadratic", as forlassosumRssWeights."heldOut"needs the reference's sample size and refits the grid four times.- fitRetention
How much of the fit is kept as the
"fit"attribute of the returned weights."none"(default) attaches nothing."slim"keepspath, the grid (p,h2,sparse) with whether each pointdivergedand which wasselected."full"also keepsbeta, every point's effects (variants x points).
Value
A numeric vector of weights, the selected fit's effects, with the
selection recorded in attribute "ldpred2_selection". Unless
fitRetention = "none", the grid is attached as attribute
"fit".
Details
backend = "bigsnpr" runs bigsnpr's snp_ldpred2_grid() on the
LD matrix, written to a temporary file for the call; "pecotmr" runs
pecotmr's port of the same sampler on a genotype reference's factor of the
LD. bigsnpr's grid sampler has no LD shrinkage of its own, so for it the
matrix written is shrunk, \(cR + (1 - c)I\), as the Bayesian alphabet's
matrix engines are given theirs; it always allows a drawn effect to
change sign, so it takes no allowJumpSign. pecotmr's sampler takes
both, as LDpred2-auto's does. See ldpred2AutoWeights for the
temporary file, the foreach backend and the seeds.
Examples
if (requireNamespace("bigsnpr", quietly = TRUE)) {
data(eqtlRegionExample)
X <- eqtlRegionExample$X[, 1:30]
y <- eqtlRegionExample$yRes
stat <- list(
cor = as.vector(cor(X, y)),
n = rep(nrow(X), ncol(X)),
variantNames = colnames(X)
)
ld <- LdMatrix(cor(X), nSamples = nrow(X))
set.seed(1)
w <- ldpred2GridWeights(stat, ld, p = c(0.01, 0.1, 1), h2 = 0.1)
attr(w, "ldpred2_selection")
}
#> mode p h2 sparse
#> "heldOut" "0.01" "0.1" "FALSE"