A frequent need in graph exploration is to identify all the edges which meet a certain criteria. After identifying them, you may wish to select them in the display, delete them, retrieve other attributes, or perhaps render them specially. Here we show how to examine and extract edges whose score attribute is 0 or greater. There are two such edges in the simple graph.
We have to accomodate the difference in edge naming found in Cytoscape and R. A typical edge name in Cytoscape (using our simple graph as an example) is
"A (phosphorylates) B"
In R, the edge is less revealingly named:
"A~B"
To further confuse the issue, the Bioc graph packages sometimes use the name
"A|B"
RCytoscape and Cytoscape use the longer edge name by privileging one of the attributes: this attribute is so
fundamental, and so broadly used, that its value becomes part of the edge name. However, the complexity goes a little
further. In Cytoscape, the priviledged edge attribute is "interaction". In RCytoscape, it is "edgeType". This
difference is managed by the conversion functions in RCytoscape, and should not concern most users.
If you identify edges in the R graph, and wish to use those edge names in the Cytoscape network, you must convert the R edge names to the Cytoscape edge names.
g = makeSimpleGraph ()
cw = new.CytoscapeWindow ('Edge Selection Demo', g)
displayGraph (cw)
layoutNetwork (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"