Title: | Create Interactive Network Visualizations in R and 'shiny' |
---|---|
Description: | Create Interactive Graph (Network) Visualizations. 'shinyCyJS' can be used in 'Shiny' apps or viewed from 'Rstudio' Viewer. 'shinyCyJS' includes API to build Graph model like node or edge with customized attributes for R. 'shinyCyJS' is built with 'cytoscape.js' and 'htmlwidgets' R package. |
Authors: | Jinhwan Kim [aut, cre, cph] |
Maintainer: | Jinhwan Kim <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.2.0 |
Built: | 2024-11-16 05:20:58 UTC |
Source: | https://github.com/jhk0530/shinyCyJS |
build single Edge element
buildEdge( source = NULL, target, width = 3, curveStyle = "haystack", label = "", fontSize = 16, lineColor = "#FECA57", lineStyle = "solid", sourceArrowColor = "#feca57", targetArrowColor = "#feca57", sourceArrowShape = "none", targetArrowShape = "none", opacity = 1, tooltip = "" )
buildEdge( source = NULL, target, width = 3, curveStyle = "haystack", label = "", fontSize = 16, lineColor = "#FECA57", lineStyle = "solid", sourceArrowColor = "#feca57", targetArrowColor = "#feca57", sourceArrowShape = "none", targetArrowShape = "none", opacity = 1, tooltip = "" )
source |
edge linked node's id. [string] |
target |
edge linked target node's id. [string] |
width |
The width of an edge’s line. [numeric] |
curveStyle |
The curving method used to separate two or more edges between two nodes. [string] |
label |
edge's label [string] |
fontSize |
edge labels font size [numeric] |
lineColor |
The colour of the edge’s line. [string] |
lineStyle |
The style of the edge’s line; may be solid, dotted, or dashed. [string] |
sourceArrowColor |
The colour of the edge’s source arrow. [string] |
targetArrowColor |
The colour of the edge’s target arrow. [string] |
sourceArrowShape |
The shape of the edge’s source arrow. [string] |
targetArrowShape |
The shape of the edge’s target arrow. [string] |
opacity |
Opacity of edge itself. [numeric between 0 ~ 1] |
tooltip |
Text for tooltip. [string] |
List typed Edge element, consisted with data options ( source, target, data ) and style options ( width, curvestyle... )
https://js.cytoscape.org/#style
call buildNode or buildEdge function, note that only one function can be called
buildElems(elems, type)
buildElems(elems, type)
elems |
value of elements consisted in dataframe |
type |
Either 'Node' or 'Edge' [string] |
List typed multiple 'Node' or 'Edge' elements. It consisted with repeated buildNode or buildEdge function results with given parameter.
buildNode(), buildEdge()
nodes <- buildElems( # will generate 5 nodes elems = data.frame( id = paste0("node", 1:5), bgColor = "#FFFFFF", borderColor = "#48DBFB", borderWidth = 2, fontSize = 10, width = 60, height = 20, opacity = 1, stringsAsFactors = FALSE ), type = "Node" )
nodes <- buildElems( # will generate 5 nodes elems = data.frame( id = paste0("node", 1:5), bgColor = "#FFFFFF", borderColor = "#48DBFB", borderWidth = 2, fontSize = 10, width = 60, height = 20, opacity = 1, stringsAsFactors = FALSE ), type = "Node" )
build Interact Option
buildIOptions( minZoom = 1e-50, maxZoom = 1e+50, zoomingEnabled = TRUE, userZoomingEnabled = TRUE, panningEnabled = TRUE, userPanningEnabled = TRUE, boxSelectionEnabled = TRUE, selectionType = "single", autolock = FALSE, autoungrabify = FALSE, autounselectify = FALSE )
buildIOptions( minZoom = 1e-50, maxZoom = 1e+50, zoomingEnabled = TRUE, userZoomingEnabled = TRUE, panningEnabled = TRUE, userPanningEnabled = TRUE, boxSelectionEnabled = TRUE, selectionType = "single", autolock = FALSE, autoungrabify = FALSE, autounselectify = FALSE )
minZoom |
Minimal zoom level of canvas. [numeric] |
maxZoom |
Maximal zoom level of canvas. [numeric] |
zoomingEnabled |
Whether canvas can zoom or not. by both user event and programmatically. [logical] |
userZoomingEnabled |
Whether canvas can zoom or not. by user event. [logical] |
panningEnabled |
Whether canvas can move or not. by both user event and programmatically. [logical] |
userPanningEnabled |
Whether canvas can move or not. by user event. [logical] |
boxSelectionEnabled |
Whether box selection by drag available [logical] |
selectionType |
Indicate selection by user input is additive or single(default). ['single' or 'additive'] |
autolock |
Whether nodes should be locked (not draggable at all) by default (if true, overrides individual node state). [logical] |
autoungrabify |
Whether nodes should be ungrabified (not grabbable by user) by default (if true, overrides individual node state). [logical] |
autounselectify |
Whether nodes should be unselectified (immutable selection state) by default (if true, overrides individual element state). [logical] |
undescribed parameter will set as default. note that touchTapThreshold & desktopTapThreshold were not used.
List typed Interact Option for Cytoscape.js canvas object.
https://js.cytoscape.org/#core/initialisation
iopt <- buildIOptions( minZoom = 0.001, maxZoom = 3, zoomingEnabled = TRUE, userZoomingEnabled = FALSE, panningEnabled = TRUE, userPanningEnabled = TRUE, boxSelectionEnabled = FALSE, selectionType = "single", autolock = FALSE, autoungrabify = TRUE, autounselectify = FALSE )
iopt <- buildIOptions( minZoom = 0.001, maxZoom = 3, zoomingEnabled = TRUE, userZoomingEnabled = FALSE, panningEnabled = TRUE, userPanningEnabled = TRUE, boxSelectionEnabled = FALSE, selectionType = "single", autolock = FALSE, autoungrabify = TRUE, autounselectify = FALSE )
build single node element.
buildNode( id = NULL, width = 15, height = 15, shape = "ellipse", bgColor = "#48DBFB", bgOpacity = 1, bgFill = "solid", bgBlacken = 0, borderWidth = 0, borderStyle = "solid", borderColor = "#8395a7", borderOpacity = 1, isParent = FALSE, label = NULL, labelColor = "#8395a7", textOpacity = 1, fontSize = 16, textOutlineColor = "#222f3e", textOutlineOpacity = 1, textOutlineWidth = 0, textbgColor = "#FFF", textbgOpacity = 0, textBorderColor = "#222f3e", textBorderOpacity = 0, textBorderWidth = 0, parent = NULL, opacity = 1, pieSize = rep("0%", 16), pieColor = rep("#000", 16), tooltip = "", position.x = 0, position.y = 0, textWrap = "none", textAlign = "auto" )
buildNode( id = NULL, width = 15, height = 15, shape = "ellipse", bgColor = "#48DBFB", bgOpacity = 1, bgFill = "solid", bgBlacken = 0, borderWidth = 0, borderStyle = "solid", borderColor = "#8395a7", borderOpacity = 1, isParent = FALSE, label = NULL, labelColor = "#8395a7", textOpacity = 1, fontSize = 16, textOutlineColor = "#222f3e", textOutlineOpacity = 1, textOutlineWidth = 0, textbgColor = "#FFF", textbgOpacity = 0, textBorderColor = "#222f3e", textBorderOpacity = 0, textBorderWidth = 0, parent = NULL, opacity = 1, pieSize = rep("0%", 16), pieColor = rep("#000", 16), tooltip = "", position.x = 0, position.y = 0, textWrap = "none", textAlign = "auto" )
id |
id of node element. Also it will used as label. [string] |
width |
Width. [numeric] |
height |
Height. [numeric] |
shape |
Shape of node body. polygon not accepted. [string] |
bgColor |
Background color of node body. [string] |
bgOpacity |
Opacity of backgroundColor. [numeric between 0 ~ 1] |
bgFill |
The filling style of the node’s body; may be solid (default), linear-gradient, or radial-gradient. [string] |
bgBlacken |
Blackens the node’s body for values from 0 to 1; whitens the node’s body for values from 0 to -1. [numeric between -1 ~ 1] |
borderWidth |
The size of the node’s border. [numeric] |
borderStyle |
The style of the node’s border; may be solid, dotted, dashed, or double. [string] |
borderColor |
The colour of the node’s border. [string] |
borderOpacity |
The opacity of the node’s border. [numeric between 0 ~ 1] |
isParent |
whether this node is parent node or not [logical] |
label |
node's label, default is node's id [string] |
labelColor |
The color of node's label |
textOpacity |
The opacity of the label text, including its outline. [numeric between 0 ~ 1] |
fontSize |
The size of the label text. [numeric] |
textOutlineColor |
The colour of the outline around the element’s label text. [string] |
textOutlineOpacity |
The opacity of the outline on label text. [numeric between 0 ~ 1] |
textOutlineWidth |
The size of the outline on label text. [numeric] |
textbgColor |
colour to apply on the text background. [string] |
textbgOpacity |
The opacity of the label background; the background is disabled for 0 (default value). [numeric between 0 ~ 1] |
textBorderColor |
The colour of the border around the label. [string] |
textBorderOpacity |
The width of the border around the label; the border is disabled for 0 (default value) [numeric between 0 ~ 1] |
textBorderWidth |
The width of the border around the label. [numeric] |
parent |
Indicate which node is parent of this node [string] |
opacity |
Opacity of node itself. [numeric between 0 ~ 1] |
pieSize |
Implement for pie node, consisted with 16 pie size[string] |
pieColor |
Color for each pie part. [string] |
tooltip |
Text for tooltip. [string] |
position.x |
Location value (specify the location of of Node) |
position.y |
Location value (specify the location of of Node) |
textWrap |
Wrap text in label. [string] |
textAlign |
Align text in label. [string] |
List typed Node element, consisted with data options ( id ) and style options ( width, shape... )
https://js.cytoscape.org/#style
build Rendering Option
buildROptions( headless = FALSE, styleEnabled = TRUE, hideEdgesOnViewport = FALSE, textureOnViewport = FALSE, motionBlur = FALSE, motionBlurOpacity = 0.2, wheelSensitivity = 1, pixelRatio = "auto" )
buildROptions( headless = FALSE, styleEnabled = TRUE, hideEdgesOnViewport = FALSE, textureOnViewport = FALSE, motionBlur = FALSE, motionBlurOpacity = 0.2, wheelSensitivity = 1, pixelRatio = "auto" )
headless |
A convenience option that initialises the instance to run headlessly. [logical] |
styleEnabled |
Whether style available or not. [logical] |
hideEdgesOnViewport |
Whether edge will show on canvas manipulation. [logical] |
textureOnViewport |
Whether texture used in canvas manipulation. [logical] |
motionBlur |
Whether use motionBlur effect. [logical] |
motionBlurOpacity |
opacity of motion blur frames [numeric between 0 ~ 1 (transparent)] |
wheelSensitivity |
Changes the scroll wheel sensitivity when zooming. [numeric between 0 (zoom slower) ~ 1 (zoom faster)] |
pixelRatio |
Overrides the screen pixel ratio with a manually set value [numeric] |
undescribed parameter will set as default.
List typed Rendering Option for Cytoscape.js canvas object.
https://js.cytoscape.org/#core/initialisation
ropt <- buildROptions(wheelSensitivity = 0.5)
ropt <- buildROptions(wheelSensitivity = 0.5)
This function is used to download cytoscape image as png.
getPNG()
getPNG()
renders a cytoscape image for output
renderShinyCyJS(expr, env = parent.frame(), quoted = FALSE)
renderShinyCyJS(expr, env = parent.frame(), quoted = FALSE)
expr |
expression that returns a list |
env |
the environment in which to evaluate expr |
quoted |
is expr a quoted expression (with quote()) |
ShinyCyJSOutput()
generate canvas with given network element and options
shinyCyJS( elements = list(), options = list(), layout = list(name = "cose"), width = NULL, height = NULL, elementId = NULL, ... )
shinyCyJS( elements = list(), options = list(), layout = list(name = "cose"), width = NULL, height = NULL, elementId = NULL, ... )
elements |
node and edge objects, it should be list of element. |
options |
rendering / interaction options, can be created with buildIoption(), buildRoption() |
layout |
list type layout, it must be contain name and other optional values |
width |
canvas width. |
height |
canvas height. |
elementId |
id used to identify in application. |
... |
other parameters |
render a renderShinyCyJS() within an application page.
ShinyCyJSOutput(outputId, width = "100%", height = "400px")
ShinyCyJSOutput(outputId, width = "100%", height = "400px")
outputId |
output variable to read the canvas from |
width |
canvas width |
height |
canvas height |
renderShinyCyJS()