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"),
  mashDataArgs = MashDataOptions(),
  mashArgs = MashOptions(),
  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. Either shape the producers return is accepted: a bare named list of covariance matrices (mashCovarianceComponents) or the list(U, w, loglik) a mashPriorCovariances result carries, which is unwrapped to its U.

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.

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.

mashArgs

Extra arguments for mashr::mash(), built with MashOptions – for example nullweight, optmethod or verbose. data, Ulist, outputlevel and seed are owned by pecotmr and are refused by the constructor.

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]]),
    studyName = "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 313 likelihood matrix.
#>  - Likelihood calculations took 0.01 seconds.
#>  - Fitting model with 313 mixture components.
#>  - Model fitting took 0.04 seconds.
model <- mashModelFit(ssl, alpha = 0, priorCovariances = prior,
  vhat = vhat)
#>  - Computing 68 x 287 likelihood matrix.
#>  - Likelihood calculations took 0.02 seconds.
#>  - Fitting model with 287 mixture components.
#>  - Model fitting took 0.36 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.