Skip to contents

Compute weights with mr.mash using a precomputed prior grid and mixture prior.

Usage

mrmashWrapper(
  X,
  Y,
  V = NULL,
  sumstats = NULL,
  dataDrivenPriorMatrices = NULL,
  prior = MrmashPriorParam(),
  bInitMethod = "enet",
  updateV = TRUE,
  updateVMethod = "full",
  standardize = FALSE,
  numThreads = 1,
  methodArgs = MrmashOptions()
)

Arguments

X

An n x p matrix of genotype data, where n is the total number of individuals and p is the number of SNPs.

Y

An n x r matrix of residual expression data, where n is the total number of individuals and r is the total number of conditions (tissue/cell-types).

V

Optional residual covariance matrix (conditions x conditions), or NULL to estimate it.

sumstats

Optional list of summary statistics for the RSS variant of mr.mash, or NULL for the individual-data variant.

dataDrivenPriorMatrices

A list of data-driven covariance matrices. Default is NULL.

prior

Prior-covariance construction options, built with MrmashPriorParam.

bInitMethod

The method for initializing the coefficient matrix. Default is "enet".

updateV

A logical indicating whether to update the residual covariance matrix. Default is TRUE.

updateVMethod

The method for updating the residual covariance matrix. Default is "full".

standardize

A logical indicating whether to standardize the input data. Default is FALSE. Used by the summary-statistic and initialisation steps as well as the fit, so it is set here rather than in methodArgs.

numThreads

The number of threads to use for parallel computation. Default is 1. Used by the same three steps as standardize.

methodArgs

Options forwarded to mr.mashr::mr.mash under its own names, built with MrmashOptions (update_w0, max_iter, tol, w0_threshold, verbose, ...). Arguments the wrapper derives — the prior, the residual covariance, the coefficient initialisation — cannot be set here.

Value

A mr.mash fit, stored as a list with some or all of the following elements:

mu1

A p x r matrix of posterior means for the regression coefficients.

S1

An r x r x p array of posterior covariances for the regression coefficients.

w1

A p x K matrix of posterior assignment probabilities to the mixture components.

V

An r x r residual covariance matrix.

w0

A K-vector with (updated, if update_w0=TRUE) prior mixture weights, each associated with the respective covariance matrix in S0.

S0

An r x r x K array of prior covariance matrices on the regression coefficients.

intercept

An r-vector containing the posterior mean estimate of the intercept.

fitted

An n x r matrix of fitted values.

G

An r x r covariance matrix of fitted values.

pve

An r-vector of proportion of variance explained by the covariates.

ELBO

The Evidence Lower Bound (ELBO) at the last iteration.

progress

A data frame including information regarding convergence criteria at each iteration.

converged

A logical indicating whether the optimization algorithm converged to a solution within the chosen tolerance level.

elapsed_time

The computation runtime for fitting mr.mash.

Y

An n x r matrix of responses at the last iteration (only relevant when missing values are present in the input Y).

Examples

data(multiTraitData)
res <- mrmashWrapper(
  X = multiTraitData$X[, 1:60], Y = multiTraitData$Y,
  dataDrivenPriorMatrices = multiTraitData$priorMatrices,
  prior = MrmashPriorParam(canonicalPriorMatrices = TRUE)
)