knitr::opts_chunk$set(echo = TRUE)
options(bitmapType="cairo")

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)

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)


yanwu2014/swne documentation built on Aug. 5, 2023, 4:42 a.m.