The Cytoscape.Window or new.Cytoscape.Window command takes a VERY long time to execute when the number of Nodes is 2482 and number of attributes is 234. The makeSimpleGraph command just took a few seconds in Cytoscape v 2.8.3. At first I thought it was hung, but the cpu is occupied by R.
By the way I wrote functions to load attributes into a graph and edges into a cytoscape window that are reproduced below. In case anyone may find them useful.
# Function to plot the primary cytoscape file
#
syntax: > mywindowname <-
plot.cy(cytoscape.file)
#
plot.cy <-function (cytoscape.file) {
mydata <- new("graphNEL", edgemode='undirected', nodes=as.character(cytoscape.file[, 1]))
# Set up and load all the node attributes
for (i in 2:ncol(cytoscape.file)) {
mydata <- initNodeAttribute (graph=mydata,
attribute.name=names(cytoscape.file[i]), attribute.
type=
'numeric', default.value=
0.0)
nodeData (mydata, n=as.character(cytoscape.file[, 1]), attr=names(cytoscape.file[i])) <- as.numeric(cytoscape.file[,i])
}
# load standard edge attributes
mydata <- initEdgeAttribute (graph= mydata,
attribute.name=
'edgeType', attribute.
type=
'char', default.value=
'undefined')
mydata <- initEdgeAttribute(mydata,
attribute.name =
"Weight", attribute.
type =
"numeric", default.value =
0.0)
return(mydata) }
#
load.an.edge <- function (Cy_Wind, Network.File) {
filename=NULL
a = as.character(Network.File$Gene.1)
b = as.character(Network.File $Gene.2)
nodenames <- unique(c(a,b))
edgeTypes <- levels(as.factor(Network.File$edgeType))
subgraph2 <- new("graphNEL", nodes= nodenames, edgemode='undirected')
subgraph2 <- initEdgeAttribute (graph= subgraph2,
attribute.name=
'edgeType', attribute.
type=
'char', default.value=
'undefined')
subgraph2 <- initEdgeAttribute(subgraph2,
attribute.name =
"Weight", attribute.
type =
"numeric", default.value =
0.0)
subgraph2 = addEdge (as.vector(Network.File$Gene.1, mode="character"), as.vector(Network.File$Gene.2, mode="character"), subgraph2)
edgeData (subgraph2, as.vector(Network.File$Gene.1, mode="character"), as.vector(Network.File$Gene.2, mode="character"), attr='edgeType') <- as.character(Network.File$edgeType)
edgeData (subgraph2, as.vector(Network.File$Gene.1, mode="character"), as.vector(Network.File$Gene.2, mode="character"), attr='Weight') <- Network.File$Weight
addGraphToGraph (Cy_Wind, subgraph2)
redraw(Cy_Wind)
showGraphicsDetails(Cy_Wind, TRUE)
}
###
#
# Function to load multiple edges:
loadedges <- function (Cy_Wind, Network.File) {
filename=NULL
a = as.character(Network.File$Gene.1)
b = as.character(Network.File $Gene.2)
nodenames <- unique(c(a,b))
edgeTypes <- levels(as.factor(Network.File$edgeType))
sepedges <- dlply(Network.File, .(edgeType))
subgraph2 <- new("graphNEL", nodes= nodenames, edgemode='undirected')
subgraph2 <- initEdgeAttribute (graph= subgraph2,
attribute.name=
'edgeType', attribute.
type=
'char', default.value=
'undefined')
subgraph2 <- initEdgeAttribute(subgraph2,
attribute.name =
"Weight", attribute.
type =
"numeric", default.value =
0.0)
#
for(i in 1:length(sepedges)) {
filename[i] <- paste(edgeTypes[i], noquote("edges"), sep=" ", collapse=NULL)
edgefile <- data.frame(sepedges[i])
names(edgefile) <- names(Network.File)
subgraph2 = addEdge (as.vector(edgefile$Gene.1, mode="character"), as.vector(edgefile$Gene.2, mode="character"), subgraph2)
edgeData (subgraph2, as.vector(edgefile$Gene.1, mode="character"), as.vector(edgefile$Gene.2, mode="character"), attr='edgeType') <- as.character(edgefile$edgeType)
edgeData (subgraph2, as.vector(edgefile$Gene.1, mode="character"), as.vector(edgefile$Gene.2, mode="character"), attr='Weight') <-edgefile$Weight
addGraphToGraph (Cy_Wind, subgraph2)
redraw(Cy_Wind)
cat("\n", filename[i], "\n")
}
cat("\n", filename)
showGraphicsDetails(Cy_Wind, TRUE)
}
#