-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot-oddsratio.R
46 lines (36 loc) · 1.43 KB
/
plot-oddsratio.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
##
## plot odds ratio vs FR for a run, after combining path support into sample support with get-sample-support.R
##
## sampleSupport
##
## label FR1 FR2 FR3 FR4 FR5 FR6 FR7 FR8 FR9 FR10 FR11 FR12 FR13 FR14
## 339537 case 1 1 0 1 0 0 0 0 0 0 0 0 0 0
## 483736 ctrl 1 1 0 1 1 1 1 1 1 1 1 1 1 1
## 373826 ctrl 1 1 0 1 0 0 0 0 0 0 0 0 0 0
## mergeMode should be set in get-sample-support.R
caseSamples = labelCounts["case",1]/2
ctrlSamples = labelCounts["ctrl",1]/2
oddsratio = data.frame(row.names=colnames(sampleSupport))
oddsratio = oddsratio[rownames(oddsratio)!="label",]
for (fr in colnames(sampleSupport)) {
if (fr!="label") {
cases = sum(sampleSupport[sampleSupport$label=="case",fr])
ctrls = sum(sampleSupport[sampleSupport$label=="ctrl",fr])
oddsratio[fr,"cases"] = cases
oddsratio[fr,"ctrls"] = ctrls
oddsratio[fr,"OR"] = (cases/ctrls) / (caseSamples/ctrlSamples)
}
}
plot(oddsratio$OR,
xlab="FR number",
ylab="<--more controls Odds ratio more cases-->",
xlim=c(0,nrow(oddsratio)+1),
pch=19,
main=paste("Odds Ratio",graphPrefix,"alpha =",alpha,"kappa =",kappa), cex.main=1.0
)
lines(c(1,nrow(oddsratio)), c(1,1), lty=2)
text(oddsratio$OR,
paste(oddsratio[,"cases"],"/",oddsratio[,"ctrls"], sep=""),
pos=4, offset=0.3
)
source("params.R")