martedì 16 ottobre 2007

Duplicate a figure with R

The following code attempts to reproduce the Figure 3 (top) in Liao L, Noble WS.
Combining pairwise sequence similarity and support vector machines for detecting remote protein evolutionary and structural relationships. Journal of computational biology. 2003;10(6):857-68 using only the Base graphics system in R.
`jcb.scores = read.delim("clipboard")attach(jcb.scores)pdf("recomb_scores.pdf")par(las =1) # To have horizontal labels for axes 2 and 4plot(y~sort(SVM.pairwise.ROC, decreasing = TRUE), pch = 3, cex = 0.5,xlab = "AUC", ylab = "Number of families", axes = FALSE,xlim = c(0,1), ylim = c(0,60))lines(y~sort(SVM.pairwise.ROC, decreasing = TRUE), lty = 1)points(y~sort(FPS.ROC, decreasing = TRUE), pch = 4, cex = 0.5)lines(y~sort(FPS.ROC, decreasing = TRUE), lty = 2)points(y~sort(SVM.Fisher.ROC, decreasing = TRUE), pch = 8, cex = 0.5)lines(y~sort(SVM.Fisher.ROC, decreasing = TRUE), lty = 3)points(y~sort(SAM.ROC, decreasing = TRUE), pch = 0, cex = 0.5)lines(y~sort(SAM.ROC, decreasing = TRUE), lty = 4)points(y~sort(PSI.BLAST.ROC, decreasing = TRUE), pch = 15, cex = 0.5)lines(y~sort(PSI.BLAST.ROC, decreasing = TRUE), lty = 5)axis(1, at = seq(0,1,0.2), labels = c(0,0.2,0.4,0.6,0.8,1), tcl = 0.25, pos = 0) # tcl = 0.25 small ticks toward the curveaxis(2, at = c(0,10,20,30,40,50,60), labels=c(0,10,20,30,40,50,60), tcl= 0.25 , pos = 0)axis(2, at = c(0,10,20,30,40,60), tcl= 0.25,labels = F, pos = 0)axis(3, tick = T, tcl= 0.25, labels = F, pos = 60)axis(4, at = c(0,10,20,30,40,50), tcl= 0.25, labels = F, pos = 1)axis(4, at = c(0,10,20,30,40,60), tcl= 0.25, labels = F, pos = 1)# To locate the legend interactivelyxy.legend = locator(1)# right-justifying a set of labels: thanks to Uwe Liggestemp <- legend(xy.legend, legend = c("SVM-pairwise", "FPS","SVM-Fisher", "SAM","PSI-BLAST"), text.width = strwidth("SVM-pairwise"), xjust = 1, yjust = 1, lty = c(1,2,3,4,5), pch = c(3,4,8,0,15), bty = "n", cex = 0.8, title = "")dev.off()detach(jcb.scores)`  