The limma package

Differential Expression Analysis with limma in R

John Blischak

Instructor

Advantages of the limma package

  • Testing thousands of genes would require lots of boiler plate code
pval <- numeric(length = nrow(x))
r2 <- numeric(length = nrow(x))
for (i in 1:nrow(x)) {
  mod <- lm(x[i, ] ~ p[, "er"])
  result <- summary(mod)
  pval[i] <- result$coefficients[2, 4]
  r2[i] <- result$r.squared
}
  • Improved inference by sharing information across genes

  • Lots of functions for pre- and post-processing (see Ritchie et al., 2015 for an overview)

biocManager::install("limma")
Differential Expression Analysis with limma in R

Specifying a linear model

$$ Y = \beta_0 + \beta_1 X_1 + \epsilon $$

  • $Y$ - Expression level of gene
  • $B_0$ - Mean expression level in ER-negative
  • $B_1$ - Mean difference in expression level in ER-positive
  • $X_1$ - ER status: 0 = negative, 1 = positive
  • $\epsilon$ - Random noise
Differential Expression Analysis with limma in R

Specifying a linear model in R

model.matrix(~<explanatory>, data = <data frame>)
design <- model.matrix(~er, data = pData(eset))
head(design, 2)
      (Intercept) erpositive
VDX_3           1          0
VDX_5           1          1
colSums(design)
(Intercept)  erpositive 
        344         209
table(pData(eset)[, "er"])
negative positive 
     135      209
Differential Expression Analysis with limma in R

Testing with limma

library(limma)
# Fit the model
fit <- lmFit(eset, design)
# Calculate the t-statistics
fit <- eBayes(fit)
# Summarize results
results <- decideTests(fit[, "er"])
summary(results)
   erpositive
-1       6276
0       11003
1        5004
Differential Expression Analysis with limma in R

Let's practice!

Differential Expression Analysis with limma in R

Preparing Video For Download...