#################################################################################### ## RedeR, dynamic networks in R ## Copyright (C) 2012 CRI-CRUK ## ## Source code to reproduce benchmark for RedeR software. ## ## RedeR program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 2 of the License, or ## (at your option) any later version. ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## ## Mauro Castro - mauro.castro@cancer.org.uk ################################################################################### #---------------------------------------------------------------------------------- #The following code was used to test the performance of six graphics tools available #in R: RedeR, igraph, RCytoscape, igraph/tkplot, Rgraphviz and default R graphics. #The tests quantify the time required to load a scale free network of increasing #size, as defined by the function 'barabasi.game()' available in the igraph package. #---------------------------------------------------------------------------------- ################################################# ### load packages and set graph size vector ################################################# ### packages library(RedeR) library(RCytoscape) library(igraph) library(graph) library(Rgraphviz) library(gplots) ### source to generate series of scale-free netwoks source("./additional_file_3.R") ### object to save results across all tests results <-list() ### graph size settings and number of tests graphseq=gp(2,2,14) ntests=10 ################################################# ### RedeR benchmark ### Version tested: RedeR_1.0.3 ### Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) ### Hardware: MacPro4.1 2 x Quad-core Intel Xeon 2.26 ### GHz, 6 GB ################################################# # start RedeR application rdp<-RedPort() calld(rdp) # check call to be tested... g<-graph.scale.free(n=10, tp="igraph") lt<-layout.random(g) addGraph(rdp,g,lt) #--main call!! resetd(rdp) # rum benchmark: graph size vs. loading time timecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) edgecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) rownames(timecount)<-graphseq rownames(edgecount)<-graphseq for (i in 1:length(graphseq)){ n=graphseq[i] for(j in 1:ntests){ g<-graph.scale.free(n,tp="igraph") edgecount[i,j]<-ecount(g) lt<-layout.random(g) #---get elapsed time timecount[i,j]<-system.time( addGraph(rdp,g,lt) )["elapsed"] #------------------- resetd(rdp) } } # get results results$RedeR$timecount=timecount results$RedeR$edgecount=edgecount results$RedeR$nodecount=graphseq results$RedeR$lab="RedeR" # save results save(results,file="benchmark.RData") ################################################# ### igraph benchmark ### Version tested: igraph_0.5.5-4 ### Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) ### Hardware: MacPro4.1 2 x Quad-core Intel Xeon 2.26 ### GHz, 6 GB ################################################# # check call to be tested... g<-graph.scale.free(n=10, tp="igraph") plot(g) #--main call!! # rum benchmark: graph size vs. loading time timecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) edgecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) rownames(timecount)<-graphseq rownames(edgecount)<-graphseq for (i in 1:length(graphseq)){ n=graphseq[i] for(j in 1:ntests){ g<-graph.scale.free(n, tp="igraph") edgecount[i,j]<-ecount(g) #---get elapsed time timecount[i,j]<-system.time( plot(g) )["elapsed"] #------------------- } } # get results results$igraph$timecount=timecount results$igraph$edgecount=edgecount results$igraph$nodecount=graphseq results$igraph$lab="igraph" # save results save(results,file="benchmark.RData") ################################################# ### RCytoscape-CytoscapeRPC benchmark ### Version tested: RCytoscape_1.4.3 ### Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) ### Hardware: MacPro4.1 2 x Quad-core Intel Xeon 2.26 ### GHz, 6 GB ################################################# # start Cytoscape application (version 2.8.1) # activate CytoscapeRPC plugin (version 1.7) # p.s. further details in RCytoscape vignettes # check call to be tested... g<-graph.scale.free(n=10, tp="graphNEL") cw<-new.CytoscapeWindow('test') displayGraph(setGraph(cw,g)) #--main call!! deleteWindow(cw) # rum benchmark: graph size vs. loading time timecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) edgecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) rownames(timecount)<-graphseq rownames(edgecount)<-graphseq for (i in 1:length(graphseq)){ n=graphseq[i] for(j in 1:ntests){ g<-graph.scale.free(n,tp="graphNEL") cw<-new.CytoscapeWindow('test') edgecount[i,j]<-numEdges(g) #---get elapsed time timecount[i,j]<-system.time( displayGraph(setGraph(cw,g)) )["elapsed"] #------------------- deleteWindow(cw) } } # get results results$RCytoscape$timecount=timecount results$RCytoscape$edgecount=edgecount results$RCytoscape$nodecount=graphseq results$RCytoscape$lab="RCytoscape/CytoscapeRPD" # save results save(results,file="benchmark.RData") ################################################# ### igraph/tkplot benchmark ### Version tested: igraph_0.5.5-4 ### Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) ### Hardware: MacPro4.1 2 x Quad-core Intel Xeon 2.26 ### GHz, 6 GB ################################################# # check call to be tested... g<-graph.scale.free(n=10, tp="igraph") id<-tkplot(g) #--main call!! tkplot.close(id) # rum benchmark: graph size vs. loading time timecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) edgecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) rownames(timecount)<-graphseq rownames(edgecount)<-graphseq for (i in 1:length(graphseq)){ n=graphseq[i] print(n) for(j in 1:ntests){ g<-graph.scale.free(n,tp="igraph") if(ecount(g)>0){ edgecount[i,j]<-ecount(g) #---get elapsed time timecount[i,j]<-system.time( id<-tkplot(g) )["elapsed"] #------------------- tkplot.close(id) } } } # get results results$tkplot$timecount=timecount results$tkplot$edgecount=edgecount results$tkplot$nodecount=graphseq results$tkplot$lab="igraph/tkplot" # save results save(results,file="benchmark.RData") ################################################# ### graph/Rgraphviz-Graphviz benchmark ### Version tested: Rgraphviz_1.32.0 ### Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) ### Hardware: MacPro4.1 2 x Quad-core Intel Xeon 2.26 ### GHz, 6 GB ################################################# # check call to be tested... g<-graph.scale.free(n=10, tp="graph") g<-layoutGraph(g) renderGraph(g) #--main call!! # rum benchmark: graph size vs. loading time timecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) edgecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) rownames(timecount)<-graphseq rownames(edgecount)<-graphseq for (i in 1:length(graphseq)){ n=graphseq[i] print(n) for(j in 1:ntests){ g<-graph.scale.free(n,tp="graph") g<-layoutGraph(g) edgecount[i,j]<-numEdges(g) #---get elapsed time timecount[i,j]<-system.time( renderGraph(g) )["elapsed"] #------------------- } } # get results results$Rgraphviz$timecount=timecount results$Rgraphviz$edgecount=edgecount results$Rgraphviz$nodecount=graphseq results$Rgraphviz$lab="Rgraphviz/Graphviz" # save results save(results,file="benchmark.RData") ################################################# ### Baseline: a trivial test; plot ###..equal number of objects using 'plot()' ###..function (i.e. default R graphics)! ### Version tested: R version 2.14.1 (2011-12-22) ### Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) ### Hardware: MacPro4.1 2 x Quad-core Intel Xeon 2.26 ### GHz, 6 GB ################################################# # check call to be tested... g<-graph.scale.free(n=10, tp="igraph") el<-get.edgelist(g) plot(el,type="b") #--main call!! # rum benchmark: graph size vs. loading time timecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) edgecount<-matrix(NA,nrow=length(graphseq),ncol=ntests) rownames(timecount)<-graphseq rownames(edgecount)<-graphseq for (i in 1:length(graphseq)){ n=graphseq[i] print(n) for(j in 1:ntests){ g<-graph.scale.free(n,tp="igraph") edgecount[i,j]<-ecount(g) el<-get.edgelist(g) #---get elapsed time timecount[i,j]<-system.time( plot(el,type="b") )["elapsed"] #------------------- } } # get results results$baseline$timecount=timecount results$baseline$edgecount=edgecount results$baseline$nodecount=graphseq results$baseline$lab="baseline" # save results save(results,file="benchmark.RData") ########################################## ### Plot results ########################################## plotbenchmark(results)