The R markdown is available from the pulldown menu for Code at the upper-right, choose “Download Rmd”, or download the Rmd from GitHub.


In addition to importing networks in network file formats, such as sif and xgmml, Cytoscape also supports importing networks from tabular data. In this vignette, the data table represents protein-protein interaction data from a mass-spectrometry experiment.

Installation

if(!"RCy3" %in% installed.packages()){
    install.packages("BiocManager")
    BiocManager::install("RCy3")
}
library(RCy3)

Getting started

First, launch Cytoscape and keep it running whenever using RCy3. Confirm that you have everything installed and running:

    cytoscapePing()
    cytoscapeVersionInfo()

Background

The data used for this protocol represents interactions between human and HIV proteins by Jäger et al. In this quantitative AP-MS experiment, a relatively small number of bait proteins were used to pull down a larger set of prey proteins.

Note that this tutorial does not describe how to pre-process the raw AP-MS data, the data used here is already scored and filtered.

Import Network

First let’s read in the example data file:

apms.data<-read.csv(file="https://raw.githubusercontent.com/cytoscape/cytoscape-automation/master/for-scripters/R/notebooks/AP-MS/ap-ms-demodata_simple.csv", stringsAsFactors = FALSE)

Now we can create a data frame for the network edges (interactions) using the imported data. We can also add the AP-MS score from the data as an edge attribute:

edges <- data.frame(source=apms.data[,"Bait"],target=apms.data[,"Prey"], AP.MS.Score=apms.data[,"AP.MS.Score"],stringsAsFactors=FALSE)

Finally, we use the edge data frame to create the network. Note that we don’t need to define a data frame for nodes, as all nodes in this case are represented in the edge data frame.

createNetworkFromDataFrames(edges=edges, title="apms network", collection = "apms collection")

The imported network consists of multiple smaller subnetworks, each representing a bait node and its associated prey nodes.

Loading Data

There is one other column of data for the prey proteins that we want to load into this network, the HEKScore.

In this data, the prey nodes are repeated for each interactions with a Bait node, so the data contains different values for the same attribute (for example HEKScore), for each Prey node. During import, the last value imported will overwrite prior values and visualizations using this attribute thus only shows the last value.

loadTableData(apms.data[,c("Prey","HEKScore")], data.key.column="Prey")

The imported network consists of multiple smaller subnetworks, each representing a bait node and its associated prey nodes:

LS0tCnRpdGxlOiAiSW1wb3J0aW5nIE5ldHdvcmsgRnJvbSBUYWJsZSIKYXV0aG9yOiAiS3Jpc3Rpbm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