This vignette will show you how to connect to Cytoscape from R using CyREST. It will cover the installation of required packages and demonstrate some basic functionality of CyREST, commands and r2cytoscape.
It is recommended that your run this vignette prior to Cytoscape Automation workshops to mitigate troubleshooting time.
source("https://bioconductor.org/biocLite.R") biocLite("r2cytoscape")
The whole point of r2cytoscape is to connect with Cytoscape. You will need to install and launch Cytoscape:
This function is a convenient way to verify a connection to Cytoscape. It is also helpful for logging the versions of CyREST and Cytoscape in your scripts.
checkCytoscapeVersion()
Let's create a Cytoscape network from some basic R objects
mynodes <- data.frame(id=c("node 0","node 1","node 2","node 3"), group=c("A","A","B","B"), # optional stringsAsFactors=FALSE) myedges <- data.frame(source=c("node 0","node 0","node 0","node 2"), target=c("node 1","node 2","node 3","node 3"), interaction=c("inhibits","interacts","activates","interacts"), # optional weight=c(5,3,5,9), # optional stringsAsFactors=FALSE) network.name = "myNetwork" collection.name = "myCollection" network.suid <- createNetwork(mynodes,myedges,network.name,collection.name)
Check out the marquee style!
applyStyle('Marquee')
Create your own style with node attribute fill mappings and some defaults
style.name = "myStyle" defaults <- list(NODE_SHAPE="diamond", NODE_SIZE=30, EDGE_TRANSPARENCY=120, NODE_LABEL_POSITION="W,E,c,0.00,0.00") nodeLabels <- mapVisualProperty('node label','id','p') nodeFills <- mapVisualProperty('node fill color','group','d',c("A","B"), c("#FF9900","#66AAAA")) arrowShapes <- mapVisualProperty('Edge Target Arrow Shape','interaction','d',c("activates","inhibits","interacts"),c("Arrow","T","None")) edgeWidth <- mapVisualProperty('edge width','weight','p') createStyle(style.name, defaults, list(nodeLabels,nodeFills,arrowShapes,edgeWidth)) applyStyle(style.name)
r2cytoscape helper functions
help(package=r2cytoscape)
Open swagger docs for live instances of CyREST API and CyREST-supported commands:
openCySwagger() # CyREST API openCySwagger("commands") # CyREST Commands API
List available commands and arguments in R. Use "help" to list top level:
commandHelp("help")
List network commands. Note that "help" is optional:
commandHelp("help network")
List arguments for the network select command:
commandHelp("help network select")
Those are the basics. You are now ready to work with some real data! See other basic and advanced R tutorials.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.