Skip to contents

ExtractResult - convenience function to return statistics for downstream analysis functions such as FgseaList. Returns results from list of dream or lmFit results from those functions natively (use model.fit.list = list(fit)) or from scglmmr::RunVoomLimma and scglmmr::dreamMixedModel

Usage

ExtractResult(
  model.fit.list,
  what = c("statistics", "lmer.z.ranks", "gene.t.ranks")[1],
  coefficient.number,
  coef.name
)

Arguments

model.fit.list

list of model results indexed by celltypes returned by `scglmmr::dreamMixedModel`, `scglmmr::RunVoomLimma`, or manually by `lmFit` or `dream`.

what

what to return what = c('statistics', 'lmer.z.ranks' or 'gene.t.ranks')[1] defaults to statistics for each cell type, e.g. avg exprs, logFC, t statistic, pval, adj.P.Val etc. If gene.z.ranks, ranks genes based on z statistic (mixed models) and returns a list (indexed by celltype of named numeric vector of genes ranked for FgseaList.

coefficient.number

what coefficient to return -- this needs to be one of model.fit.list$coefficients: check the order of the coefficients. Results returned from dream include statistical contrasts and estimated coefficients from the model. If limma::contrasts.fit was used (e.g. if using do_contrast_fit = TRUE in RunVoomLimma), these 'coefficients' are results of the statistical contrast.

coef.name

the name of the estimated coefficient for which results are being returned; if returning results from a statistical contrast e.g. limma::contrasts.fit() this will be the name of the contrast. If returning a model fit with the dream function, can also be contrast specified by from variancePartition::makeContrastsDream() or a fixed effect parameter that was included in the model.

Value

a list of dataframes with contrast results indexed by cell type or a list of genes ranked b t statistic in format ready for FgseaList.