Skip to contents

Fit a mashr model on a chosen partition using a supplied prior covariance list and residual correlation, returning the fitted model. This is the fit step (mash_fit's first step): following Urbut et al. 2019 the mixture weights are learned on the representative "random" partition, and the resulting model is then applied to the strong / target set by mashPosterior.

Usage

mashModelFit(
  sumStatsList,
  alpha,
  priorCovariances,
  vhat = NULL,
  fitOn = c("random", "strong"),
  outputLevel = 4L,
  inputScale = c("auto", "beta", "z"),
  setSeed = 999
)

Arguments

sumStatsList

Named list (or S4Vectors::SimpleList) of QtlSumStats / GwasSumStats; must contain the fitOn entry.

alpha

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

priorCovariances

The prior covariance list (U) to fit with – e.g. the $U of a mashPriorCovariances result.

vhat

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

fitOn

Partition to learn the mixture weights on: "random" (default, the standard unbiased choice) or "strong".

outputLevel

mashr::mash() outputlevel (default 4 – the full model mashPosterior consumes).

inputScale

SumStats -> matrix conversion scale.

setSeed

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

Value

The fitted mashr model (the mashr::mash() object).

Examples

data(mashInputExample)
mi <- mashInputExample
mk <- function(b, s) {
  qtlSumStatsFromBetaMatrix(as.matrix(mi[[b]]), as.matrix(mi[[s]]),
    study = "mash")
}
ssl <- list(strong = mk("strong.b", "strong.s"),
  random = mk("random.b", "random.s"), null = mk("null.b", "null.s"))
conds <- colnames(mi$strong.b)
vhat <- diag(length(conds))
dimnames(vhat) <- list(conds, conds)
prior <- mashPriorCovariances(ssl, alpha = 0, vhat = vhat,
  components = "canonical")
#>  - Computing 17 x 625 likelihood matrix.
#>  - Likelihood calculations took 0.01 seconds.
#>  - Fitting model with 625 mixture components.
#>  - Model fitting took 0.02 seconds.
model <- mashModelFit(ssl, alpha = 0, priorCovariances = prior$U,
  vhat = vhat)
#>  - Computing 68 x 573 likelihood matrix.
#>  - Likelihood calculations took 0.02 seconds.
#>  - Fitting model with 573 mixture components.
#>  - Model fitting took 1.20 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.