Research highlights---利用空间转录组学解码细胞间通讯

作者,Evil Genius
从自然属性的角度看,女性是需要保护的一方。
Xenium、MERSCOPE、CosMx、seqFISH和Slide-seqV2等最新技术使CCC空间预测成为必须分析的内容。
计算框架NiCo(Niche Covariation)为CCC分析提供了一种三管齐下的方法。首先,NiCo使用scRNA-seq数据的标记转移来注释空间细胞类型,这实现了比其他方法更精确的注释。空间注释辅以直观的视觉表示,将细胞类型位置映射到组织载玻片上,便于探索组织组织和细胞分布模式。

其次,NiCo通过构建一个邻域矩阵来推断空间共定位区域中细胞类型之间的相互作用,该邻域矩阵捕获了组织中细胞类型共定位的所有实例;NiCo使用该矩阵作为分类器的输入,该分类器预测每对细胞类型的相互作用强度。正相互作用强度表明细胞类型之间可能存在相互作用,这些预测已经使用模拟数据集进行了严格验证。这种能力使研究人员能够推断细胞类型之间的功能关系,并评估细胞相互作用的空间组织。
第三,NiCo最具创新性的方面在于它能够预测空间共定位细胞之间基因程序的细胞状态协变。这项独特的任务假设一种细胞类型中的一组基因可以影响其共定位伴侣细胞类型的另一组基因。由于空间转录组学数据集通常具有有限的基因覆盖率,NiCo整合了scRNA-seq数据以提高其预测能力。通过在相邻细胞类型中回归这些因素,NiCo推断出统计上显著的相互作用系数,表明潜在因素空间内的CCC,揭示了相互作用细胞类型之间的潜在串扰。这种方法能够探索CCC背后的潜在基因程序活动,超越单个基因表达,揭示更高层次的生物学见解。
示例代码在nico-sc-sp · PyPI
我们来简单看一下

import nico 
from nico import Annotations as sann
from nico import Interactions as sint
from nico import Covariations as scov

import numpy as np
import os
import matplotlib.pyplot as plt 
from matplotlib.collections import PatchCollection

# if you did not install the nico package and downloaded the nico related scripts into the current directory

#import Annotations as sann
#import Interactions as sint
#import Covariations as scov

#import scanpy as sc
#import gseapy
#import xlsxwriter
plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42
plt.rcParams['axes.linewidth'] = 0.1 #set the value globally

# please use Helvetica font according to your OS to ensure compatibility with Adobe Illustrator. 
plt.rcParams['font.family'] = 'Helvetica'
plt.rcParams['font.sans-serif'] = ['Helvetica']

# Use the default font for all the figures 
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Tahoma', 'DejaVu Sans','Lucida Grande', 'Verdana']

import warnings
warnings.filterwarnings("ignore")

#parameters for saving plots
saveas='png'
transparent_mode=False
dpi=300
showit=True
ref_datapath='./inputRef/'
query_datapath='./inputQuery/'

output_nico_dir='./nico_out/'
output_annotation_dir=None #uses default location
#output_annotation_dir=output_nico_dir+'annotations/'
annotation_save_fname= 'nico_celltype_annotation.h5ad'
inputRadius=0

ref_cluster_tag='cluster' #scRNAseq cell type slot 
annotation_slot='nico_ct' #spatial cell type slot 

####Perform cell type annotation of spatial data
anchors_and_neighbors_info=sann.find_anchor_cells_between_ref_and_query(
refpath=ref_datapath,
quepath=query_datapath,
output_nico_dir=output_nico_dir,
output_annotation_dir=output_annotation_dir)

output_info=sann.nico_based_annotation(anchors_and_neighbors_info,
guiding_spatial_cluster_resolution_tag='leiden0.4',
across_spatial_clusters_dispersion_cutoff=0.15,
ref_cluster_tag=ref_cluster_tag,
resolved_tie_issue_with_weighted_nearest_neighbor='No')

sann.delete_files(output_info)

sann.save_annotations_in_spatial_object(output_info,
anndata_object_name=annotation_save_fname)

####Annotations from different computational methods such cell2location or TACCO
####Visualize the spatial annotations of all cell types
sann.visualize_umap_and_cell_coordinates_with_all_celltypes( 
output_nico_dir=output_nico_dir,
output_annotation_dir=output_annotation_dir,
anndata_object_name=annotation_save_fname,
#spatial_cluster_tag='nico_ct',
spatial_cluster_tag=annotation_slot,    
spatial_coordinate_tag='spatial',
umap_tag='X_umap',
showit=showit,
saveas=saveas,transparent_mode=transparent_mode)

