
本内容前期准备参考:
空转上游你可以不做,但不能不会呀!详细演示Visium HD上游公共数据库分析及图像对齐矫正
空转联合单细胞分析(五):10X Visium HD上手就是复杂情况?多样本拼片如何进行拆分?
空转联合单细胞分析(六):10X Visium HD seurat V5分析教程
上一节完成了visium HD在seurat中的分析流程,使用的是标准的聚类流程,
这里介绍的是另外一种用于空间组学数据聚类的方法BANKSY。文章发表在Singhal, V., Chou, N., Lee, J. et al. BANKSY unifies cell typing and tissue domain segmentation for scalable spatial omics data analysis. Nat Genet 56, 431–441 (2024). https://doi.org/10.1038/s41588-024-01664-3。
相关R版包Github链接:
https://github.com/prabhakarlab/Banksy?tab=readme-ov-file python版本链接:https://github.com/prabhakarlab/Banksy_py
空间组学数据通常通过聚类来定义细胞类型和组织空间域。BANKSY(Building Aggregates with a Neighborhood Kernel and Spatial Yardstick)是一种将这两个空间聚类问题统一起来的算法,通过将细胞嵌入到一个由其自身转录组与局部邻域转录组共同构成的乘积空间中,分别代表细胞状态与其微环境。与Seurat不同的是,BANKSY不仅考虑单个bin的表达模式,还会同时纳入其更大空间邻域中基因表达水平的均值和梯度。
#remotes::install_github("prabhakarlab/Banksy")
#remotes::install_github('satijalab/seurat-wrappers')
library(Banksy)
library(SeuratWrappers)
library(Seurat)
library(ggplot2)
library(patchwork)
library(dplyr)加载数据:
#visium HD data
#接上一节的数据,已在seurat读取及完成了正常的基于bins基因表达模式的聚类
load('./hd_obj_filtered.RData')使用RunBanksy函数在seurat object上运行Banksy。使用默认的features = “variable”,使用高变基因创建一个新的assay“BANKSY”,用于后续的降维与聚类分析。
RunBanksy有两个重要参数: k_geom:用于定义局部邻域的 bin 数量。值越大,得到的空间域(domain)越大。 lambda:邻域信息的影响程度。值越大,得到的空间域越具有空间一致性。作者建议将 lambda = 0.8 用于识别较大尺度的空间域。
hd_obj_filtered <- RunBanksy(hd_obj_filtered,
lambda = 0.8, verbose = TRUE,
assay = "Spatial.008um", slot = "data", features = "variable",
k_geom = 50
)## Fetching data from slot data from assay Spatial.008um## Subsetting by features## Warning in asMethod(object): sparse->dense coercion: allocating vector of size
## 3.4 GiB## Computing neighbors...## Spatial mode is kNN_median## Parameters: k_geom=50## Done
## Done## Creating Banksy matrix## Scaling BANKSY matrix. Do not call ScaleData on assay BANKSY## Setting default assay to BANKSY## Warning: Layer counts isn't present in the assay object; returning NULLDefaultAssay(hd_obj_filtered) <- "BANKSY"
hd_obj_filtered <- RunPCA(hd_obj_filtered, assay = "BANKSY", reduction.name = "pca.banksy", features = rownames(hd_obj_filtered), npcs = 30)hd_obj_filtered <- FindNeighbors(hd_obj_filtered, reduction = "pca.banksy", dims = 1:30)
hd_obj_filtered <- FindClusters(hd_obj_filtered, cluster.name = "banksy_cluster", resolution = 0.5)# Arrange so clusters get listed in numerical order
hd_obj_filtered$banksy_cluster <- hd_obj_filtered$banksy_cluster %>%
as.numeric %>% as.factor()
color_pal <- Seurat::DiscretePalette(n = length(unique(hd_obj_filtered$banksy_cluster)),
palette = "polychrome")
SpatialDimPlot(hd_obj_filtered,
group.by = 'banksy_cluster',
pt.size.factor = 8) +
scale_fill_manual(values = color_pal)+
guides(fill=guide_legend(ncol=2))
SpatialDimPlot(hd_obj_filtered,group.by = 'sample_id',label = T) + NoLegend()
这个结果,虽然我们把这8个sample当一张片子做的,但是它还是区分出了WT和T组的区别。两组之间的cluster明显是区别的,很有意思。同时作为kidney,虽然组之间不同,但是空间结构倒是大差不差的区别出来了。RunBanksy聚类与seurat聚类不冲突,实际上是互补的结果,取决于您的研究目的。