[BioC] a way to select and filter edge attributes in RCytoscape

Paul Shannon pshannon at fhcrc.org
Wed Mar 14 19:55:59 CET 2012

Hi Burak,

On Mar 14, 2012, at 11:30 AM, Burak Kutlu wrote:

> Hi
> Is there a way to filter edges based on edge attributes?

Lifting from    http://rcytoscape.systemsbiology.net/versions/current/cookbook/filterByEda.html

here is how to do it:

  g = makeSimpleGraph ()
  cw = new.CytoscapeWindow ('Edge Selection Demo', g)
  displayGraph (cw)
  layout (cw)
  redraw (cw)
  eda.names (g) #  [1] "edgeType" "score"    "misc"
  eda (g, 'score')
      #  A|B B|C C|A
      #  35 -12   0
  which (eda (g, 'score') >= 0)
      #  A|B C|A
      #   1   3
  names (which (eda (g, 'score') >= 0))   
      # [1] "A|B" "C|A"
  cy2.edge.names (g, names (which (eda (g, 'score') >= 0)))
      #                   A~B                    C~A
      # "A (phosphorylates) B"      "C (undefined) A"
  as.character (cy2.edge.names (g, names (which (eda (g, 'score') >= 0))))
      # [1] "A (phosphorylates) B" "C (undefined) A"
  selectEdges (cw, as.character (cy2.edge.names (g, names (which (eda (g, 'score') >= 0)))))
  getSelectedEdges (cw)
      # [1] "A (phosphorylates) B" "C (undefined) A"

> As an example: Think of selecting a subgraph from a bigger and you want to select on the binding partners.
> Would you rather create separate graphs and look at the intersection?

You could select all binding edges using the technique above

  selectEdges (cw, as.character (cy2.edge.names (g, names (which (eda (g, 'eda') == 'binding'))))) 

Then, from the Cytoscape 'Select' menu, choose 'Nodes connected by selected edges' -- sorry, no RCy method for this yet.
Your original edge selection survives, so now you have all the relevant nodes & edges selected.  In RCy

  cw.new = createWindowFromSelection (cw)

puts the selected subgraph in a new window.  cw.new at graph has the subgraph, all attributes & etc intact.

> Also,  if you have two graphs, what is your best method to merge them and keep the graph attributes?
> Union() will work if the graphs have the same nodes. 

Last I recall, the graph union methods (RBGL? graph-class, maybe igraph) discarded all attributes on edges, preserving (or creating) 'weight'.

You can combine graphs indirectly in RCytocape with 'addGraphToGraph' but requires a CytoscapeWindow to hold the first graph.  
Tell me more about your needs on this, and I will try to come up with something.

 - Paul

> Thanks a lot!
> -burak
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor

More information about the Bioconductor mailing list