Node attributes are handled much the same in Cytoscape and the R graph classes. Arbitrary attributes of a few basic types (integer, double, character string) may be defined, added, and retrieved. Here we show how to identify nodes of a graph which meet criteria based upon those attributes. We use our standard demonstration, the 3-node, 3-edge graph returned by RCytoscape's makeSimpleGraph ().
library (RCytoscape)
g = makeSimpleGraph ()
cw = new.CytoscapeWindow ('Filter Demo', graph=g)
displayGraph (cw);
layoutNetwork (cw);
redraw (cw)
noa.names (g) # display the node attribute names
[1] "type" "lfc" "label" "count"
noa (g, 'count') # display the count attribute values
A B C
2 30 100
noa (g, 'count') > 50
A B C
FALSE FALSE TRUE
which (noa (g, 'count') > 50)
C
3
names (which (noa (g, 'count') > 50))
[1] "C"
selectNodes (cw, names (which (noa (g, 'count') > 50)))
head (noquote (names (which (noa (g.kegg, 'moleculeType') == 'gene'))))
[1] YGR192C YJL052W YJR009C YER073W YOR374W YPL061W