ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/modelit/scripts/plot.R
Revision: 1299
Committed: Tue Jan 11 17:38:33 2011 UTC (9 years, 6 months ago) by hstehr
File size: 4695 byte(s)
Log Message:
adding Model-It server files to repository
Line User Rev File contents
1 hstehr 1299 ## plotting CASP7 benchmarks
2    
3    
4     ### function to plot CASP7 benchmark data
5     # Parameters:
6     # mat: data.frame, 1st column target and 2nd method (bla, pb3, gtg), rest of columns the data series.
7     # title: main title of the plot
8     # seriestitles: the title for each of the series corresponding to the data columns of mat that will appear in the legend
9     # datacols: to use only some selected data columns from mat (otherwise every data column from 3 to the end will be taken)
10     # NOTE: recipe for rotated x-axis labels taken from:
11     # http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f
12    
13     plotCASP7benchmark<- function (mat, title, seriestitles, datacols=c(3:ncol(mat)))
14     {
15    
16     if (length(datacols)!=length(seriestitles)) {
17     stop("Number of datacols and seriestitles length differ! exiting")
18     }
19    
20     # increase margins to make room for rotated labels
21     par(mar=c(7,4,4,2) +0.1)
22    
23     # creating the series vector (to be used for colors and pchs)
24     # as we have 2 columns before the data columns start, we want to map 3 to 1, 4 to 2 and so on
25     # we don't want to use directly the indices of the data cols: we rather go for lower colors
26     # and lower pchs to have simple looking things like circles, triangles and so on
27     series<-c()
28     for (col in datacols) {
29     i<-col-2
30     series<-c(series,i)
31     }
32    
33     # plotting matrix: first 2 columns are target and method, rest are data
34     matplot(mat[,datacols], ylim=c(0,100),axes=FALSE, type="b", lty=1,ylab="gdt_ts",pch=series,col=series, main=title)
35    
36     # no labels, we put them after with text
37     axis(1,at=1:nrow(mat), labels=FALSE)
38     #axis(1,at=1:nrow(mat),labels=mat[,1]) # for normal labels
39    
40     # these are the rotated labels
41     text(1:nrow(mat), par("usr")[3] - 2.00, srt = 90, adj = 1,labels=mat[,1], xpd=TRUE)
42    
43     # and the y axis labels
44     axis(2,at=seq(0,100,10), labels=seq(0,100,10))
45    
46    
47     startypos<-90
48     ypos<-startypos
49     i<-1
50     for (ser in series) {
51     legend(x=nrow(mat)-10,y=ypos, seriestitles[i], lty=1, bty="n", pch=ser,col=ser)
52     ypos<-ypos-5
53     i<-i+1
54     }
55    
56     }
57    
58    
59     ### PLOTS
60    
61    
62     postscript("plots.ps", horizontal=TRUE)
63    
64     ## nopp vs pp20 vs pp30 vs pp20mm0
65     # blast
66     bla<-read.table("nopp_pp20_pp30_pp20mm0_bla")
67     title<-c("CASP7 targets: nopp vs pp20 vs pp30 vs pp20mm0 (blast)")
68     series<-c("nopp","pp20","pp30","pp20mm0")
69     plotCASP7benchmark(bla,title,series)
70    
71     title<-c("CASP7 targets: pp20 vs pp20mm0 (blast)")
72     series<-c("pp20", "pp20mm0")
73     plotCASP7benchmark(bla,title,series,datacols=c(4,6))
74    
75     title<-c("CASP7 targets: pp20 vs pp30 (blast)")
76     series<-c("pp20", "pp30")
77     plotCASP7benchmark(bla,title,series,datacols=c(4,5))
78    
79     #psi blast
80     pb3<-read.table("nopp_pp20_pp30_pp20mm0_pb3")
81     title<-c("CASP7 targets: nopp vs pp20 vs pp30 vs pp20mm0 (psi-blast)")
82     series<-c("nopp","pp20","pp30","pp20mm0")
83     plotCASP7benchmark(pb3,title,series)
84    
85     title<-c("CASP7 targets: pp20 vs pp20mm0 (psi-blast)")
86     series<-c("pp20", "pp20mm0")
87     plotCASP7benchmark(pb3,title,series,datacols=c(4,6))
88    
89     title<-c("CASP7 targets: pp20 vs pp30 (psi-blast)")
90     series<-c("pp20", "pp30")
91     plotCASP7benchmark(pb3,title,series,datacols=c(4,5))
92    
93     #gtg
94     gtg<-read.table("nopp_pp20_pp30_pp20mm0_gtg")
95     title<-c("CASP7 targets: nopp vs pp20 vs pp30 vs pp20mm0 (GTG)")
96     series<-c("nopp","pp20","pp30","pp20mm0")
97     plotCASP7benchmark(gtg,title,series)
98    
99     title<-c("CASP7 targets: pp20 vs pp20mm0 (GTG)")
100     series<-c("pp20", "pp20mm0")
101     plotCASP7benchmark(gtg,title,series,datacols=c(4,6))
102    
103     title<-c("CASP7 targets: pp20 vs pp30 (GTG)")
104     series<-c("pp20", "pp30")
105     plotCASP7benchmark(gtg,title,series,datacols=c(4,5))
106    
107     ## blast vs psiblast vs gtg
108     # bla vs pb3 vs gtg for pp20, max10, cct4
109     all<-read.table("bla_vs_pb3_vs_gtg_pp20_max10_cct4")
110     title<-c("CASP7 targets: blast vs psi-blast vs gtg \n (pp20, max 10, cct 4)")
111     series<-c("blast","psi-blast","GTG")
112     plotCASP7benchmark(all,title,series)
113    
114     # pb3 vs gtg for pp20, max10, cct4
115     all<-read.table("pb3_vs_gtg_pp20_max10_cct4")
116     title<-c("CASP7 targets: psi-blast vs gtg \n (pp20, max 10, cct 4)")
117     series<-c("psi-blast","GTG")
118     plotCASP7benchmark(all,title,series)
119    
120    
121     ## nopp vs pp20mm0 vs pp20mm2_om178_5
122     #blast
123     all<-read.table("nopp_pp20mm0_pp20mm2om_bla")
124     title<-c("CASP7 targets: nopp vs pp20mm0 vs pp20mm2_om178_5 \n(blast)")
125     series<-c("nopp","pp20","pp20mm0","pp20mm2_om178_5")
126     plotCASP7benchmark(all,title,series)
127     #psi-blast
128     all<-read.table("nopp_pp20mm0_pp20mm2om_pb3")
129     title<-c("CASP7 targets: nopp vs pp20mm0 vs pp20mm2_om178_5 \n(psi-blast)")
130     series<-c("nopp","pp20","pp20mm0","pp20mm2_om178_5")
131     plotCASP7benchmark(all,title,series)
132     #GTG
133     all<-read.table("nopp_pp20mm0_pp20mm2om_gtg")
134     title<-c("CASP7 targets: nopp vs pp20mm0 vs pp20mm2_om178_5 \n(GTG)")
135     series<-c("nopp","pp20","pp20mm0","pp20mm2_om178_5")
136     plotCASP7benchmark(all,title,series)
137    
138     dev.off()