-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinter_limma.R
86 lines (65 loc) · 2.58 KB
/
inter_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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
library(limma)
targets <- readTargets("inter_targets_l2.txt")
x <- read.maimages(targets, source="agilent", green.only=TRUE)
y <- backgroundCorrect(x, method="normexp", offset=16)
png('lplots/inter/pre-norm.png', width=14, height=14, units = 'cm', res=300)
plotDensities(y, legend=FALSE,
col=c('grey8',
'grey15',
'grey22',
'grey29',
'grey36',
'grey43',
'grey50',
'grey57',
'grey64',
'grey71',
'grey78',
'grey85',
'grey92'))
dev.off()
y <- normalizeBetweenArrays(y, method="quantile")
png('lplots/inter/normalized.png', width=14, height=14, units = 'cm', res=300)
plotDensities(y, legend=FALSE,
col=c('grey8',
'grey15',
'grey22',
'grey29',
'grey36',
'grey43',
'grey50',
'grey57',
'grey64',
'grey71',
'grey78',
'grey85',
'grey92'))
dev.off()
y.ave <- avereps(y, ID=y$genes$ProbeName)
# create design
f <- factor(targets$Condition, levels = unique(targets$Condition))
design <- model.matrix(~0 + f)
colnames(design) <- levels(f)
fit <- lmFit(y.ave, design)
contrasts <- c('log_24h-nrp1_24h', 'log_48h-nrp1_48h',
'log_24h-nrp2_24h', 'log_48h-nrp2_48h',
'ctl_24h-nrp1_24h', 'ctl_48h-nrp1_48h',
'ctl_24h-nrp2_24h', 'ctl_48h-nrp2_48h')
for (contrast in contrasts) {
contrast.matrix <- makeContrasts(contrast, levels=design)
fit2 <- contrasts.fit(fit, contrast.matrix)
fit2 <- eBayes(fit2)
output <- topTable(fit2, adjust="BH", coef=contrast, genelist=y.ave$genes, number=Inf)
write.table(output, file=paste("data/inter_contrasts/", contrast, ".txt", sep=""), sep="\t", quote=FALSE)
output <- topTable(fit2, adjust="BH", coef=contrast, genelist=y.ave$genes, number=10)
write.table(output, file=paste("data/inter_contrasts/", contrast, "_top10.txt", sep=""), sep="\t", quote=FALSE)
results <- decideTests(fit2)
png(paste("lplots/inter/ma_", contrast, ".png", sep=""),
width=14, height=14, units = 'cm', res=300)
plotMA(fit2, 1)
dev.off()
png(paste("lplots/inter/volcano_", contrast, ".png", sep=""),
width=14, height=14, units = 'cm', res=300)
volcanoplot(fit2, names=fit2$genes, main=contrast)
dev.off()
}