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 this example, we will import normalized scRNA-seq data and cluster
assignments from local files, generate cell plots, perform differential
expression analysis based on provided categories, visualize as a
combined heatmap and generate networks from the top genes from each
category.
Installation
if(!"RCy3" %in% installed.packages()){
install.packages("BiocManager")
BiocManager::install("RCy3")
}
library(RCy3)
Required software
RCy3 works by connecting with Cytoscape. You will need to install and
launch Cytoscape:
For this vignette, you’ll need the following apps:
#available in Cytoscape 3.7.0 and above
installApp('STRINGapp')
installApp('enhancedGraphics')
installApp('cyBrowser')
installApp('cyPlot')
installApp('scNetViz')
Download test data
You may use your own scRNA-seq data for the next steps. scNetViz
accepts standard outputs from an scRNA-seq processing software such as
CellRanger as inputs. For illustration, the following chunk downloads
and unzips a test data (Accession:
E-GEOD-109979) in the same directory as this R Markdown file.
#Download normalized counts
url_1 <- "https://github.com/cytoscape/cytoscape-tutorials/blob/gh-pages/protocols/data/E-GEOD-109979-normalised-files.zip?raw=true"
fname_1 <- "E-GEOD-109979-normalised-files.zip"
download.file(url_1, fname_1)
unzip(fname_1, overwrite=TRUE, exdir="E-GEOD-109979")
#Download category information
url_2 <- "https://raw.githubusercontent.com/cytoscape/cytoscape-tutorials/gh-pages/protocols/data/E-GEOD-109979.clusters.tsv"
fname_2 <- "E-GEOD-109979.clusters.tsv"
download.file(url_2, fname_2)
Load data from local disk
scNetViz expects complete paths for inputs. Load the normalized count
matrix in the current Cytoscape session. The directory with normalized
counts must have three files only:
- a file with the count matrix in Matrix Market file format,
- a file with the the column names, and
- a file with the the row names.
completeFilePath <- file.path(getwd(), "E-GEOD-109979")
commandToLoadFile <- paste0('scnetviz load experiment file file=',
completeFilePath,
' species=Homo sapiens')
RCy3::commandsRun(commandToLoadFile)
Load the category data
completeFilePath <- file.path(getwd(),
"E-GEOD-109979.clusters.tsv")
commandToAddCategory <- paste0('scnetviz add file category file=',
completeFilePath)
RCy3::commandsRun(commandToAddCategory)
Generate a UMAP plot
scNetViz identifies the loaded data with the file name that was
input, which is E-GEOD-109979
for our case. Next, generate
UMAP plot and display it in the Cytoscape session (this step may take
several minutes to complete). Note that the indexing of rows in the
loaded category file starts with 0.
RCy3::commandsRun('scnetviz calculate UMAP scale=true accession=E-GEOD-109979')
RCy3::commandsRun('scnetviz show cell plot accession=E-GEOD-109979 category=E-GEOD-109979.clusters.tsv categoryRow=0')
Generate heatmap
Generate a heatmap showing the top differentially expressed
genes.
RCy3::commandsRun('scnetviz show diff plot type=Heatmap')
Fetch interaction networks
Fetch interaction networks from the STRING database.
RCy3::commandsRun('scnetviz create network accession=E-GEOD-109979')
LS0tCnRpdGxlOiAic2NOZXRWaXo6IFlvdXIgT3duIHNjUk5BLVNlcSBEYXRhc2V0IgphdXRob3I6ICJLcmlzaG5hIENob3VkaGFyeSwgQWxleCBQaWNvIgpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKLS0tCgpgYGB7ciwgZWNobyA9IEZBTFNFfQprbml0cjo6b3B0c19jaHVuayRzZXQoCiAgZXZhbD1GQUxTRQopCmBgYAoqVGhlIFIgbWFya2Rvd24gaXMgYXZhaWxhYmxlIGZyb20gdGhlIHB1bGxkb3duIG1lbnUgZm9yKiBDb2RlICphdCB0aGUgdXBwZXItcmlnaHQsIGNob29zZSAiRG93bmxvYWQgUm1kIiwgb3IgW2Rvd25sb2FkIHRoZSBSbWQgZnJvbSBHaXRIdWJdKGh0dHBzOi8vcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbS9jeXRvc2NhcGUvY3l0b3NjYXBlLWF1dG9tYXRpb24vbWFzdGVyL2Zvci1zY3JpcHRlcnMvUi9ub3RlYm9va3MvdXNlLWNhc2UtMi5SbWQpLioKCjxociAvPgoKSW4gdGhpcyBleGFtcGxlLCB3ZSB3aWxsIGltcG9ydCBub3JtYWxpemVkIHNjUk5BLXNlcSBkYXRhIGFuZCBjbHVzdGVyIGFzc2lnbm1lbnRzIGZyb20gbG9jYWwgZmlsZXMsIGdlb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