This vignette will show you how to convert networks between igraph and Cytoscape.

Installation

source("https://bioconductor.org/biocLite.R")
biocLite("r2cytoscape", "igraph")

Required Software

The whole point of r2cytoscape is to connect with Cytoscape. You will need to install and launch Cytoscape:

From igraph to Cytoscape

The igraph package is a popular network tool among R users. With r2cytoscape, you can easily translate igraph networks to Cytoscape networks!

Here is a basic igraph network construction from the graph_from_data_frame docs:

actors <- data.frame(name=c("Alice", "Bob", "Cecil", "David",
                            "Esmeralda"),
                     age=c(48,33,45,34,21),
                     gender=c("F","M","F","M","F"))
relations <- data.frame(from=c("Bob", "Cecil", "Cecil", "David",
                               "David", "Esmeralda"),
                        to=c("Alice", "Bob", "Alice", "Alice", "Bob", "Alice"),
                        same.dept=c(FALSE,FALSE,TRUE,FALSE,FALSE,TRUE),
                        friendship=c(4,5,5,2,1,1), advice=c(4,5,5,4,2,3))
g <- graph_from_data_frame(relations, directed=TRUE, vertices=actors)

You now have an igraph network, g. In order to translate the network together with all vertex (node) and edge attributes over to Cytoscape, simply use:

createNetworkFromIgraph(g, "myNetwork")

From Cytoscape to igraph

Inversely, you can use createIgraphFromNetwork() in r2cytoscape to retreive vertex (node) and edge data.frames to construct an igraph network.

g2 <- createIgraphFromNetwork("myNetwork")


cytoscape/r2cytoscape documentation built on May 4, 2019, 6:36 p.m.