SpaGRA:通过图增强算法提高空间域识别准确性

导读:本文是由山东大学控制科学与工程学院高瑞教授团队和复旦大学类脑智能科学与技术研究院原致远青年副研究员合作,于2024年10月2日在JGG在线发表的方法学论文。该研究开发了一个新的空间域识别方法SpaGRA,通过图增强算法实现多重关系的自动构建,挖掘SRT数据中细胞间潜在的多层次关系,从而改进空间域的识别效果。

在这里插入图片描述

  • 原文 开放获取 ,阅读原文请参考 这儿.

研究背景


近年来,空间转录组学(spatially resolved transcriptomics, SRT)技术迅速发展,可以同时获取组织样本的基因表达和空间位置信息,弥补了传统单细胞RNA测序在空间上的局限性,为研究复杂的组织结构提供了全新视角。其中,精准识别空间域(即具有相似基因表达模式的区域)至关重要。然而现有大多数方法在识别空间域时,往往只依赖细胞间空间距离来构建邻接关系,忽视了诸如基因表达相似性、细胞间相互作用等关键生物学因素,可能会导致结果不够准确。

主要结论


SpaGRA的核心模块包括图增强和几何对比学习。SpaGRA将细胞间的欧式距离作为先验知识,通过多头图注意力网络(GATs)动态调整图中边的权重,挖掘基因表达、形态学相似性以及细胞间相互作用等多层次关系。此外,几何对比学习的引入增强了潜在嵌入的可区分性,进一步提升了SpaGRA在空间域识别中的表现。SpaGRA支持不同分辨率的空间转录组技术,且适用于最新的Visium HD数据。在多种数据集上的测试结果显示,SpaGRA能够有效区分癌组织中的癌变区域和健康区域,识别不同脑区域中的关键空间域,在不同组织类型和多种病理条件下具有广泛的应用潜力。

  • SpaGRA的工作流程:
    SpaGRA的工作流程

软件使用和代码


