getContrast | R Documentation |
Extract contrast matrix, L, testing a single variable. Contrasts involving more than one variable can be constructed by modifying L directly
getContrast(exprObj, formula, data, coefficient)
exprObj |
matrix of expression data (g genes x n samples), or |
formula |
specifies variables for the linear (mixed) model. Must only specify covariates, since the rows of exprObj are automatically used as a response. e.g.: |
data |
data.frame with columns corresponding to formula |
coefficient |
the coefficient to use in the hypothesis test |
Contrast matrix testing one variable
# load simulated data:
# geneExpr: matrix of gene expression values
# info: information/metadata about each sample
data(varPartData)
# get contrast matrix testing if the coefficient for Batch2 is zero
# The variable of interest must be a fixed effect
form <- ~ Batch + (1 | Individual) + (1 | Tissue)
L <- getContrast(geneExpr, form, info, "Batch3")
# get contrast matrix testing if Batch3 - Batch2 = 0
form <- ~ Batch + (1 | Individual) + (1 | Tissue)
L <- getContrast(geneExpr, form, info, c("Batch3", "Batch2"))
# To test against Batch1 use the formula:
# ~ 0 + Batch + (1|Individual) + (1|Tissue)
# to estimate Batch1 directly instead of using it as the baseline
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.