extract_lmFit: Extract lmFit model results

View source: R/extract_lmFit.R

extract_lmFitR Documentation

Extract lmFit model results

Description

Extract model fit and significance for all individual variables and/or contrasts in a limma model

Usage

extract_lmFit(
  design,
  fit,
  contrast_mat = NULL,
  dat_genes = NULL,
  name_genes = "geneName",
  contrast.mat = NULL,
  dat.genes = NULL,
  name.genes = NULL
)

Arguments

design

model matrix output by model.matrix( )

fit

MArrayLM model fit output by limma::eBayes( )

contrast_mat

contrast matrix output by limma::makeContrasts( ). NOTE: When using constrasts, the result will not exactly match extract_kmFit due to limma's naming of contrast levels as variableLEVEL

dat_genes

data frame with additional gene annotations. Optional. If not provided, the fit object is also checked for gene annotation information.

name_genes

character for variable name in dat_genes that matches gene names in fit

contrast.mat

Deprecated form of contrast_mat

dat.genes

Deprecated form of dat_genes

name.genes

Deprecated form of name_genes

Value

List with data frames. One for model fit (sigma) and one for significance for all variable and genes. Variables names as in limma::topTable( )

Examples

# Run limma model
design <- model.matrix(~ virus, data = example.voom$targets)
fit <- limma::eBayes(limma::lmFit(example.voom$E, design))

## Get results
fdr <- extract_lmFit(design = design, fit = fit)
## Get results and add gene annotations
fdr <- extract_lmFit(design = design, fit = fit,
                        dat_genes = example.voom$genes)

# Run limma contrasts model
design <- model.matrix(~ 0 + virus, data = example.voom$targets)
fit <- limma::lmFit(example.voom$E, design)
contrast_mat <- limma::makeContrasts(virusHRV-virusnone, levels = design)
fit <- limma::eBayes(limma::contrasts.fit(fit, contrast_mat))

## Get contrast results
fdr <- extract_lmFit(design = design, fit = fit, contrast_mat = contrast_mat)

BIGslu/kimma documentation built on May 30, 2024, 10:09 p.m.