Skip to contents

Build the mash prior covariance list U and mixture weights w from a {strong[, random, null]} SumStats collection. Split out of mashPipeline so the covariance-estimation chain lives in one place. The default builds every non-udr covariance component (canonical + pca + flash + flash_nonneg) and refines them with mashr extreme deconvolution (cov_ed).

Usage

mashPriorCovariances(
  sumStatsList,
  alpha,
  vhat = NULL,
  components = c("canonical", "pca", "flash", "flash_nonneg"),
  engine = c("cov_ed", "ud", "ud_ted"),
  nPcs = NULL,
  priorCovariances = NULL,
  priorComponents = NULL,
  udControl = list(),
  inputScale = c("auto", "beta", "z"),
  setSeed = 999
)

Arguments

sumStatsList

Named list (or S4Vectors::SimpleList) with at least "strong" (the discovery set the covariances are learned on).

alpha

mash alpha.

vhat

Residual correlation matrix (V); typically from mashResidualCorrelation. NULL -> identity.

components

Data-driven covariance components, any of "canonical", "pca", "flash" (default cov_flash), "flash_nonneg" (cov_flash(factors = "nonneg")). Built in that fixed order. Ignored by the "ud" / "ud_ted" engines.

engine

Covariance-refinement engine. "cov_ed" (default; mashr's exported cov_ed() extreme deconvolution, whose default algorithm = "bovy" IS the Bovy et al. 2011 method – weights from a final mash()); "ud" / "ud_ted" (udr ED / TED updates, returning weights directly – OPT-IN, known numerical issues, so not the default; "ud_ted" additionally needs i.i.d. (z-scale) data).

nPcs

PCs seeded into cov_pca. Default ncol(Bhat) - 1.

priorCovariances

Optional caller-supplied prior U: a non-empty named list of nCond x nCond matrices. When supplied, the covariance chain is bypassed and only the mixture-weight fit runs.

priorComponents

Optional caller-supplied raw covariance components (a non-empty named list, e.g. the concatenated mashCovarianceComponents outputs). When supplied, these are refined by engine instead of being rebuilt internally – the mixture-prior pipeline where separate steps built the components. components / nPcs are then ignored. Distinct from priorCovariances, which bypasses the engine entirely.

udControl

Named list overriding the udr controls for the "ud" / "ud_ted" engines: n_unconstrained (data-driven matrices to fit; default 50 – the dominant cost, so reduce it for few-condition data), maxiter (default 1000), tol, tol.lik. Ignored by cov_ed.

inputScale

SumStats -> matrix conversion scale.

setSeed

Integer seed, or NULL to leave the ambient RNG untouched.

Value

list(U, w, loglik): the covariance list, the mashr::get_estimated_pi() mixture weights, and the fit log-likelihood (NULL for the cov_ed engine).