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) ofQtlSumStats/GwasSumStats; must contain thefitOnentry.- alpha
mash
alpha(forwarded tomashr::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 thelist(U, w, loglik)amashPriorCovariancesresult carries, which is unwrapped to itsU.- 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 modelmashPosteriorconsumes).- inputScale
SumStats -> matrix conversion scale.
- mashDataArgs
Extra arguments for
mashr::mash_set_data(), built withMashDataOptions– for examplezero_Bhat_Shat_resetorzero_Shat_reset.Bhat,Shat,alphaandVare supplied by pecotmr and are refused by the constructor.- mashArgs
Extra arguments for
mashr::mash(), built withMashOptions– for examplenullweight,optmethodorverbose.data,Ulist,outputlevelandseedare owned by pecotmr and are refused by the constructor.- setSeed
Integer seed, or
NULLto 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.