MyNixOS website logo
Description

Cytoscape.js Shiny Widget (cyjShiny).

Wraps cytoscape.js as a shiny widget. cytoscape.js <https://js.cytoscape.org/> is a Javascript-based graph theory (network) library for visualization and analysis. This package supports the visualization of networks with custom visual styles and several available layouts. Demo Shiny applications are provided in the package code.

R-CMD-check

cyjShiny

cyjShiny is a Shiny widget based on htmlWidgets for network visualization using cytoscape.js.

Installation

From CRAN (Stable Version)

Users should start with CRAN as it is the most stable version:

install.packages("cyjShiny") 

Install from GitHub (Development Version)

library(remotes)
remotes::install_github(repo="cytoscape/cyjShiny", ref="master", build_vignette=TRUE)

Compile cytoscape.js (Javascript Development)

Instructions for compiling cytoscape.js for use with htmlWidgets. NOTE: This should only be used by those actively modifying cytoscape.js.

Quick Start (First cyjShiny App)

library(shiny)
library(cyjShiny)
library(graph)
library(jsonlite)

# NETWORK DATA ----
tbl_nodes <- data.frame(id=c("A", "B", "C"), 
                        size=c(10, 20, 30),
                        stringsAsFactors=FALSE)

# Must have the interaction column 
tbl_edges <- data.frame(source=c("A", "B", "C"),
                        target=c("B", "C", "A"),
                        interaction=c("inhibit", "stimulate", "inhibit"),
                        stringsAsFactors=FALSE)

graph_json <- toJSON(dataFramesToJSON(tbl_edges, tbl_nodes), auto_unbox=TRUE)

# UI ----
ui <- fluidPage(cyjShinyOutput('cyjShiny'))

# SERVER ----
server <- function(input, output, session) {
  output$cyjShiny <- renderCyjShiny({
    # Layouts (see js.cytoscape.org): cola, cose, circle, concentric, grid, breadthfirst, random, fcose, spread
    cyjShiny(graph_json, layoutName="cola")
  })
}

# RUN ----
shinyApp(ui=ui, server=server)

Styling

Many of the visual properties of a network can be stylized.

  • Styling Documentation
  • Example Styling (data() maps data dynamically to specify a property value from the input data.frame):
[
  {"selector":"node", "css": {
    "border-width": "2px",
    "width": "data(size)",
    "height": "data(size)", 
    "content": "data(id)"
  }},
  {"selector": "edge[interaction='stimulate']", "css": {
    "line-color": "green"
  }},
  {"selector": "edge[interaction='inhibit']", "css": {
    "line-color": "red"
  }}
]
  • Styling Usage with Quick Start Example:

Save the example styling to a file style.js in the current working directory and replace cyjShiny() in the Quick Start example as shown below:

cyjShiny(graph_json, layoutName="cola", styleFile="style.js")

Demos

  • Try basicDemo Demo on shinyapps.io
  • basicDemo Code
  • Other Demos:
    • quickStartDemo: Demo used in README; Code
    • rmarkdownDemo: Demo for cyjShiny use in R Markdown files; Code
    • dataFrameGraphWithPresetNodePositions: Use preset layout to set node positions; Code
    • fromCytoscapeDesktop: Load and visualize networks generated in Cytoscape Desktop; Code
    • saveAndRestoreLayout: Within a session, save node positions and restore positions for nodes moved after positions saved; Code
    • withDT: Include at DT table of node values along with the graph visualization; Code.

Metadata

Version

1.0.42

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows