# generate using 
# pkgdown::build_site()

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(SCHNAPPs)

Overview

Shiny app (referred to as "app" in this document) for the exploration and analysis of single cell RNA-Seq data as it comes from 10X or MARS-Seq technologies or other. It has been developed as a responds to user requests by the scientific community of the Cytometry and Biomarkers UTechS at the Institut Pasteur, Paris. The goal is to enable the users (biologists, immunologists) of our platform to explore their single cell RNA-Seqe data, select cells they would like to work with and then perform the final analysis together with the bioinformatics support at Pasteur. We hope you might find it helpful as well.

Installation

if (!require("devtools"))
  install.packages("devtools")
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("BiocSingular")
devtools::install_github("C3BI-pasteur-fr/UTechSCB-SCHNAPPs")

history functionality

To take advantage of the history functionality orca needs to be installed: (https://github.com/plotly/orca#installation)

orca is part of ploty so nothing to be done for R.

Notes:

Running schnapps

The application is started from the command line in R using schnapps().

library(SCHNAPPs)
# create example data
save(file = "filename.RData", "singleCellExperiementObject")
# use "filename.RData" with load data functionality within the shiny app
schnapps()

Optional parameters:

Load data {#loadData}

To load count data there are two formats that are accepted:

To save a singleCellExperiment object in an RData file use:

save(file = "filename.RData", "singleCellExperiementObject")

An example data set is provided with the package. Load a small set of 200 cells and save to a file in the local directory:

data("scEx", package = "SCHNAPPs")
save(file = "scEx.Rdata", list = "scEx")

This file can be loaded once the app is started.

Overview of functionality

Below is the description of the individual tabs/views with the SCHNAPPs application. ^[ During the execution of a task, a message is displayed at the lower right corner. While the message is displayed other requests will wait. Though all mouse clicks and keyboard are normally retained (depending on the OS and computer characteristics), it is recommended to wait until the messages disappeared. Some internal SHINY processes that are not part of the actually SCHNAPPs application might also take considerable time. This can be checked using a monitoring tool (MAC: Activity Monitor).]

knitr::include_graphics('images/overview.png')

Side panel

#TODO remove report button + add comment to history + bookmark
knitr::include_graphics('images/loadingData.png')

Tabs

Input

PleaseNote ^[Since internally we call the singleCellExperiment object scEx, we first search for this name in the RData file. Otherwise the first SingleCellExperiment object is taken. For simplicity it is strongly recommended to have only one SingleCellExperiment in the RData file.
If only the "logcounts" slot is availbale it is taken as the "counts" slot since we require the "counts" slot. This also allows loading only transformed data.
When loading multiple RData files, it is strongly recommended not to use only logcount data as this hasn't been tested well enough.]

Parameters

Normalization

knitr::include_graphics('images/parametersNormalization.png')

In SCHNAPPs there is only one normalization at a time. multiple normalization could be calculated but there is no way to compare them or switch between them.

Source ^[ SeratRefBased
seur.list <- SplitObject(seurDat, split.by = "sampleNames")
for (i in 1:length(seur.list)) {
seur.list[[i]] <- SCTransform(seur.list[[i]])
}
features <- SelectIntegrationFeatures(object.list = seur.list, nfeatures = nfeatures)
#keep.features is the user supplied list of genes
keep.features = keep.features[keep.features %in% rownames(scEx)]
features = unique(c(features, keep.features))
seur.list <- PrepSCTIntegration(object.list = seur.list, anchor.features = features)
reference_dataset <- order(unlist(lapply(seur.list, FUN = function(x) {ncol(x)})), decreasing =T)[1]
anchors <- FindIntegrationAnchors(object.list = seur.list, normalization.method = "SCT", anchor.features = features, k.filter = k.filter, reference = reference_dataset)
integrated <- IntegrateData(anchorset = anchors, normalization.method = "SCT")]

General Parameters

# TODO update with Seurat clustering
# remove side panel
knitr::include_graphics('images/parametersGeneral.png')

The clustering process populates the dbCluster projection. To compare different clustering methods a given dbCluster can be renamed

Quickcluster from the scran package is used for clustering of cells.

tSNE plot

knitr::include_graphics('images/parametersTSNE.png')

Place to change the parameters for the tSNE calculations (Wrapper for the C++ implementation of Barnes-Hut t-Distributed Stochastic Neighbor Embedding. t-SNE is a method for constructing a low dimensional embedding of high-dimensional data, distances or similarities. Exact t-SNE can be computed by setting theta=0.0.) . Rtsne package is used. All PCA components available are used for the calculations. The number of PCs calculated is set under Parameters - General Parameters.

The 3D display is not limited to the tsne projections and can be used in addition to the Co-expression -s Seleccted 2D plot. Special projections like histogram are not available.

Umap

knitr::include_graphics('images/parametersUMAP.png')

Calculation of Umap projections. Since this can be quite time consuming there is a checkbox called “activate Umap projection” that starts the computation. When this is selected all changes in the parameters result in new executions. Thus it should be unchecked while the parameters are changed. The R package uwot is used. The description of the parameters comes directly from the package documentation.


Cell selection

knitr::include_graphics('images/CellSelection.png')

All selections are based on the original input data without filtering genes. In case this is needed, one can apply the gene filter, save the RData file and then apply the cell filters.

Gene selection

knitr::include_graphics('images/geneSelection1.png')
knitr::include_graphics('images/geneSelection2.png')

Co-expression

All clusters

knitr::include_graphics('images/coexpressionAll.png')

Selected

knitr::include_graphics('images/coexpressionSelected1.png')
knitr::include_graphics('images/coexpressionSelected2.png')
knitr::include_graphics('images/coexpressionSelected3.png')

Violin plot

knitr::include_graphics('images/coexpressionViolin1.png')
knitr::include_graphics('images/coexpressionViolin2.png')

SOM cluster

knitr::include_graphics('images/coexpressionSOM1.png')
knitr::include_graphics('images/coexpressionSOM2.png')

A self organizing map is calculated of all the cells. The matrix of normalized counts is used for the clustering. A square SOM with X nodes per dimension is calculated using nEpoch = 10, radius0 = 0, radiusN = 0, radiusCooling = "linear", mapType = "planar", gridType = "rectangular", scale0 = 1, scaleN = 0.01, scaleCooling = "linear" as parameters in the Rsomoclu.train function of the Rsomoclu package. globalBmus is used to identify genes that cluster together. The cluster(s) that contain the gene(s) of interest are returned.

Data Exploration

Expression

knitr::include_graphics('images/dataexplorationExpression.png')

As a convenience the following three plots are combined in one view. Most of the functionality displayed here can also be achieved using other tabs/views.

Panel plot

knitr::include_graphics('images/DataexplorationPanel.png')

2D plots of genes of interest. If the x-axis is a categorical value and the y-axis is UMI.counts the y-axis related to the count for that gene. Otherwise, all genes are used. This plots automatically creates box plots if the x-axis is a categorical value. If a categorical value is chosen for the y-axis an error message is displayed (‘min’ not meaningful for factors). Choosing barcodes as an axis can cause the computer to hang. When y-axis is set to UMI.counts the most useful values for the x-axis are sampleNames or dbCluster, which allows comparing the expression of different genes in parallel over different samples or clusters.

Subcluster analysis

DGE analysis

knitr::include_graphics('images/subclusteranalysis1.png')
knitr::include_graphics('images/subclusteranalysis2.png')

Differential gene expression analysis of selected genes.

Reused GUI elements (Modules)

Tables

knitr::include_graphics('images/table1.png')
knitr::include_graphics('images/tableSelect2.png')
knitr::include_graphics('images/tableReorder.png')
knitr::include_graphics('images/tableAll.png')

A modular table can be downloaded using the “Download Table” button.

2D plots

knitr::include_graphics('images/2Dplot1.png')
knitr::include_graphics('images/2dplotSmallGrp.png')
knitr::include_graphics('images/2dplotAddOptions.png')

Except for the Co-expression - Selected tab the selection of cells is not used.

Comments on groups:

Handling the groups is relatively complex because of the different possibilities especially with selection process within the plot. Once the group is activated (either after selecting a group in the group names dropdown or by clicking on “change current selection” the selected cells are colored red (instead of highlighted when selecting using the box/lasso select). This selection overwrites the selection in the plot. To deactivate this behaviour one has to uncheck the “show more options” check-box. Unfortunately the selection box/highlighting is removed in the plot though the selection is still used in the corresponding visualizations. This can be confusing.

Heatmaps

knitr::include_graphics('images/heatmap1.png')
knitr::include_graphics('images/heatmap2.png')
knitr::include_graphics('images/heatmap3.png')

Like most figures the heatmap is also resizable using the lower right corner that can be dragged.

The color of the samples and clusters can be changed under Parameters - general parameters.

Create input data

under construction.

Please see scranWorkflow for an example or the contributions at https://github.com/baj12/SCHNAPPsContributions

Notes



C3BI-pasteur-fr/UTechSCB-SCHNAPPs documentation built on March 27, 2024, 2:40 a.m.