今天是如何在Seurat中处理Slide-seq数据。😎
rm(list = ls())
library(SeuratObject)
library(Seurat)
library(SeuratData)
library(ggplot2)
library(patchwork)
library(dplyr)
今天用到的是小鼠海马体的Slide-seq v2生成的数据集。🙂
在这里,我们读入并执行和之前相似的预处理。😘
#InstallData("ssHippo")
slide.seq <- LoadData("ssHippo")
plot1 <- VlnPlot(slide.seq, features = "nCount_Spatial", pt.size = 0, log = TRUE) + NoLegend()
slide.seq$log_nCount_Spatial <- log(slide.seq$nCount_Spatial)
plot2 <- SpatialFeaturePlot(slide.seq, features = "log_nCount_Spatial") + theme(legend.position = "right")
wrap_plots(plot1, plot2)

然后我们使用sctransform对数据进行归一化,并执行标准的scRNA-seq降维和聚类。😛
library(future)
options(future.globals.maxSize = 8 * 1024^3) # 提到 8 GB,可按内存再调大
plan(multisession, workers = 4)
slide.seq <- SCTransform(slide.seq, assay = "Spatial", ncells = 3000, verbose = FALSE)
slide.seq <- RunPCA(slide.seq)
slide.seq <- RunUMAP(slide.seq, dims = 1:30)
slide.seq <- FindNeighbors(slide.seq, dims = 1:30)
slide.seq <- FindClusters(slide.seq, resolution = 0.3, verbose = FALSE)
可视化!~
plot1 <- DimPlot(slide.seq, reduction = "umap", label = TRUE)
plot2 <- SpatialDimPlot(slide.seq, stroke = 0)
plot1 + plot2

SpatialDimPlot(slide.seq, cells.highlight = CellsByIdentities(object = slide.seq, idents = c(1,
6, 13)), facet.highlight = TRUE)

为了促进Slide-seq数据集的细胞类型注释,我们利用现有的小鼠单细胞RNA-seq海马体数据集。😘
ref <- readRDS("./mouse_hippocampus_reference.rds")
ref <- UpdateSeuratObject(ref)
我们首先运行Seurat的label transfer法来预测每个bead的主要细胞类型。🧐
anchors <- FindTransferAnchors(reference = ref, query = slide.seq, normalization.method = "SCT",
npcs = 50)
predictions.assay <- TransferData(anchorset = anchors, refdata = ref$celltype, prediction.assay = TRUE,
weight.reduction = slide.seq[["pca"]], dims = 1:50)
slide.seq[["predictions"]] <- predictions.assay
然后,我们可以可视化一些主要预期细胞类型的预测分数。😎
DefaultAssay(slide.seq) <- "predictions"
SpatialFeaturePlot(slide.seq, features = c("Dentate Principal cells", "CA3 Principal cells", "Entorhinal cortex",
"Endothelial tip", "Ependymal", "Oligodendrocyte"), alpha = c(0.1, 1))

slide.seq$predicted.id <- GetTransferPredictions(slide.seq)
Idents(slide.seq) <- "predicted.id"
SpatialDimPlot(slide.seq, cells.highlight = CellsByIdentities(object = slide.seq, idents = c("CA3 Principal cells",
"Dentate Principal cells", "Endothelial tip")), facet.highlight = TRUE)

DefaultAssay(slide.seq) <- "SCT"
slide.seq <- FindSpatiallyVariableFeatures(slide.seq, assay = "SCT", slot = "scale.data",
features = VariableFeatures(slide.seq)[1:100],
selection.method = "moransi",
x.cuts = 100, y.cuts = 100
)
现在可视化Moran’s I法确定的前6个特征的表达。🙊
SpatialFeaturePlot(slide.seq,
features = head(SpatiallyVariableFeatures(slide.seq, selection.method = "moransi"),6),
ncol = 3, alpha = c(0.1, 1), max.cutoff = "q95"
)

FindTransferAnchors可用于集成来自空间转录组数据集的点级数据。😛
此外,Seurat v5还支持 Robust Cell Type Decomposition,可以在有scRNA-seq作为参考时从空间数据集中反卷积spot数据的计算方法。🫢
RCTD可以准确注释来自各种技术的空间数据,包括SLIDE-seq、Visium 和 10x Xenium 原位空间平台。
#yulab.utils::install_zip_gh("dmcable/spacexr")
# install.packages("devtools")
#options(timeout = 600000000) ### set this to avoid timeout error
#devtools::install_github("dmcable/spacexr", build_vignettes = FALSE)
library(spacexr)
# set up reference
#ref <- readRDS("./mouse_hippocampus_reference.rds")
ref <- UpdateSeuratObject(ref)
Idents(ref) <- "celltype"
# extract information to pass to the RCTD Reference function
counts <- ref[["RNA"]]$counts
cluster <- as.factor(ref$celltype)
names(cluster) <- colnames(ref)
nUMI <- ref$nCount_RNA
names(nUMI) <- colnames(ref)
reference <- Reference(counts, cluster, nUMI)
# set up query with the RCTD function SpatialRNA
slide.seq <- SeuratData::LoadData("ssHippo")
counts <- slide.seq[["Spatial"]]$counts
coords <- GetTissueCoordinates(slide.seq)
colnames(coords) <- c("x", "y")
coords[is.na(colnames(coords))] <- NULL
query <- SpatialRNA(coords, counts, colSums(counts))
RCTD <- create.RCTD(query, reference, max_cores = 6)
RCTD <- run.RCTD(RCTD, doublet_mode = "doublet")
slide.seq <- AddMetaData(slide.seq, metadata = RCTD@results$results_df)
因为我们在doublet模式下运行RCTD,所以算法会为每个barcode或spot分配一个first_type和second_type。😏
p1 <- SpatialDimPlot(slide.seq, group.by = "first_type")
p2 <- SpatialDimPlot(slide.seq, group.by = "second_type")
p1 | p2
