RCyjs (version 1.4.0)

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

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

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

Examples

   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)