This vignette will show you how to import a data.frame of node attributes into Cytoscape as Node Table columns. The same approach works for edge and network attriubutes.

Installation

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

Required Software

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

Always Start with a Network

When importing data, you are actually performing a merge function of sorts, appending columns to nodes (or edges) that are present in the referenced network. Data that do not match elements in the network are effectively discarded upon import.

So, in order to demonstrate data import, we first need to have a network. This command will import networks files in any of the supported formats (e.g., SIF, GML, XGMML, etc).

sif <- system.file("extdata","galFiltered.sif",package="r2cytoscape")
commandRun(paste('network load file file',sif,sep = "="))

You should now see a network with just over 300 nodes. If you look at the Node Table, you'll see that there are no attributes other than node names. Let's fix that...

Import Data

You can import data into Cytoscape from any data.frame in R as long as it contains row.names (or an arbitrary column) that match a Node Table column in Cytoscape. In this example, we are starting with a network with yeast identifiers in the "name" column. We also have a CSV file with gene expression data values keyed by yeast identifiers here:

csv <- system.file("extdata","galExpData.csv", package="r2cytoscape")
data <- read.csv(csv)

Now we have a data.frame that includes our identifiers in a column called "name", plus a bunch of data columns. Knowing our key columns, we can now perform the import:

loadTableData(data,data.key.column="name")

Note: we relied on the default values for table ("node") and table.key.column ("name"), but these can be specified as well.

If you look back at the Node Table, you'll now see that the corresponding rows of our data.frame have been imported as new columns.



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