Skip to contents

Extract weights from mr.ash.rss (susieR)

Usage

mrashRssWeights(
  stat,
  ldReference,
  varY = NULL,
  sigma2E = NULL,
  s0 = NULL,
  w0 = NULL,
  fitRetention = c("none", "slim", "full"),
  methodArgs = MrashRssOptions()
)

Arguments

stat

A list of summary statistics: n (per-variant sample sizes), variantNames, and the marginal effects as z, or as b with seb.

ldReference

The LD reference the statistics' variants are matched to by stat$variantNames: a genotype panel (see readGenotypes), a GenotypeMixture or an LdMatrix. mr.ash.rss takes an LD matrix, which is formed from the reference over these variants.

varY

Variance of the phenotype, or NULL (default) to fit on the standardized scale. Used only with b and seb.

sigma2E

Initial residual variance, or NULL (default) for mr.ash.rss's own.

s0

Prior variances of the mixture components, relative to the residual variance, or NULL (default) for the grid susieR::mr.ash uses by default, built for these statistics.

w0

Prior mixture weights (summing to 1), or NULL (default) for equal weights.

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 fitted mr.ash.rss model. This engine keeps no trimmable intermediates, so the two retaining levels behave alike here.

methodArgs

Options forwarded to susieR::mr.ash.rss, built with MrashRssOptions. 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 mean of the coefficients. Unless fitRetention = "none", the fitted model is 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))
mrashRssWeights(stat, LdMatrix(cor(X)))
#>                [,1]
#>  [1,] -5.579090e-08
#>  [2,] -5.579090e-08
#>  [3,]  2.834145e-08
#>  [4,] -5.120788e-09
#>  [5,] -5.120788e-09
#>  [6,] -1.862601e-08
#>  [7,] -2.598663e-08
#>  [8,]  2.898662e-08
#>  [9,] -1.433750e-08
#> [10,] -1.433750e-08
#> [11,] -7.729178e-09
#> [12,] -2.728945e-08
#> [13,] -6.958815e-09
#> [14,] -1.264231e-08
#> [15,] -7.729178e-09
#> [16,]  2.898662e-08
#> [17,] -2.496487e-08
#> [18,] -2.753271e-08
#> [19,]  2.316456e-08
#> [20,] -2.753271e-08
#> [21,] -2.753271e-08
#> [22,] -1.862601e-08
#> [23,] -2.753271e-08
#> [24,]  2.504618e-09
#> [25,] -6.958817e-09
#> [26,] -1.862602e-08
#> [27,] -7.066388e-08
#> [28,] -2.179186e-08
#> [29,]  1.263938e-08
#> [30,]  2.539543e-08