Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cytoscape/cyjShiny
An R/shiny widget for cytoscape.js
https://github.com/cytoscape/cyjShiny
Last synced: 3 months ago
JSON representation
An R/shiny widget for cytoscape.js
- Host: GitHub
- URL: https://github.com/cytoscape/cyjShiny
- Owner: cytoscape
- License: other
- Created: 2014-08-05T22:21:13.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-06T13:36:17.000Z (6 months ago)
- Last Synced: 2024-05-14T11:32:15.838Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 10.3 MB
- Stars: 91
- Watchers: 20
- Forks: 28
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-shiny-extensions - cyjShiny - R/Shiny widget for Cytoscape.js. (Visualization / Network and Graph Data)
README
## cyjShiny
cyjShiny is a Shiny widget based on [htmlwidgets](http://www.htmlwidgets.org/index.html) for network visualization using [cytoscape.js](https://js.cytoscape.org/).
## 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](https://github.com/cytoscape/cyjShiny/wiki/installation) for compiling cytoscape.js for use with htmlwidgets. NOTE: This should only be used by those actively modifying [cytoscape.js](https://js.cytoscape.org/).
## Quick Start (First cyjShiny App)
* [Shiny Development Basics](https://shiny.rstudio.com/tutorial/)
* [Shiny Extensions for Embedding Javascript Visualizations](https://shiny.rstudio.com/articles/htmlwidgets.html)
* Get Help: `help(package="cyjShiny")`
* Main available features: layouts, node selection, styling, save to PNG, fit graphs to display area
* Quick Start Example:```
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](https://js.cytoscape.org/#style)
* 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](https://cyjshiny.shinyapps.io/basicDemo/) on [shinyapps.io](https://www.shinyapps.io/)
* [basicDemo Code](https://github.com/cytoscape/cyjShiny/tree/master/inst/demos/basicDemo)
* Other Demos:
* quickStartDemo: Demo used in README; [Code](https://github.com/cytoscape/cyjShiny/tree/master/inst/demos/quickStartDemo)
* rmarkdownDemo: Demo for cyjShiny use in R Markdown files; [Code](https://github.com/cytoscape/cyjShiny/tree/master/inst/demos/rmarkdownDemo)
* dataFrameGraphWithPresetNodePositions: Use preset layout to set node positions; [Code](https://github.com/cytoscape/cyjShiny/tree/master/inst/demos/dataFrameGraphWithPresetNodePositions)
* fromCytoscapeDesktop: Load and visualize networks generated in Cytoscape Desktop; [Code](https://github.com/cytoscape/cyjShiny/tree/master/inst/demos/fromCytoscapeDesktop)
* saveAndRestoreLayout: Within a session, save node positions and restore positions for nodes moved after positions saved; [Code](https://github.com/cytoscape/cyjShiny/tree/master/inst/demos/saveAndRestoreLayout)
* withDT: Include at DT table of node values along with the graph visualization; [Code](https://github.com/cytoscape/cyjShiny/tree/master/inst/demos/withDT)