SpaGene 空间转录组高级分析:空间可变基因与受配体共定位
背景介绍
方法原理
给定一组空间位置,SpaGene 首先使用 k-近邻 构建空间网络。
对于每个基因,SpaGene 然后从 k-近邻图中提取一个子网络,该子网络仅包含高表达该基因的细胞/点。
SpaGene 通过计算子网络的度分布与完全连接的网络的度分布之间的 Earth Mover's Distance(地球移动距离,EMD) 来量化子网络的连接性。
最后,SpaGene 将观察到的距离与通过随机置换得到的期望距离进行比较。
方法应用
SpaGene 通过量化基因表达的空间聚集性,识别空间可变基因及其分布模式。
受配体共定位 通过分析配体和受体在空间上的共表达模式,揭示细胞间通信的潜在机制。
结合 SpaGene 和受配体共定位分析,可以更全面地研究空间转录组数据中的生物学意义。
SpaGene 的计算结果
library(SpaGene)
library(Seurat)
library(pheatmap)
library(ggplot2)
library(stringr)
library(tibble)Loading required package: ggplot2
Loading required package: patchwork
Attaching SeuratObject
Warning message:
“package ‘stringr’ was built under R version 4.3.3”
Warning message:
“package ‘tibble’ was built under R version 4.3.3”
SpaGene 参数说明
- rds_path:rds 的路径
- meta_path:meta 的路径
- col_SAM:meta 中对应的样本列名,多个样本以","相隔,例如"A,B,C"
- SAMple_name:样本名称,对应 col_SAM 列名下
- species:物种选择,可选"human"或者"mouse"
rds_path="../../data/AY1748480899609//input.rds"
meta_path="../../data/AY1748480899609//meta.tsv"
col_sam="Sample"
sample_name="N1_expression"
species="human"data = readRDS(rds_path)
meta <- read.table(meta_path,header=T,sep='\t',check.names=F)
if(colnames(meta)[1]=="barcode"){
rownames(meta) <- meta$barcode
} else if(colnames(meta)[1]=="barcodes"){
rownames(meta) <- meta$barcodes
}
data@meta.data <- meta
sample_name = str_split(sample_name,",")[[1]]
ll=list()
ll_heatmap = list()
for(i in 1:length(sample_name)){
data_subset = subset(data,cells = rownames(data@meta.data[data@meta.data[[col_sam]] %in% sample_name[i],]))
position = data_subset@reductions$spatial@cell.embeddings
data_subset_count = GetAssayData(data_subset,assay = "RNA",slot = "count")
spagene = SpaGene(data_subset_count,position)
pattern=FindPattern(spagene)
ll[[sample_name[i]]]$pattern = pattern
ll[[sample_name[i]]]$position = position
top5<-apply(pattern$genepattern,2,function(x){names(x)[order(x,decreasing=T)][1:5]})
ll_heatmap[[sample_name[i]]] = pheatmap(pattern$genepattern[rownames(pattern$genepattern)%in%top5,])
a = pattern$pattern
colnames(a) = rownames(position)
write.table(a,paste0(sample_name[i],"_pattern_expression.txt"),sep = "\t",col.names = T,row.names = T,quote = F)
}
空间表达模式
options(repr.plot.height=8, repr.plot.width=16)
for(i in 1:length(sample_name)){
print(sample_name[i])
plot = PlotPattern(ll[[sample_name[i]]]$pattern,ll[[i]]$position,pt.size = 0.3)
print(plot)
}
图中展示基因 pattern 在空间的表达情况,红色越深,表达越高;蓝色越深,表达越低。基因表达热图
每一个 pattern 中 Top5 基因的表达热图
for(i in 1:length(sample_name)){
print(sample_name[i])
print(ll_heatmap[[sample_name[i]]])
}
热图展示了每个 pattern 中 Top5 基因的表达情况,横走代表基因;纵轴代表 pattern。受配体基因空间表达
加载受配体库,可选方法:
- 下载常见细胞通讯工具提供的受配体库
- SpaGene 工具的 GitHub 里提供的受配体库
- 自己感兴趣的库
输入的受配体库文件,需要两列,列名为(ligand_gene_symbol 和 receptor_gene_symbol),行名为配体基因_受体基因
if(species == "human"){
LRpair = read.delim("human_LR.txt",sep = "\t",row.names = 1)
} else if(species == "mouse"){
LRpair = read.delim("mouse_LR.txt",sep = "\t",row.names = 1)
}ll_plotLR = list()
for(i in 1:length(sample_name)){
data_subset = subset(data,cells = rownames(data@meta.data[data@meta.data[[col_sam]] %in% sample_name[i],]))
position = data_subset@reductions$spatial@cell.embeddings
data_subset_count = GetAssayData(data_subset,assay = "RNA",slot = "count")
data_lr = SpaGene_LR(data_subset_count,position,LRpair=LRpair)
data_lr = data_lr[order(data_lr$adj),]
#可以根据LRpair参数挑选想要展示的受配体对共表达情况
ll_plotLR[[sample_name[i]]] = plotLR(data_subset_count,position,LRpair=c(gsub(rownames(data_lr)[1],pattern = ".*[_]",replacement = ""),gsub(rownames(data_lr)[1],pattern = "[_].*",replacement = "")),alpha.min=0.2,pt.size = 0.3)
}“sparse->dense coercion: allocating vector of size 5.4 GiB”
计算显著的受配体共定位和共表达对,可视化受配体对在空间上的分布
options(repr.plot.height=4, repr.plot.width=16)
for(i in 1:length(sample_name)){
print(sample_name[i])
print(ll_plotLR[[sample_name[i]]])
}
- 左图:灰色代表受体和配体表达都低的细胞;红色代表配体表达高的细胞;绿色代表受体表达高的细胞;蓝色代表配受体表达都高的细胞。
- 右图:受配体对的表达分数,颜色越深,受配体对越有可能存在互作情况。文献案例解析
文献一: 文献《Single-cell and spatial transcriptome analyses reveal tertiary lymphoid structures linked to tumour progression and immunotherapy response in nasopharyngeal carcinoma》前文通过细胞通讯发现 CXCL13+ CAFs 与 B 细胞通过 CXCL13-CXCR5, VCAM1-ITGAM2 等受配体对相互作用,进一步使用 SpaGene 发现这些受配体对在空间分布上接近并且共表达,验证了 CXCL13+ CAFs 与 B 细胞存在相互作用。
文献二: 文献《A Specialized Epithelial Cell Type Regulating Mucosal Immunity and Driving Human Crohn’s Disease》为了探究上皮细胞与免疫细胞之间的相互作用,使用 SpaGene 发现 LND 高表达的 marker 基因与高表达免疫细胞信号基因显著相关,并且在空间分布上临近。
参考资料
[1] Pang Z, Chong J, Zhou G, de Lima Morais DA, Chang L, Barrette M, et al. MetaboAnalyst 5.0: narrowing the gap between raw spectra and functional insights. Nucleic Acids Res. 2021;49:W388–96.
[2] Liu, Y., Ye, SY., He, S. et al. Single-cell and spatial transcriptome analyses reveal tertiary lymphoid structures linked to tumour progression and immunotherapy response in nasopharyngeal carcinoma. Nat Commun 15, 7713 (2024).
[3] Li J, Simmons AJ, Chiron S, Ramirez-Solano MA, Tasneem N, Kaur H, Xu Y, Revetta F, Vega PN, Bao S, Cui C, Tyree RN, Raber LW, Conner AN, Beaulieu DB, Dalal RL, Horst SN, Pabla BS, Huo Y, Landman BA, Roland JT, Scoville EA, Schwartz DA, Washington MK, Shyr Y, Wilson KT, Coburn LA, Lau KS, Liu Q. A Specialized Epithelial Cell Type Regulating Mucosal Immunity and Driving Human Crohn's Disease. bioRxiv [Preprint]. 2023 Oct 2:2023.09.30.560293. doi: 10.1101/2023.09.30.560293. Update in: Nat Commun. 2024 Aug 22;15(1):7204.
