Importing data


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.


if(!"RCy3" %in% installed.packages()){

Required Software

The whole point of RCy3 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 network files in any of the supported formats (e.g., SIF, GML, XGMML, etc).

sif <- system.file("extdata","galFiltered.sif",package="RCy3")

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="RCy3")
data <- read.csv(csv, stringsAsFactors = FALSE)

Note: there may be times where your network and data identifers are of different types. This calls for identifier mapping. RCy3 provides a function to perform ID mapping in Cytoscape:


Check out the Identifier mapping vignette for detailed examples.

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:


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.

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


Try the RCy3 package in your browser

Any scripts or data that you put into this service are public.

RCy3 documentation built on Nov. 21, 2020, 2 a.m.