Non-linear 2D embedding algorithms can be run through Single-Cell
Toolkit (SCTK) using both interactive shiny application and R console.
For the interactive analysis, the toolkit offers a streamlined workflow
to both compute the embedding and then visualize the results. For the
console analysis, SCTK offers a generic function
runDimReduce()
to compute the 2D embedding.
Methods available with the toolkit include tSNE and UMAP from Seurat [[1]][2][[3]][4] package, tSNE from Rtsne [[5]][6] package and UMAP from scater [7] package.
To view detailed instructions on how to use these methods, please select “Interactive Analysis”, from the tabs below, for the usage in Shiny application or “Console Analysis” for using these methods in R console:
In general, the UI offers options for selection of data items and choice of parameters on the left side, and a visualization panel on the right side of the interface.
Here we show how to generate 2D embedding with the generic function
runDimReduce()
, together with the method to visualize and
explore the results.
1. Compute 2D embedding
sce <- runDimReduce(inSCE = sce, method = "scaterUMAP", useReducedDim = "PCA", reducedDimName = "UMAP")
The generic function runDimReduce()
allows
"scaterUMAP"
from scater, "rTSNE"
from Rtsne, "seuratUMAP"
and
"seuratTSNE"
from Seurat as options of 2D
embedding for method
argument. For detailed parameter
description, please click on the function name to be redirected to its
reference page.
2. Visualization
There are multiple functions that can create scatter plot using
dimensions stored in reducedDims
slot of the SCE
object.
# Make scatter plot without annotation
plotDimRed(sce, useReduction = "UMAP")
# Short-cut for embedding named as "UMAP"
plotUMAP(sce)
# Customizing scatter plot with more information from cell metadata (colData)
plotSCEDimReduceColData(sce, colorBy = "cluster", reducedDimName = "UMAP")
# Color scatter plot with feature expression
plotSCEDimReduceFeatures(sce, feature = "CD8A", reducedDimName = "UMAP")
library(singleCellTK)
sce <- importExampleData("pbmc3k")
sce <- runNormalization(sce, normalizationMethod = "LogNormalize", useAssay = "counts", outAssayName = "logcounts")
sce <- runFeatureSelection(sce, useAssay = "counts", method = "modelGeneVar")
sce <- setTopHVG(sce, method = "modelGeneVar", hvgNumber = 2000, featureSubsetName = "HVG")
sce <- runDimReduce(sce, method = "seuratPCA", useAssay = "logcounts",
scale = TRUE, useFeatureSubset = "HVG", reducedDimName = "PCA",
nComponents = 50)
# Run UMAP on the PCA reducedDim
sce <- runDimReduce(sce, method = "scaterUMAP", useReducedDim = "PCA",
reducedDimName = "UMAP")
# Plot UMAP
plotDimRed(sce, useReduction = "UMAP")
While the runDimReduce()
wrapper function can be used
for all 2D embedding algorithms including tSNE and UMAP, and
additionally for dimension reduction methods like PCA and ICA, separate
functions are also available for all of the included methods. The
following functions can be used for specific methods:
Running tSNE from Rtsne package:
sce <- getTSNE(inSCE = sce, useReducedDim = "PCA", reducedDimName = "TSNE")
Using the Seurat tSNE wrapper is recommended only in the Seurat Curated Workflow.
sce <- runSeuratFindHVG(inSCE = sce, useAssay = "seuratNormData")
sce <- runSeuratPCA(inSCE = sce, useAssay = "seuratNormData", scale = TRUE, reducedDimName = "seuratPCA")
sce <- runSeuratTSNE(inSCE = sce, useReduction = "pca", reducedDimName = "seuratTSNE")
Running UMAP from scater package:
sce <- getUMAP(inSCE = sce, useReducedDim = "PCA", reducedDimName = "UMAP")
Using the Seurat UMAP wrapper is recommended only in the Seurat Curated Workflow.
sce <- runSeuratFindHVG(inSCE = sce, useAssay = "seuratNormData")
sce <- runSeuratPCA(inSCE = sce, useAssay = "seuratNormData", scale = TRUE, reducedDimName = "seuratPCA")
sce <- runSeuratUMAP(inSCE = sce, useReduction = "pca", reducedDimName = "seuratUMAP")