Seurat3.0 整合与标签转换
整合与标签转换
Integration and Label Transfer
1.描述在预印版上的方法
组装多种scRNA数据集到一种
Assembly of multiple distinct scRNA-seq datasets into an integrated reference
转换标签
Transfer of cell type labels from a reference dataset onto a new query dataset
样本
human pancreatic islet cell datasets
CelSeq (GSE81076) CelSeq2 (GSE85241), Fluidigm C1 (GSE86469), and SMART-Seq2 (E-MTAB-5061)
提供了一个合并的raw data矩阵和metadata文件
install.packages("Seurat")
把很多命令做了个汇总
数据集预处理
载入表达量和metadata矩阵,metadata包含了
library(Seurat)
pancreas.data <- readRDS(file = "../data/pancreas_expression_matrix.rds")
metadata <- readRDS(file = "../data/pancreas_metadata.rds")
image.png
metadata
metadata包含了,细胞 以及对应的分组和celltype
为了重构参考,鉴定各个数据集的 'anchor',将合并的object分割成单个
pancreas <- CreateSeuratObject(counts = pancreas.data, meta.data = metadata)
pancreas.list <- SplitObject(object = pancreas, split.by = "tech")
在找'anchor'之前,进行标准的预处理(取对数进行标准化),并且对每个'anchor'单独识别变量
找最高变的2000个基因
for (i in 1:length(x = pancreas.list)) {
pancreas.list[[i]] <- NormalizeData(object = pancreas.list[[i]], verbose = FALSE)
pancreas.list[[i]] <- FindVariableFeatures(object = pancreas.list[[i]], selection.method = "vst", nfeatures = 2000, verbose = FALSE)
}
默认采用2000个VariableFeatures寻找anchors
整合3个胰岛细胞数据集
接着使用 FindIntegrationAnchors
这个函数鉴定anchors,需要用到Seurat objects作为输入,文档这里的例子用3个样本的Seurat objects整合成一个
- 这里用到的都是默认的参数,比如数据集的维度用30,自己也可以尝试更大的范围,比如10到50之间的值
reference.list <- pancreas.list[c("celseq", "celseq2", "smartseq2")]
pancreas.anchors <- FindIntegrationAnchors(object.list = reference.list, dims = 1:30)
image.png
用IntegrateData
函数处理上一步的anchors,得到一个Seurat对象
这个对象包含了所有细胞的表达量矩阵,可以进行下游分析
pancreas.integrated <- IntegrateData(anchorset = pancreas.anchors, dims = 1:30)
pancreas.integrated
pancreas.integrated 的内容
pancreas.integrated
在运行IntegrateData后,Seurat对象包含了一个有表达量矩阵的新Assay。 原始(未校正的值)仍存储在“RNA”分析中的对象中,我们可以进行来回切换。
然后我们可以使用这个新的集成矩阵进行下游分析和可视化。 在这里,我们扩展集成数据,运行PCA,并使用UMAP可视化结果。 集成数据集按cell 类型而不是cluster。
library(ggplot2)
library(cowplot)
# 切换到 integrated assay.
# IntegrateData
DefaultAssay(object = pancreas.integrated) <- "integrated"
# 进行可视化和聚类
pancreas.integrated <- ScaleData(object = pancreas.integrated, verbose = FALSE)
pancreas.integrated <- RunPCA(object = pancreas.integrated, npcs = 30, verbose = FALSE)
pancreas.integrated <- RunUMAP(object = pancreas.integrated, reduction = "pca", dims = 1:30)
p1 <- DimPlot(object = pancreas.integrated, reduction = "umap", group.by = "tech")
p2 <- DimPlot(object = pancreas.integrated, reduction = "umap", group.by = "celltype", label = TRUE,
repel = TRUE) + NoLegend()
plot_grid(p1, p2)
image.png
使用整合的reference 进行细胞类型分类
Seurat v3 also supports the projection of reference data (or meta data) onto a query object. While many of the methods are conserved (both procedures begin by identifying anchors), there are two important distinctions between data transfer and integration:
In data transfer, Seurat does not correct or modify the query expression data.
In data transfer, Seurat has an option (set by default) to project the PCA structure of a reference onto the query, instead of learning a joint structure with CCA. We generally suggest using this option when projecting data between scRNA-seq datasets.
After finding anchors, we use the TransferData function to classify the query cells based on reference data (a vector of reference cell type labels). TransferData returns a matrix with predicted IDs and prediction scores, which we can add to the query metadata.
pancreas.query <- pancreas.list[["fluidigmc1"]]
pancreas.anchors <- FindTransferAnchors(reference = pancreas.integrated, query = pancreas.query,
dims = 1:30)
predictions <- TransferData(anchorset = pancreas.anchors, refdata = pancreas.integrated$celltype,
dims = 1:30)
pancreas.query <- AddMetaData(object = pancreas.query, metadata = predictions)
这一步处理后,query metadata的信息
pancreas.query$prediction.match <- pancreas.query$predicted.id == pancreas.query$celltype
table(pancreas.query$prediction.match)
image.png##
## FALSE TRUE
## 16 622
因为我们从完整的综合分析中获得了原始标签注释,所以我们可以评估我们预测的细胞类型注释与完整参考的匹配程度。 在这个例子中,我们发现细胞类型分类有很高的一致性,超过97%的细胞被正确标记。
image.png为了进一步验证这一点,我们可以检查特定胰岛细胞群的一些经典细胞类型标记。 请注意,即使这些细胞类型中的一些仅由一个或两个细胞(例如ε细胞)表示,我们仍然能够正确地对它们进行分类。
VlnPlot(pancreas.query, c("REG1A", "PPY", "SST", "GHRL", "VWF", "SOX10"), group.by = "predicted.id")
image.png