Skip to contents

End-to-end driver: from `strong, random, null` sumstats collections, builds the variant × context Bhat / Shat matrices, estimates the residual correlation (Vhat), and fits the mash model with canonical + PCA + flash + ED covariance components, returning the fitted covariance list and the estimated mixture weights.

Usage

mashPipeline(
  sumStatsList,
  alpha,
  residualCorrelation = NULL,
  priorCovariances = NULL,
  nPcs = NULL,
  inputScale = c("auto", "beta", "z"),
  setSeed = 999
)

Arguments

sumStatsList

Named list (or SimpleList) of QtlSumStats or GwasSumStats objects. Required names: "strong" (discovery variants), "random" (random background). Optional: "null" (for residual correlation estimation).

alpha

Numeric (length 1). Variance-stabilising-transform exponent forwarded to mashr::mash_set_data(). Use alpha = 0 on the BETA scale, alpha = 1 on the Z scale.

residualCorrelation

Optional pre-computed residual correlation matrix (Vhat). When supplied, replaces the inline mashr::estimate_null_correlation_simple() call entirely and the "random" slot of sumStatsList becomes optional (the function does not need it for anything else). Useful when Vhat was estimated previously on a larger reference and shipped as a static artefact (the legacy MWE pattern).

priorCovariances

Optional named list of square covariance matrices (the Ulist mashr::mash() consumes). When supplied, replaces the canonical + PCA + flash + ED chain (cov_canonical / cov_pca / cov_flash / cov_ed) entirely; mash sees only the supplied matrices. Every entry must be a ncol(Bhat) x ncol(Bhat) matrix. Useful when U was learnt on a larger reference and shipped as a static artefact (the legacy MWE pattern).

nPcs

Optional integer; number of principal components seeded into mashr::cov_pca(). Defaults to ncol(Bhat) - 1. Ignored when priorCovariances is supplied.

inputScale

One of "auto" (default), "beta", "z". Controls which (Bhat, Shat) pair is extracted from each sumstats entry:

"beta"

Bhat = BETA, Shat = SE — the standard effect-size scale mashr was designed around. Requires every entry to carry BETA + SE mcols.

"z"

Bhat = Z, Shat = 1 — z-score scale. Requires Z.

"auto"

Use BETA + SE when every entry carries both; otherwise fall back to (Z, 1) when every entry carries Z. Mixed inputs (some entries missing BETA, others missing Z) are a hard error.

alpha should be chosen consistently with the resolved scale: typically alpha = 0 for beta, alpha = 1 for z.

setSeed

Integer. RNG seed for reproducibility of mashr::cov_flash and mashr::cov_ed. Default 999.

Value

A list with elements U (the combined covariance list: canonical + PCA + flash + ED) and w (the estimated mixture weights).