Seurat 4.3.0 | 数据集坐标映射

2023-03-19  本文已影响0人  可爱的一只帆

一、数据集准备

  1. 参考数据集(reference )
  2. 查询数据集(query )
  3. 参考数据集和查询数据集整合之后的数据集(anchors)

建议数据集在使用前进行NormalizeData、FindVariableFeatures、RunUMAP等常规预处理操作。

二、寻找锚点,投影数据集

library(Seurat)
library(dplyr)
library(ggforce)
#reference <- RunUMAP(reference, dims = 1:30, reduction = "pca", return.model = TRUE)
anchors <- FindTransferAnchors(reference = reference, query = query,
             dims = 1:30,#可以自己调节 
             reference.reduction = "pca")#官方建议scRNA-seq数据集使用PCA
Query <- MapQuery(anchorset = anchors, reference = reference, query = query, 
                  refdata = list(celltype = "celltype"), 
                  reference.reduction = "pca",
                  reduction.model = "umap")

常见报错:Error: The provided reduction.model does not have a model stored. Please try running umot-learn on the object first.
解决方法:RunUMAP的时候加上return.model = TRUE

三、可视化
可视化投影结果,和参考数据集对比:

p1 <- DimPlot(reference,reduction = "umap",label = TRUE,raster=FALSE)
p2 <- DimPlot(Query, reduction = "ref.umap",label = TRUE,raster=FALSE)
p1|p2

画个桑基图看不同注释结果的拟合程度:

head(Query@meta.data)
#                         nCount_RNA nFeature_RNA Cluster celltype
#AAACCTGAGCTGTTCA.11_4       7913         2339       6      Comp
#AAAGCAAGTGCCTGTG.11_4       1845          856       2    Lrrc15
#AACACGTCAAGAAGAG.11_4      12460         2890       6      Comp
#AACCATGAGATCACGG.11_4       3497         1577       0   Col15a1
#AACGTTGAGATCTGAA.11_4       8999         2487       5      Npnt
#AACGTTGCACGAGGTA.11_4      12018         2369       4    Cxcl12
#                           Tissue        orig.ident
#AAACCTGAGCTGTTCA.11_4 Artery HFD 16WK         PS
#AAAGCAAGTGCCTGTG.11_4 Artery HFD 16WK         PS
#AACACGTCAAGAAGAG.11_4 Artery HFD 16WK         PS
#AACCATGAGATCACGG.11_4 Artery HFD 16WK         PS
#AACGTTGAGATCTGAA.11_4 Artery HFD 16WK         PS
#AACGTTGCACGAGGTA.11_4 Artery HFD 16WK         PS
#                      predicted.celltype.score predicted.celltype
#AAACCTGAGCTGTTCA.11_4                0.7243527            Col15a1
#AAAGCAAGTGCCTGTG.11_4                0.7817366              Acta2
#AACACGTCAAGAAGAG.11_4                0.6213131               Comp
#AACCATGAGATCACGG.11_4                0.9919202            Col15a1
#AACGTTGAGATCTGAA.11_4                0.8128144              Acta2
#AACGTTGCACGAGGTA.11_4                0.6597668               Comp
Query@meta.data %>%  na.omit() %>%
  gather_set_data(c(4,3,5)) %>% #选中想查看的列
  ggplot(aes(x, id = id, split = y, value = 1))  +
  geom_parallel_sets(aes(fill = celltype ), alpha = 0.3) +
  geom_parallel_sets_axes(axis.width = 0.1, color = "black", fill = "white") +
  geom_parallel_sets_labels(angle = 0) +
  theme_no_axes()

参考:Function reference • Seurat (satijalab.org)
Cell, 2019, 177(7): 1888–1902.e21.

上一篇 下一篇

猜你喜欢

热点阅读