runContrasts: Build contrast matrix and calculate contrast fits

View source: R/runContrasts.R

runContrastsR Documentation

Build contrast matrix and calculate contrast fits

Description

Takes a DGEobj and a named list of contrasts to build. The DGEobj must contain a limma Fit object and associated designMatrix. Returns the DGEobj with contrast fit(s), contrast matrix, and topTable/topTreat dataframes added.

Usage

runContrasts(
  dgeObj,
  designMatrixName,
  contrastList,
  contrastSetName = NULL,
  runTopTable = TRUE,
  runTopTreat = FALSE,
  foldChangeThreshold = 1.5,
  runEBayes = TRUE,
  robust = TRUE,
  proportion = 0.01,
  qValue = FALSE,
  IHW = FALSE,
  verbose = FALSE
)

Arguments

dgeObj

A DGEobj object containing a Fit object and design matrix. (Required)

designMatrixName

The name of the design matrix within dgeObj to use for contrast analysis. (Required)

contrastList

A named list of contrasts. (Required)

contrastSetName

Name for the set of contrasts specified in contrastList. Defaults to "<fitName>_cf". Only needed to create 2 or more contrast sets from the same initial fit.

runTopTable

Runs topTable on the specified contrasts. (Default = TRUE)

runTopTreat

Runs topTreat on the specified contrasts. (Default = FALSE)

foldChangeThreshold

Only applies to topTreat (Default = 1.5)

runEBayes

Runs eBayes after contrast.fit (Default = TRUE)

robust

eBayes robust option. 'statmod' package must be installed to perform required calculations if robust = TRUE (Default = TRUE)

proportion

Proportion of genes expected to be differentially expressed. (used by eBayes) (Default = 0.01)

qValue

Set TRUE to include Q-values in topTable output. (Default = FALSE)

IHW

Set TRUE to add FDR values from the IHW package. (Default = FALSE)

verbose

Set TRUE to print some information during processing. (Default = FALSE)

Details

The contrastList is a named list. The values are composed of column names from the designMatrix of the DGEobj. Each contrast is named to give it a short, recognizable name to be used for display purposes.

Example contrastList

contrastList = list(
T1 = "treatment1 - control",
T2 = "treatment2 - control"
)

where treatment1, treatment2, and control are column names in the designMatrix.

The returned DGEobj list contains the new items:

  • "contrastMatrix" a matrix

  • "Fit.Contrasts" a Fit object

  • "topTableList" a List of dataframes

  • "topTreatList" a List of dataframes: if enabled

Value

The DGEobj with contrast matrix, fit and topTable/topTreat dataframes added.

Examples

## Not run: 
  # NOTE: Requires the limma and statmod packages

   myDGEobj <- readRDS(system.file("exampleObj.RDS", package = "DGEobj"))

   # Name the design matrix to be used (see inventory(myDGEobj))
   designMatrixName <- "ReplicateGroupDesign"

   # Define the named contrasts from design matrix column names
   contrastList  <- list(BDL_v_Sham = "ReplicateGroupBDL - ReplicateGroupSham",
                         EXT1024_v_BDL = "ReplicateGroupBDL_EXT.1024  - ReplicateGroupBDL",
                         Nint_v_BDL = "ReplicateGroupBDL_Nint - ReplicateGroupBDL",
                         Sora_v_BDL = "ReplicateGroupBDL_Sora - ReplicateGroupBDL")


   myDGEobj <- runContrasts(myDGEobj,
                            designMatrixName=designMatrixName,
                            contrastList=contrastList,
                            contrastSetName = "SecondContrastSet",
                            qValue = TRUE,
                            IHW = FALSE,
                            runTopTable = TRUE,
                            runTopTreat = TRUE,
                            foldChangeThreshold = 1.25)
   DGEobj::inventory(myDGEobj)

## End(Not run)


DGEobj.utils documentation built on May 20, 2022, 1:08 a.m.