setwd('data')
Obs.RES=read.table('Obs.RES.txt')
Obs.RES=t(Obs.RES) ## 每个基因在每个gene set里面的running ES score,一个矩阵
Obs.indicator=read.table('Obs.indicator.txt')
Obs.indicator=t(Obs.indicator) ## 每个基因是否属于每个gene set,一个0/1矩阵
obs.s2n=read.table('obs.s2n.txt')[,1] ## 每个基因的signal 2 noise值,已经Z-score化,而且排好序了。
size.G=read.table('size.G.txt')[,1] ## 每个gene set的基因数量,在图中需要显示
gs.names=read.table('gs.names.txt')[,1] ## 每个gene set的名字,在图中需要显示
Obs.arg.ES=read.table('Obs.arg.ES.txt')[,1]## 每个gene set的最大ES score出现在排序基因的位置
Obs.ES.index=read.table('Obs.ES.index.txt')[,1]## 这个用不着的,我也忘记是什么了
Obs.ES=read.table('Obs.ES.txt')[,1] ##每个gene set的最大ES score是多少,如果是正值,用红色表示富集在case组,如果是负值,用蓝色,表示富集在control组。
plot_ES_score
for (i in 1:Ng) {
png(paste0('number_',gs.names[i],'.png'))
ind
min.RES
max.RES
if (max.RES < 0.3) max.RES
if (min.RES > -0.3) min.RES
delta
min.plot
max.plot
max.corr
min.corr
Obs.correl.vector.norm
zero.corr.line
col 0, 2, 4)
# Running enrichment plot
sub.string
main.string
plot(ind, Obs.RES[i,], main = main.string, sub = sub.string, xlab = "Gene List Index", ylab = "Running Enrichment Score (RES)", xlim=c(1, N), ylim=c(min.plot, max.plot), type = "l", lwd = 2, cex = 1, col = col)
for (j in seq(1, N, 20)) {
lines(c(j, j), c(zero.corr.line, Obs.correl.vector.norm[j]), lwd = 1, cex = 1, col = colors()[12]) # shading of correlation plot
}
lines(c(1, N), c(0, 0), lwd = 1, lty = 2, cex = 1, col = 1) # zero RES line
lines(c(Obs.arg.ES[i], Obs.arg.ES[i]), c(min.plot, max.plot), lwd = 1, lty = 3, cex = 1, col = col) # max enrichment vertical line
for (j in 1:N) {
if (Obs.indicator[i, j] == 1) {
lines(c(j, j), c(min.plot + 1.25*delta, min.plot + 1.75*delta), lwd = 1, lty = 1, cex = 1, col = 1) # enrichment tags
}
}
lines(ind, Obs.correl.vector.norm, type = "l", lwd = 1, cex = 1, col = 1)
lines(c(1, N), c(zero.corr.line, zero.corr.line), lwd = 1, lty = 1, cex = 1, col = 1) # zero correlation horizontal line
temp
arg.correl
lines(c(arg.correl, arg.correl), c(min.plot, max.plot), lwd = 1, lty = 3, cex = 1, col = 3) # zero crossing correlation vertical line
leg.txt
text(x=1, y=min.plot, adj = c(0, 0), labels=leg.txt, cex = 1.0)
leg.txt
text(x=N, y=min.plot, adj = c(1, 0), labels=leg.txt, cex = 1.0)
adjx 0, 0, 1)
leg.txt
text(x=Obs.arg.ES[i], y=min.plot + 1.8*delta, adj = c(adjx, 0), labels=leg.txt, cex = 1.0)
leg.txt
text(x=arg.correl, y=min.plot + 1.95*delta, adj = c(adjx, 0), labels=leg.txt, cex = 1.0)
dev.off()
}
}