Skip to contents

Extract weights from prsCs function

Usage

prsCsWeights(
  stat,
  ldReference,
  fitRetention = c("none", "slim", "full"),
  methodArgs = PrsCsOptions()
)

Arguments

stat

A list of summary statistics: n (per-variant sample sizes) and the marginal effects as cor (standardized), z, b with seb, or b alone, taken as already standardized. The engine receives the standardized effects z / sqrt(n), with n the median of n.

ldReference

The LD reference the statistics' variants are matched to by stat$variantNames: a genotype panel (see readGenotypes), a GenotypeMixture or an LdMatrix. A genotype reference's LD is used through its standardized genotypes, never formed as a matrix.

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 posterior estimates: betaEst, the local shrinkage parameters psiEst, the residual variance sigmaEst and the global shrinkage phiEst. This engine keeps no trimmable intermediates, so the two retaining levels behave alike here.

methodArgs

Options forwarded to the sampler, prsCs, built with PrsCsOptions. 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 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 <- prsCsWeights(
  stat,
  LdMatrix(cor(X)),
  fitRetention = "slim",
  methodArgs = PrsCsOptions(maf = rep(0.3, ncol(X)))
)
attr(w, "fit")$phiEst
#> [1] 0.003201511