RCyjs: Interactive R/browser network visualization, using cytoscape.js

Share:

Description

A "Cytoscape ecosystem" exists, with the desktop Cytoscape 3.x as the heavyweight tool, and the browser-based cytoscape.js a very nice and somewhat compatible alternative. The current package, RCyjs, provides programmatic control of cytoscape.js from an R session using the BrowserViz base class. This ensures that both R and the cytoscape.js sessions retain full interactivity. A large portion of the RCyjs API is taken from the RCytoscape package.

Usage

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
RCyjs(portRange, host="localhost", title="RCyjs", graph=graphNEL(),
      hideEdges=FALSE, quiet=TRUE)
simpleDemoGraph()
createTestGraph(nodeCount, edgeCount)
biocGraphToCytoscapeJSON(graph)
noa(graph, node.attribute.name)
eda(graph, edge.attribute.name)
noaNames(graph)
edaNames(graph)


## S4 method for signature 'RCyjsClass'
setGraph(obj, graph, hideEdges)
## S4 method for signature 'RCyjsClass'
addGraph(obj, graph)
## S4 method for signature 'RCyjsClass'
httpAddGraph(obj, graph)
## S4 method for signature 'RCyjsClass'
httpSetStyle(obj, filename)
## S4 method for signature 'RCyjsClass'
setNodeAttributes(obj, attribute, nodes, values)
## S4 method for signature 'RCyjsClass'
getNodeCount(obj)
## S4 method for signature 'RCyjsClass'
getEdgeCount(obj)
## S4 method for signature 'RCyjsClass'
getNodes(obj)
## S4 method for signature 'RCyjsClass'
getNodeSize(obj, nodeIDs)
## S4 method for signature 'RCyjsClass'
getSelectedNodes(obj)
## S4 method for signature 'RCyjsClass'
invertNodeSelection(obj)
## S4 method for signature 'RCyjsClass'
hideSelectedNodes(obj)
## S4 method for signature 'RCyjsClass'
deleteSelectedNodes(obj)
## S4 method for signature 'RCyjsClass'
clearSelection(obj)
## S4 method for signature 'RCyjsClass'
redraw(obj)
## S4 method for signature 'RCyjsClass'
hideAllEdges(obj)
## S4 method for signature 'RCyjsClass'
hideEdges(obj, edgeType)
## S4 method for signature 'RCyjsClass'
showAllEdges(obj)
## S4 method for signature 'RCyjsClass'
showAll(obj)
## S4 method for signature 'RCyjsClass'
showEdges(obj, edgeType)
## S4 method for signature 'RCyjsClass'
setNodeLabelRule(obj, attribute)
## S4 method for signature 'RCyjsClass'
setNodeLabelAlignment(obj, horizontal, vertical)
## S4 method for signature 'RCyjsClass'
setNodeSizeRule(obj, attribute, control.points, node.sizes)
## S4 method for signature 'RCyjsClass'
setNodeColorRule(obj, attribute, control.points, colors, mode)
## S4 method for signature 'RCyjsClass'
setNodeShapeRule(obj, attribute, control.points, node.shapes)
## S4 method for signature 'RCyjsClass'
setEdgeStyle(obj, mode)
## S4 method for signature 'RCyjsClass'
setEdgeColorRule(obj, attribute, control.points, colors, mode)
## S4 method for signature 'RCyjsClass'
setEdgeWidthRule(obj, attribute, control.points, widths, mode)
## S4 method for signature 'RCyjsClass'
setEdgeTargetArrowShapeRule(obj, attribute, control.points, shapes)
## S4 method for signature 'RCyjsClass'
setEdgeTargetArrowColorRule(obj, attribute, control.points, colors, mode)
## S4 method for signature 'RCyjsClass'
setEdgeSourceArrowShapeRule(obj, attribute, control.points, shapes)
## S4 method for signature 'RCyjsClass'
setEdgeSourceArrowColorRule(obj, attribute, control.points, colors, mode)
## S4 method for signature 'RCyjsClass'
layout(obj, strategy)
## S4 method for signature 'RCyjsClass'
layoutStrategies(obj)
## S4 method for signature 'RCyjsClass'
getPosition(obj, nodeIDs=NA)
## S4 method for signature 'RCyjsClass'
setPosition(obj, tbl.pos)
## S4 method for signature 'RCyjsClass'
getSize(obj, nodeIDs=NA)
## S4 method for signature 'RCyjsClass'
getLayout(obj)
## S4 method for signature 'RCyjsClass'
saveLayout(obj, filename)
## S4 method for signature 'RCyjsClass'
restoreLayout(obj, filename)
## S4 method for signature 'RCyjsClass'
getJSON(obj)
## S4 method for signature 'RCyjsClass'
setZoom(obj, newValue)
## S4 method for signature 'RCyjsClass'
getZoom(obj)
## S4 method for signature 'RCyjsClass'
setBackgroundColor(obj, newValue)
## S4 method for signature 'RCyjsClass'
fit(obj, padding)
## S4 method for signature 'RCyjsClass'
fitContent(obj, padding)
## S4 method for signature 'RCyjsClass'
fitSelectedContent(obj, padding)
## S4 method for signature 'RCyjsClass'
hAlign(obj)
## S4 method for signature 'RCyjsClass'
vAlign(obj)
## S4 method for signature 'RCyjsClass'
layoutSelectionInGrid(obj, x, y, w, h)
## S4 method for signature 'RCyjsClass'
layoutSelectionInGridInferAnchor(obj, w, h)
## S4 method for signature 'RCyjsClass'
selectNodes(obj, nodeIDs)
## S4 method for signature 'RCyjsClass'
sfn(obj)
## S4 method for signature 'RCyjsClass'
setDefaultNodeSize(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultNodeHeight(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultNodeShape(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultNodeFontSize(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultNodeBorderColor(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeTargetArrowShape(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeColor(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeTargetArrowColor(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeFontSize(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeWidth(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeLineColor(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeFont(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeFontWeight(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeTextOpacity(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeLineStyle(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeOpacity(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeSourceArrowColor(obj, newValue)
## S4 method for signature 'RCyjsClass'
setDefaultEdgeSourceArrowShape(obj, newValue)

Arguments

portRange

One or more consecutive integers in the range 1025-65535. A typical choice is 9000:9024. The BrowserViz class constructor will try these one at a time in succession until a free port is found and the connection to your web browser is established. If no open ports are found in the supplied range, an error is reported.

host

Nearly always left to its default value, "localhost" but included as a parameter supporting remote computers for future flexibility.

title

The constructor creates a new window (or a new tab, depending on how you web browser is configured). This title is displayed at the top of the window or tab.

graph

A graphNEL object.

quiet

Trace and tracking messages are written to the R console if this variable is set to FALSE.

obj

The RCyjsClass object returned by the class constructor.

newValue

A new size, color, shape (etc.) value to be used in rendering the network.

horizontal

"left", "right", "center": specifies node label position.

vertical

"top", "bottom", "center": specifies node label position.

attribute

Many network rendering rules are controlled by the value of a node or edge attribute. This characacter string is the name of that controlling attribute.

control.points

Values (2 or more) of an edge or node attribute at which color, size (etc) rendering changes.

node.sizes

A list of pixel values.

colors

A list of colors. Well-known names (e.g., "red") can be used. An RGB triplet (red, green blue) will always work, and provides more specificity: "rgb(0, 255, 128)"

mode

either "lookup" for when the controlling node or edge attribute is categorical, or "interpolate" when the attribute is continous.

node.shapes

One of "ellipse", "triangle", "pentagon", "hexagon", "heptagon", "octagon", "star", "rectangle", "roundrectangle".

widths

The width, in pixels, for edges.

shapes

For edge "decorations" – the arrow (and etcetera) that decorates the ends of edges, as they connect to nodes. Currently supported values are "arrow", "tee" and "none" (the default).

strategy

A character string, this names a network layout strategy. Currently supported: "breadthfirst", "circle", "concentric", "cose", "grid", "random".

nodeIDs

Nodes as identified by the "id" field in their cytoscape.js data.

tbl.pos

A 3-column data.frame describing node positions: "id", "x", "y"

filename

A character string representing a valid path in your filesystem.

nodeCount

An integer value for the requested graph.

edgeCount

An integer value for the requested graph.

node.attribute.name

a character string.

edge.attribute.name

a character string.

hideEdges

A logical value. If the graph has many edges, you may wish to hide them initially.

nodes

Character list, node ids.

values

Any type.

edgeType

Character value.

padding

Integer value, pixels.

x

Integer value, pixels.

y

Integer value, pixels.

w

Integer value, pixels.

h

Integer value, pixels.

Author(s)

Paul Shannon

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
   library(RCyjs)

   g <- simpleDemoGraph()  # a 3-node, 3-edge graph with some node and edge attributes
   noaNames(g)
   edaNames(g)

   rcy <- RCyjs(portRange=9047:9057, quiet=TRUE, graph=g);

   title <- "demo"
   setBrowserWindowTitle(rcy, title)

   tbl.nodes <- getNodes(rcy)

   setNodeLabelRule(rcy, "label");
   setNodeSizeRule(rcy, "count", c(0, 30, 110), c(20, 50, 100));
   setNodeColorRule(rcy, "count", c(0, 100), c("rgb(0,255,0)", "rgb(255,0,0)"), mode="interpolate")
   redraw(rcy)
   layout(rcy, "cose")
   closeWebSocket(rcy)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.