-
Notifications
You must be signed in to change notification settings - Fork 10
/
limma.R
33 lines (26 loc) · 911 Bytes
/
limma.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Identify differentially methylated CpG islands using limma
library(lattice)
library(limma)
library(reshape2)
# Load the CpG island M values.
load('Data/CPGI_MList.Rdata')
# Combine the CTRL and ALL data sets.
data <- rbind(
do.call(cbind, cpgi.M[['CTRL']]),
do.call(cbind, cpgi.M[['ALL']]))
design <- data.frame(
Group=relevel(ref='HBC', factor(substr(rownames(data), 1, 3))),
row.names=rownames(data))
# Fit a linear model.
mm <- model.matrix(~Group, design)
fit <- eBayes(lmFit(t(data), mm))
tt <- topTable(fit, coef='GroupALL', number=Inf, p.value=1e-10)
# Reshape the data.
tall <- melt(cbind(design, data), id.vars=colnames(design),
variable.name = 'probe', value.name = 'M')
# Plot the hits.
stripplot(M ~ Group | probe, tall,
subset = probe %in% tt[1:12,'ID'], auto.key=T)
# Write the gene set to a file.
source('coord_to_gene.R')
writeLines(coordToGene(tt$ID), 'Data/limma-geneset.txt')