Extract weights from sdpr function
Usage
sdprWeights(
stat,
ldReference,
fitRetention = c("none", "slim", "full"),
methodArgs = SdprOptions()
)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 engine receives 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. A genotype reference's LD is used through its standardized genotypes and not formed as a matrix, except underoptLlk = 2when the per-variant sample sizes and arrays are too varied for its low-rank form to pay.- 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 sampler's estimates,betaEstand the heritabilityh2. This engine keeps no trimmable intermediates, so the two retaining levels behave alike here.- methodArgs
Options forwarded to the sampler,
sdpr, built withSdprOptions. A bare list is refused: it cannot be checked against the engine, so a misspelled option would be silently ignored.
Value
A numeric vector of the posterior SNP coefficients. Unless
fitRetention = "none", the sampler's estimates, the heritability
among them, are attached as attribute "fit".
Examples
data(eqtlRegionExample)
X <- eqtlRegionExample$X[, 1:30]
y <- eqtlRegionExample$yRes
ss <- lapply(
seq_len(ncol(X)), function(j) coef(summary(lm(y ~ X[, j])))[2, 1:2])
stat <- list(
b = vapply(ss, `[`, numeric(1), 1L),
seb = vapply(ss, `[`, numeric(1), 2L),
n = rep(nrow(X), ncol(X)),
variantNames = colnames(X)
)
w <- sdprWeights(stat, LdMatrix(cor(X)), fitRetention = "slim")
#> 100 iter. h2: 0.0208449 max beta: 0.0411226
#> 200 iter. h2: 0.00251109 max beta: 0.0286469
#> 300 iter. h2: 4.4499e-05 max beta: 0.00135623
#> 400 iter. h2: 0.00107698 max beta: -0.0164433
#> 500 iter. h2: 0.000290251 max beta: 0.00942079
#> 600 iter. h2: 0 max beta: -0
#> 700 iter. h2: 0 max beta: 0
#> 800 iter. h2: 0 max beta: -0
#> 900 iter. h2: 0 max beta: -0
#> 1000 iter. h2: 0 max beta: 0
#> h2: 0.00277866 max: 0.00262481
attr(w, "fit")$h2
#> [1] 0.002778656