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 example, the data table represents protein-protein interaction data from a mass-spectrometry experiment.
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
if(!"RCy3" %in% installed.packages())
BiocManager::install("RCy3")
library(RCy3)
First, launch Cytoscape and keep it running whenever using RCy3. Confirm that you have everything installed and running:
cytoscapePing()
## [1] "You are connected to Cytoscape!"
cytoscapeVersionInfo()
## apiVersion cytoscapeVersion
## "v1" "3.8.0-SNAPSHOT"
The data used for this protocol represents interactions between human and HIV proteins by Jäger et al (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3310911/). In this quantitative AP-MS experiment, a relatively small number of bait proteins are 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.
Let’s start by reading 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.csv", stringsAsFactors = FALSE)
Now we can create a data frame for the network edges (interactions) using the imported data. We will add an interaction “AP-MS” to each edge, which will be useful later, and 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"],interaction="AP-MS", AP.MS.Score=apms.data[,"AP.MS.Score"],stringsAsFactors=FALSE)
Finally, we use the edge data fram 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")
## Loading data...
## Applying default style...
## Applying preferred layout...
## networkSUID
## 6314
The imported network consists of multiple smaller subnetworks, each representing a bait node and its associated prey nodes
There are three other columns of data and annotations for the “Prey” proteins that we want to load into this network.
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[,2:5], data.key.column="Prey")
## [1] "Success: Data loaded in defaultnode table"
The imported network consists of multiple smaller subnetworks, each representing a bait node and its associated prey nodes:
exportImage()
## Warning: This file already exists. A Cytoscape popup
## will be generated to confirm overwrite.
## file
## "C:\\Users\\kozon\\Documents\\gsod2019_kozo_nishida\\apms network.png"
knitr::include_graphics('apms network.png')