Skip to contents

Estimate the residual (null) correlation matrix \(\hat V\) that mashr::mash_set_data() consumes as V. Split out of mashPipeline so the estimation logic lives in one place and is reusable by the mixture-prior workflows.

Usage

mashResidualCorrelation(
  sumStatsList,
  alpha,
  method = c("simple", "identity", "mle", "corshrink", "simpleSpecific"),
  priorCovariances = NULL,
  nSubset = 6000L,
  maxIter = 6L,
  inputScale = c("auto", "beta", "z"),
  mashDataArgs = MashDataOptions(),
  setSeed = 999
)

Arguments

sumStatsList

Named list (or S4Vectors::SimpleList) of QtlSumStats / GwasSumStats. method = "simple" needs a "null" entry; method = "mle" needs "random"; method = "identity" reads only the condition count off "strong".

alpha

mash alpha (forwarded to mashr::mash_set_data()).

method

Estimator, all on the "null" partition unless noted. "simple" = mashr estimate_null_correlation_simple(); "identity" = diag(nConditions) (reads only "strong"); "simpleSpecific" = Matrix::nearPD(cov(nullZ), corr = TRUE); "corshrink" = CorShrink::CorShrinkData() adaptive-shrinkage correlation (needs the CorShrink package); "mle" = mashr::mash_estimate_corr_em() on a random subset (needs "random" + priorCovariances).

priorCovariances

Prior U list (required by method = "mle"). Accepts a bare named list of covariance matrices or a mashPriorCovariances result, which is unwrapped to its U.

nSubset, maxIter

method = "mle" controls (random-subset size and EM iterations).

inputScale

SumStats -> matrix conversion scale ("auto" / "beta" / "z").

mashDataArgs

Extra arguments for mashr::mash_set_data(), built with MashDataOptions – for example zero_Bhat_Shat_reset or zero_Shat_reset. Bhat, Shat, alpha and V are supplied by pecotmr and are refused by the constructor.

setSeed

Integer seed, or NULL to leave the ambient RNG stream untouched (how mashPipeline keeps one continuous stream across its delegated calls).

Value

A conditions x conditions residual correlation matrix.

Examples

data(qtlSumStatsMulticontextExample)
ss <- qtlSumStatsMulticontextExample
mashResidualCorrelation(list(strong = ss, random = ss), alpha = 0,
  method = "identity")
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    0    1    0
#> [3,]    0    0    1