Giter VIP home page Giter VIP logo

r-cytoscape.js's Introduction

r-cytoscape.js

Overview

An HTMLWidgets package for CytoscapeJS which can be used to produce standalone figure or for embedding in Shiny applications.

Install

This package is currently not on CRAN, but you can install it from GitHub via devtools:

library("devtools");
devtools::install_github("cytoscape/r-cytoscape.js");

Sample network

# Load devtools 
library(rcytoscapejs)

id <- c("Jerry", "Elaine", "Kramer", "George")
name <- id
nodeData <- data.frame(id, name, stringsAsFactors=FALSE)

source <- c("Jerry", "Jerry", "Jerry", "Elaine", "Elaine", "Kramer", "Kramer", "Kramer", "George")
target <- c("Elaine", "Kramer", "George", "Jerry", "Kramer", "Jerry", "Elaine", "George", "Jerry")
edgeData <- data.frame(source, target, stringsAsFactors=FALSE)

network <- createCytoscapeJsNetwork(nodeData, edgeData)
rcytoscapejs(network$nodes, network$edges, showPanzoom=FALSE)

##Customizing Network

Customizing the network can be done by appending additional columns on to the original data.frames for the network. The current possible additional columns for nodes are "color", "shape", and "href" (an external link). The colors are hex colors and the options for shapes are from the CytoscapeJS website. For edges, the additional columns are: "color", "sourceShape", "targetShape".

nodeData$color <- rep("#00FF00", nrow(nodeData)) 
nodeData$color[which(grepl("^Elaine$", nodeData$id))] <- "#FF0000"

nodeData$href <- paste0("http://www.google.com/search?q=Seinfeld%20", nodeData$name)

network <- createCytoscapeJsNetwork(nodeData, edgeData)

cytoscapeJsSimpleNetwork(network$nodes, network$edges)

##Embedding in Shiny

It is possible embed Cytoscape.js networks into Shiny applications. The example in current GitHub repository shows a small network with proteins that interact with topoisomerase TOP1, as well as drugs that target the protein. The example Shiny app can be run with the following commands and is stored in inst/examples.

library(shiny)
runShinyApp()

CytoscapeJS possesses many options that are not all captured in the HTMLWidgets functionality; users can fork this repository and edit inst/htmlwidgets/rcytoscapejs.js The sample showcases the use tooltips (from "href" data column), usage of Cytoscape plugins (i.e. panzoom and qtip), returning values from click events on network.

Demo

Screenshot

screenshot

r-cytoscape.js's People

Contributors

taalbrecht avatar cannin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.