Differential Expression Analysis with limma in R
John Blischak
Instructor
Visualize with plotDensities
3 steps:
top2b <- which(fData(eset)[, "symbol"] == "Top2b")
boxplot(
exprs(eset)[top2b, ] ~ pData(eset)[, "genotype"],
main = fData(eset)[top2b, ]
)
# Plot principal components labeled by genotype
plotMDS(eset, labels = pData(eset)[,"genotype"], gene.selection = "common")
# Plot principal components labeled by treatment
plotMDS(eset, labels = pData(eset)[,"treatment"], gene.selection = "common")
# Create single variable
group <- with(pData(eset),
paste(genotype, treatment, sep = "."))
group <- factor(group)
# Create design matrix with no intercept
design <- model.matrix(~0 + group)
colnames(design) <- levels(group)
# Create a contrasts matrix
cm <- makeContrasts(dox_wt = wt.dox - wt.pbs,
dox_top2b = top2b.dox - top2b.pbs,
interaction = (top2b.dox - top2b.pbs) -
(wt.dox - wt.pbs),
levels = design)
# Fit the model
fit <- lmFit(eset, design)
# Fit the contrasts
fit2 <- contrasts.fit(fit, contrasts = cm)
# Calculate the t-statistics for the contrasts
fit2 <- eBayes(fit2)
topTable
and hist
# Extract the gene symbols
gene_symbols <- fit2$genes[, "symbol"]
# Create a volcano plot for the contrast dox_wt
volcanoplot(fit2, coef = "dox_wt", highlight = 5, names = gene_symbols)
# Extract the entrez gene IDs
entrez <- fit2$genes[, "entrez"]
# Test for enriched KEGG Pathways for contrast dox_wt
enrich_dox_wt <- kegga(fit2, coef = "dox_wt", geneid = entrez,
species = "Mm")
# View the top 4 enriched KEGG pathways
topKEGG(enrich_dox_wt, number = 4)
Pathway
path:mmu05322 Systemic lupus erythematosus
path:mmu03008 Ribosome biogenesis in eukaryotes
path:mmu05034 Alcoholism
path:mmu05412 Arrhythmogenic right ventricular cardiomyopathy (ARVC)
N Up Down P.Up P.Down
path:mmu05322 76 37 1 3.657708e-10 9.999999e-01
path:mmu03008 71 34 4 3.320811e-09 9.997410e-01
path:mmu05034 130 47 17 2.358456e-07 9.733029e-01
path:mmu05412 52 2 26 9.995025e-01 4.140466e-07
Differential Expression Analysis with limma in R