-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.frs.pri.R
75 lines (62 loc) · 2.27 KB
/
plot.frs.pri.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
## plot a sort of heatmap of FRs versus nodes
## frs and nodes must already be loaded
source("plot.params.R")
plot.frs.pri = function(xmin=0, xmax=0, ymin=0, ymax=0, xlegend="bottomleft", connect=TRUE) {
sigPri = 200
if (xmin==0) {
xmin = min(as.numeric(rownames(nodes)))
}
if (xmax==0) {
xmax = max(as.numeric(rownames(nodes)))
}
xlim = c(xmin,xmax)
if (ymin==0) {
ymin = min(frs$pri)
}
if (ymax==0) {
ymax = max(frs$pri)
}
ylim = c(ymin, ymax)
xlab = "node"
ylab = "priority"
if (priorityOption==4) {
ylab = paste(ylab, "=", "-log10(p)×100")
}
plot(xlim, rep(sigPri,2), type="l", lty=2, col="lightgray",
xlim=xlim, ylim=ylim,
xlab=xlab, ylab=ylab)
oldNodes = c()
reqNodes = as.numeric(strsplit(sub("\\[","",sub("\\]","",requiredNodes)), ",")[[1]])
for (i in 1:nrow(frs)) {
nodeString = frs$nodes[i]
frNodes = as.numeric(strsplit(sub("\\[","",sub("\\]","",nodeString)), ",")[[1]])
if ((frs$pri[i]>=ymin && frs$pri[i]<=ymax)) {
if (frs$pri[i]>sigPri && frs$OR[i]>1.0) {
color = "darkred"
} else if (frs$pri[i]>sigPri && frs$OR[i]<1.0) {
color = "darkgreen"
} else {
color = "darkgray"
}
points(frNodes, rep(frs$pri[i],length(frNodes)), col=color, pch=0)
if (connect) {
lines(frNodes, rep(frs$pri[i],length(frNodes)), col=color, lwd=1)
}
text(max(frNodes), frs$pri[i], paste(frs$case[i],"/",frs$ctrl[i]), col="black", pos=4, cex=0.7)
for (node in frNodes) {
if (!node%in%oldNodes) {
text(node, frs$pri[i], node, pos=1, col=color, cex=0.7)
oldNodes = c(oldNodes, node)
if (node%in%reqNodes) {
lines(rep(frNodes,2), ylim, lty=3, col=color, lwd=2)
}
}
}
lastFR = frs[i,]
lastFRNodes = frNodes
}
}
points(lastFRNodes, rep(lastFR$pri,length(lastFRNodes)), col=color, pch=15)
text(lastFRNodes, ylim[2]+(ylim[2]-ylim[1])*0.02, lastFRNodes, col=color, cex=0.7)
plot.params(x=xlegend)
}