Contents

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 Cytoscape, network data can be loaded from a variety of sources, and in several different formats. Where you get your network data depends on your biological question and analysis plan. This tutorial outlines how to load network data from several popular sources and formats.

  1. Public databases
  1. Local and remote files
  2. Cytoscape apps (Biopax, KEGG and other formats)

1 Installation

if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")

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

library(RCy3)

2 Getting started

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

    cytoscapePing()
    cytoscapeVersionInfo()

3 Prerequisites

The exercises require you to have certain Cytoscape apps and R packages installed.

installApp('stringApp')
installApp('WikiPathways')

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("ndexr")
BiocManager::install("rWikiPathways")

install.packages("httr")

4 Networks from Public Data

Cytoscape includes a Network Search tool for easy import of public network data. In addition to core apps that are included with your Cytoscape installation (NDEx and PSICQUIC), the resources listed here will depend on which apps you have installed.

getInstalledApps()

5 NDEx

The NDEx Project provides an open-source framework where scientists and organizations can share, store, manipulate, and publish biological network knowledge.

library(ndexr)
ndexcon <- ndex_connect()
networks <- ndex_find_networks(ndexcon, "TP53 AND BARD1")
print(networks[,c("name","externalId","nodeCount","edgeCount")])
networkId = networks$externalId[1]
network = ndex_get_network(ndexcon, networkId)
print(network)
importNetworkFromNDEx(networkId)

6 STRING/STITCH

STRING is a database of known and predicted protein-protein interactions, and STITCH stored known and predicted interactions between chemicals and proteins. Data types include:

To search STRING with the disease keyword “ovarian cancer”, run the following code chunk. (The resulting network will load automatically.)

string.cmd = 'string disease query disease="ovarian cancer"'
commandsRun(string.cmd)
exportImage('ovarian_cancer', 'PNG')
df <- getTableColumns()
View(df)
getEdgeCount() #Before changing interaction confidence level
string.cmd = 'string change confidence confidence=0.9 network=CURRENT'
commandsRun(string.cmd)
getEdgeCount() #After changing interaction confidence level
exportImage('before_expand', 'PNG')
string.cmd = 'string expand network=CURRENT'
commandsRun(string.cmd)
exportImage('after_expand', 'PNG')

7 WikiPathways

WikiPathways is a collaborative wiki platform with manually pathway models. It currently covers over 2,600 pathways in 25 species-specific collections.

library(rWikiPathways)
statin.pathways <- findPathwaysByText('statin')
print(statin.pathways)
human.filter <- lapply(statin.pathways, function(x) x$species == "Homo sapiens")
human.statin.pathways <- statin.pathways[unlist(human.filter)]
lapply(human.statin.pathways, function(x) commandsRun(paste('wikipathways import-as-pathway id=', x$id, sep = '')))

To open the pathway as a network, run the following chunk.

lapply(human.statin.pathways, function(x) commandsRun(paste('wikipathways import-as-network id=', x$id, sep = '')))

WikiPathways model imported as pathway and network.

8 Local and Remote Files

Cytoscape can load locally and remotely stored network data files in a variety of file formats:

8.1 Loading SIF files

SIF is a simple interaction format consisting of three columns of data: source, interaction and target. To learn more about the SIF format, see the Cytoscape manual.

library(httr)
sif_url = "https://cytoscape.github.io/cytoscape-tutorials/protocols/data/galFiltered.sif"
GET(sif_url, write_disk(tf <- tempfile(fileext = ".sif")))
importNetworkFromFile(tf)
  • To see the whole network, run
fitContent()

8.2 Loading XGMML files

XGMML is an XML format and can includes node and edge attributes as well as visual style properties. To learn more about the XGMML format, see the Cytoscape manual.

xgmml_url = "https://raw.githubusercontent.com/cytoscape/cytoscape-tutorials/gh-pages/protocols/data/BasicDataVizDemo.xgmml"
GET(xgmml_url, write_disk(tf <- tempfile(fileext = ".xgmml")))
importNetworkFromFile(tf)
  • This is the same network as in the previous step, but with node fill color corresponding to expression values.