此部分内容转载自该项目GitHub文档(https://github.com/sunxue-yy/SpaGRA)

安装

SpaGRA可通过Python 3.7.12和Pytorch 1.11.0实现,通过 PyPI 安装:

pip install SpaGRA
### Requirements
numpy==1.21.5
torch==1.11.0
pandas==1.3.5
numba==0.55.1
scanpy==1.9.1
scikit-learn==1.0.2
scipy==1.7.3
anndata==0.8.0
matplotlib==3.5.2

应用实例

作者通过两个数据集作为示例,即人类乳腺癌数据集(Human breast cancer)和Visium HD数据集(Visium HD dataset),验证SpaGRA在空间域识别中的应用。

人类乳腺癌数据集(Human breast cancer)
  1. 首先加载安装包和数据集:
# Importing necessary libraries
import os,csv,re
import pandas as pd
import numpy as np
import scanpy as sc
import matplotlib.pyplot as plt
from sklearn.metrics.cluster import adjusted_rand_score
import warnings
warnings.filterwarnings('ignore')
from SpaGRA.utils import *
from SpaGRA.process import *
from SpaGRA import train_model
from sklearn.metrics import normalized_mutual_info_score

# Loading spatial transcriptomics data using Scanpy
adata = sc.read_visium("Data/V1_Breast_Cancer_Block_A_Section_1",
                count_file="V1_Breast_Cancer_Block_A_Section_1_filtered_feature_bc_matrix.h5")
  1. 对数据进行预处理:
# Ensuring that gene names are unique
adata.var_names_make_unique()  

# Filtering out genes that are minimally expressed in different cells
prefilter_genes(adata, min_cells=3)  

# Identifying and retaining genes that are highly variable
sc.pp.highly_variable_genes(adata, flavor="seurat_v3", n_top_genes=1000) 

# Data normalization and log transformation
sc.pp.normalize_per_cell(adata) 
sc.pp.log1p(adata)

# Loading a metadata file (containing ground truth annotations)
Ann_df = pd.read_csv("Data/V1_Breast_Cancer_Block_A_Section_1/metadata.tsv", sep="	", header=0, na_filter=False, index_col=0)

# Adding the ground truth labels
adata.obs['Ground Truth'] = Ann_df.loc[adata.obs_names, 'fine_annot_type']

# Adjacency matrix calculation
Cal_Spatial_Net(adata, rad_cutoff=400)  
  1. 对模型进行训练并保存聚类结果:
adata = train_model.train(adata,k=20,n_epochs=200)
obs_df = adata.obs.dropna()

# Calculating Adjusted Rand Index (ARI)
ARI = adjusted_rand_score(obs_df['SpaNCL'], obs_df['Ground Truth'])
print('Adjusted rand index = %.2f' % ARI)

# Plotting UMAP visualization
sc.pp.neighbors(adata, use_rep='SpaGRA')
sc.tl.umap(adata)
plt.rcParams["figure.figsize"] = (3, 3)
sc.pl.umap(adata, color=["SpaGRA", 'Ground Truth'], title=['SpaGRA (ARI=%.2f)' % ARI, 'Ground Truth'],save="SpaGRA_umap")

# Display and save clustering results
plt.rcParams["figure.figsize"] = (3, 3)
sc.pl.spatial(adata, color=["SpaGRA", 'Ground Truth'], title=['SpaGRA (ARI=%.2f)' % ARI, 'Ground Truth'],save="SpaGRA")
Visium HD数据集(Visium HD dataset)
  1. 首先加载安装包和数据集:
# Importing necessary libraries
import os,csv,re
import pandas as pd
import numpy as np
import scanpy as sc
import matplotlib.pyplot as plt
from sklearn.metrics.cluster import adjusted_rand_score
import warnings
warnings.filterwarnings('ignore')
from SpaGRA.utils import *
from SpaGRA.process import *
from SpaGRA import train_model

# Loading spatial transcriptomics data using Scanpy
adata = sc.read("Data/HD/HD2.h5ad")
  1. 数据预处理:
adata.var_names_make_unique()
prefilter_genes(adata, min_cells=3) 
sc.pp.highly_variable_genes(adata, flavor="seurat_v3", n_top_genes=1000)
sc.pp.normalize_per_cell(adata)
sc.pp.log1p(adata)
Cal_Spatial_Net(adata, rad_cutoff=150)
  1. 对模型进行训练并保存聚类结果:
adata = train_model.train(adata,hidden_dims=1000, n_epochs=200,num_hidden=600,lr=0.00008, key_added='SpaNCL',a=2,b=1,c=1,
                radius=0,  weight_decay=0.00001,  random_seed=0,feat_drop=0.02,attn_drop=0.01,
                negative_slope=0.02,heads=4,method = "louvain",reso=0.8)


# Display and save clustering results
coor = pd.DataFrame(adata.obsm['spatial'])
coor.index = adata.obs.index
coor.columns = ['imagerow', 'imagecol']
adata.obs["x_pixel"]=coor['imagerow']
adata.obs["y_pixel"]=coor['imagecol']

domains='SpaGRA'
title = 'SpaGRA'
ax = sc.pl.scatter(adata, alpha=1, x="x_pixel", y="y_pixel", color=domains, legend_fontsize=18, show=False,
                   size=100000 / adata.shape[0])
ax.set_title(title, fontsize=23)
ax.set_aspect('equal', 'box')
ax.set_xticks([])
ax.set_yticks([])
ax.axes.invert_yaxis()
plt.savefig("HD2.pdf")
plt.close()

代码获取

SpaGRA详细代码请参见GitHub

引用本文

Xue Sun, Wei Zhang, Wenrui Li, Na Yu, Daoliang Zhang, Qi Zou, Qiongye Dong, Xianglin Zhang, Zhiping Liu, Zhiyuan Yuan, Rui Gao. (2024). SpaGRA: graph augmentation facilitates domain identification for spatially resolved transcriptomics. Journal of Genetics and Genomics.
DOI:10.1016/j.jgg.2024.09.015


Journal of Genetics and Genomics 期刊简介

Journal of Genetics and Genomics (JGG) 是由中国科学院遗传与发育生物学研究所和中国遗传学会主办的国际学术期刊,致力于报道涵盖生命科学和医学遗传学领域的原创性研究成果。JGG 2023年度影响因子6.6 (5年影响因子5.8),Scopus学术期刊评价指标CiteScore 8.2,位列JCR 2023年度GENETICS & HEREDITY领域Q1区(Top 10%),BIOCHEMISTRY & MOLECULAR BIOLOGY领域Q1区,入选中国科技期刊卓越行动计划。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值