Flexible linear models

Differential Expression Analysis with limma in R

John Blischak

Instructor

Models for complicated study designs

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

  • $\beta_0$ - Mean in ER-neg
  • $\beta_1$ - Mean difference in ER-pos
  • Test: $\beta_1 = 0$

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

  • $\beta_0$ - Mean in group 1
  • $\beta_1$ - Mean difference in group 2
  • $\beta_2$ - Mean difference in group 3
  • Tests: $\beta_1 = 0$, $\beta_2 = 0$, ???
Differential Expression Analysis with limma in R

Group-means parametrization

$$ Y = \beta_1 X_1 + \beta_2 X_2 + \epsilon $$

  • $\beta_1$ - Mean in ER-neg
  • $\beta_2$ - Mean in ER-pos
  • Test: $\beta_2 - \beta_1 = 0$

$$ Y = \beta_1 X_1 + \beta_2 X_2 + \beta_3 X_3 + \epsilon $$

  • $\beta_1$ - Mean in group 1
  • $\beta_2$ - Mean in group 2
  • $\beta_3$ - Mean in group 3
  • Tests:
    • $\beta_2 - \beta_1 = 0$
    • $\beta_3 - \beta_1 = 0$
    • $\beta_3 - \beta_2 = 0$
Differential Expression Analysis with limma in R

Design matrix for group-means

design <- model.matrix(~0 + er, data = pData(eset))

head(design)
      ernegative erpositive
VDX_3          1          0
VDX_5          0          1
VDX_6          1          0
VDX_7          1          0
VDX_8          1          0
VDX_9          0          1
colSums(design)
ernegative erpositive 
       135        209
Differential Expression Analysis with limma in R

Contrasts matrix

library(limma)
cm <- makeContrasts(status = erpositive - ernegative,
                    levels = design)
cm
            Contrasts
Levels       status
  ernegative     -1
  erpositive      1
Differential Expression Analysis with limma in R

Testing the group-means parametrization

fit <- lmFit(eset, design)
head(fit$coefficients, 3)
          ernegative erpositive
1007_s_at  11.725148  11.823936
1053_at     8.126934   7.580204
117_at      7.972049   7.798623
fit2 <- contrasts.fit(fit, contrasts = cm)
head(fit2$coefficients, 3)
           Contrasts
                 status
  1007_s_at  0.09878782
  1053_at   -0.54673000
  117_at    -0.17342654
Differential Expression Analysis with limma in R

The parametrization does not change the results

# Calculate the t-statistics
fit2 <- eBayes(fit2)
# Count the number of differentially expressed genes
results <- decideTests(fit2)
summary(results)
   status
-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...