# first, delete existing windows to save memory:
deleteAllWindows(CytoscapeConnection())
window.name <- 'demo addGraphToGraph'
cw3 <- CytoscapeWindow (window.name, graph=makeSimpleGraph ())
displayGraph (cw3)
redraw (cw3)
layoutNetwork(cw3)
# create a new graph, which adds two nodes, and edges between them
# and an existing node, A
g2 <- new("graphNEL", edgemode = "directed")
g2 <- graph::addNode ('A', g2)
g2 <- graph::addNode ('D', g2)
g2 <- graph::addNode ('E', g2)
g2 <- initNodeAttribute (g2, "label", "char", "default node label")
g2 <- initEdgeAttribute (g2, "edgeType", "char", "unspecified")
g2 <- initEdgeAttribute (g2, "probability", "numeric", 0.0)
nodeData (g2, 'D', 'label') <- 'Gene D'
nodeData (g2, 'E', 'label') <- 'Gene E'
g2 <- graph::addEdge ('D', 'E', g2)
g2 <- graph::addEdge ('A', 'E', g2)
edgeData (g2, 'D', 'E', 'probability') <- 0.95
edgeData (g2, 'D', 'E', 'edgeType') <- 'literature'
edgeData (g2, 'A', 'E', 'edgeType') <- 'inferred'
addGraphToGraph (cw3, g2)
redraw (cw3)
layoutNetwork(cw3)
Run the code above in your browser using DataLab