Learn R Programming

RCy3 (version 1.2.0)

addGraphToGraph: addGraphToGraph

Description

Given a CytoscapeWindow containing a graph, this method adds new nodes, edges, and their attributes. Thus, it is the way to extend a graph -- to merge a new graph with an existing one. A typical use would be to add a second KEGG pathway to a CytoscapeWindow upon discovering that two KEGG pathways overlap, which share some enzymes and some reactions. No existing attributes are overwritten.

Usage

addGraphToGraph(obj, other.graph)

Arguments

obj
a CytoscapeWindowClass object.
other.graph
a graph object.

Value

None.

Examples

Run this code
  # 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