This is a walkthrough demonstrating how to generate SWNE plots alongside the Seurat manifold alignment pipeline from three pancreas datasets generated using different single cell RNA-seq technologies.
To save time we will be using the pre-computed Seurat object pancreas_integrated_seurat.Robj
, which can be downloaded here.
First let’s load the required libraries
library(Seurat)
library(swne)
Let’s load the Seurat object
se.obj <- readRDS("~/swne/Data/multiple_pancreas_seurat_v3.RObj")
Using the wrapper function RunSWNE
is the simplest way to generate an SWNE embedding for an integrated Seurat object. Just make sure that DefaultAssay(object) == "integrated"
.
genes.embed <- c("REG1A", "PPY", "SST", "GHRL", "VWF", "SOX10")
swne.embedding <- RunSWNE(se.obj, k = 20, genes.embed = genes.embed, snn.exp = 0.25, snn.k = 20)
## [1] "2000 variable genes to use"
## Computing nearest neighbor graph
## Computing SNN
## Initial stress : 0.20444
## stress after 10 iters: 0.05985, magic = 0.500
## stress after 20 iters: 0.05725, magic = 0.500
## stress after 30 iters: 0.05712, magic = 0.500
## stress after 40 iters: 0.05703, magic = 0.500
We can make the SWNE plot
clusters <- se.obj$celltype
PlotSWNE(swne.embedding, alpha.plot = 0.4, sample.groups = clusters, do.label = T,
label.size = 3.5, pt.size = 1.25, show.legend = F, seed = 42)
We also can show that there are no batch effects
batch <- se.obj$tech
PlotSWNE(swne.embedding, alpha.plot = 0.4, sample.groups = batch, do.label = F,
label.size = 3.5, pt.size = 0.15, show.legend = T, seed = 42)
UMAP plot for comparison
umap.emb <- Embeddings(se.obj, "umap")
PlotDims(umap.emb, sample.groups = clusters, show.legend = F, seed = 42,
show.axes = F)