###Visualize spatial annotations of selected pairs (or larger sets) of cell types
choose_celltypes=[['Stem/TA','Paneth'],['Paneth','Goblet']]

sann.visualize_umap_and_cell_coordinates_with_selected_celltypes(
choose_celltypes=choose_celltypes,    
output_nico_dir=output_nico_dir,
output_annotation_dir=output_annotation_dir,
anndata_object_name=annotation_save_fname,
spatial_cluster_tag=annotation_slot,spatial_coordinate_tag='spatial',
umap_tag='X_umap',
showit=showit,    
saveas=saveas,transparent_mode=transparent_mode)

Infer significant niche cell type interactions
do_not_use_following_CT_in_niche=['Basophils','Cycling/GC B cell','pDC']

niche_pred_output=sint.spatial_neighborhood_analysis(
Radius=inputRadius,
output_nico_dir=output_nico_dir,
anndata_object_name=annotation_save_fname,
spatial_cluster_tag='nico_ct',
removed_CTs_before_finding_CT_CT_interactions=do_not_use_following_CT_in_niche)

# this cutoff is use for the visualization of cell type interactions network 
celltype_niche_interaction_cutoff=0.1
###Plot the niche interaction network without any edge weight details for cutoff 0.1
sint.plot_niche_interactions_without_edge_weight(niche_pred_output,
niche_cutoff=celltype_niche_interaction_cutoff,
saveas=saveas,
transparent_mode=transparent_mode,
showit=showit,
figsize=(10,7),
dpi=dpi,                #Resolution in dots per inch for saving the figure.
input_colormap='jet',   #Colormap for node colors, from matplotlib colormaps.
with_labels=True,       #Display cell type labels on the nodes, if True.
node_size=500,          #Size of the nodes. 
linewidths=0.5,         #Width of the node border lines. 
node_font_size=6,       #Font size for node labels.
alpha=0.5,              #Opacity level for nodes and edges. 1 is fully opaque, and 0 is fully transparent. 
font_weight='bold'      #Font weight for node labels; 'bold' for emphasis, 'normal' otherwise. 
)

###Using edge weights included in the niche interaction plot can be done as shown below
sint.plot_niche_interactions_with_edge_weight(niche_pred_output,
niche_cutoff=celltype_niche_interaction_cutoff,
saveas=saveas,
transparent_mode=transparent_mode,
showit=showit,
figsize=(10,7),
dpi=dpi,
input_colormap='jet',
with_labels=True,
node_size=500,
linewidths=1,
node_font_size=8,
alpha=0.5,
font_weight='normal',
edge_label_pos=0.35,   #Relative position of the weight label along the edge. 
edge_font_size=3       #Font size for edge labels.  
)

Individual cell type niche plot
sint.find_interacting_cell_types(niche_pred_output,
choose_celltypes=['Stem/TA','Paneth'],
celltype_niche_interaction_cutoff=celltype_niche_interaction_cutoff,
saveas=saveas,transparent_mode=transparent_mode,dpi=dpi,showit=showit,figsize=(4.0,2.0))

###Plot the average confusion matrix of the classifier from cross-folds

sint.plot_confusion_matrix(niche_pred_output,
saveas=saveas,transparent_mode=transparent_mode,showit=showit,dpi=dpi)

Perform niche cell state covariation analysis using latent factors
cov_out=scov.gene_covariation_analysis(iNMFmode=True,
        Radius=inputRadius,
        no_of_factors=3,
        refpath=ref_datapath,
        quepath=query_datapath,
        spatial_integration_modality='double',
        output_niche_prediction_dir=output_nico_dir,
        ref_cluster_tag=ref_cluster_tag,LRdbFilename='NiCoLRdb.txt')
scov.plot_cosine_and_spearman_correlation_to_factors(cov_out,
choose_celltypes=['Paneth'],
NOG_Fa=30,saveas=saveas,transparent_mode=transparent_mode,showit=showit,
figsize=(15,10),dpi=dpi)

# Cosine and spearman correlation: visualize the correlation of genes from NMF
scov.plot_cosine_and_spearman_correlation_to_factors(cov_out,
choose_celltypes=['Stem/TA'],
NOG_Fa=30,saveas=saveas,transparent_mode=transparent_mode,showit=showit,
figsize=(15,10),dpi=dpi)

还有很多的可视化的方法,大家多多学习。
生活很好,有你更好
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值