BayesR TWAS weights from summary statistics
Source:R/regularizedRegressionWrappers.R
bayesRRssWeights.RdbayesAlphabetRssWeights with the BayesR prior.
Usage
bayesRRssWeights(
stat,
ldReference,
backend = NULL,
nIter = 5000,
nBurnin = 1000,
thin = 5,
shrinkCorr = 0.95,
fitRetention = c("none", "slim", "full"),
methodArgs = NULL
)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 engines receive the standardized effects z / sqrt(n), with n the median ofn.- ldReference
The LD reference the statistics' variants are matched to by
stat$variantNames: a genotype panel (seereadGenotypes), aGenotypeMixtureor anLdMatrix.- backend
"qgg","hibayes"or"pecotmr";NULLpicks the default for the LD reference.- nIter
Integer. Total number of MCMC iterations, burn-in included, on every engine. Default
5000.- nBurnin
Integer. Number of burn-in iterations discarded; less than
nIter. Default1000.- thin
Integer. Thinning interval for retained MCMC samples. Default
5.- shrinkCorr
The LD shrinkage \(c\): every engine reads \(cR + (1 - c)I\), qgg and hibayes as the matrix they are given, pecotmr's sampler through the factor. Default 0.95, the LDpred2 vignette's. A reference with fewer samples than the window has variants lacks directions the statistics have, and without shrinkage the samplers' effects can grow without bound along them (pecotmr's sampler also drops those directions by default, through SDPR's likelihood; see
bayesAlphabetRssWeights). A small or mismatched reference does better with less, down to 0.4 as the LDpred2 vignette advises; the study's own genotypes as the reference need none, up to 1.- fitRetention
How much of the fit is kept as the
"fit"attribute of the returned weights:"none"(default) attaches nothing,"slim"and"full"attach the engine's estimates (betaEst, and where the engine gives them the inclusion probabilitiespip, the non-null proportionpiand the residual variance),backendand theshrinkCorrused. No engine keeps trimmable intermediates, so the two retaining levels behave alike.- methodArgs
Options for the backend's engine, built with its constructor:
QggOptionsfor qgg,HibayesRssOptionsfor hibayes,BayesAlphabetRssOptionsfor pecotmr's sampler.NULLkeeps the engine's defaults.
Examples
data(eqtlRegionExample)
X <- eqtlRegionExample$X[, 1:30]
stat <- list(
z = as.vector(cor(X, eqtlRegionExample$yRes)) * sqrt(nrow(X)),
n = rep(nrow(X), ncol(X)),
variantNames = colnames(X)
)
bayesRRssWeights(stat, LdMatrix(cor(X)), "hibayes", nIter = 1000,
nBurnin = 200)
#> [1] -2.887230e-03 -4.748196e-03 1.765330e-03 -1.423034e-03 -4.551287e-04
#> [6] -2.028051e-03 -1.684843e-03 1.174772e-03 -1.045486e-03 7.092007e-04
#> [11] -7.619483e-04 -3.155411e-03 -1.264380e-03 -1.438423e-04 -5.884024e-04
#> [16] 3.047931e-03 -1.896856e-03 -2.418185e-04 8.993368e-04 -5.043595e-04
#> [21] -9.735005e-04 -2.146926e-03 -3.230834e-03 -4.242292e-06 -2.450746e-04
#> [26] -9.736134e-04 -6.473676e-03 -1.226245e-03 2.529348e-03 9.732139e-05