首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >内容分享--利用空间转录组学解码细胞间通讯(NiCo)

内容分享--利用空间转录组学解码细胞间通讯(NiCo)

原创
作者头像
追风少年i
发布2025-11-18 10:40:49
发布2025-11-18 10:40:49
1410
举报

作者,Evil Genius

今天给大家看个东西,希望大家以后都用不到这个东西。

厄运总是如影随形,多的自己快麻木了。

经常有人问培训应该挣了不少钱吧,说实话, 挣了一些,但是一分也没剩下, 23年出事的时候负债了40多万,父母急火攻心的住院,花了5万多,我也辞掉了上海的工作,回到了太原,当时仔细算了一下,饥荒都超过50万了。严格来讲培训也就做了2年,时至今日,才算是把债务都清了,能生活起来了。可是不等缓口气,又要面临劳动仲裁的命运。

当初相亲,觉得女的要房要车要彩礼,好物质,可是结了婚以后,没房没车,还遭受各种厄运,经常会问自己她跟着自己吃这个苦是不是把人家姑娘给害了,不免会落泪啊~~~,也渐渐明白,为什么找对象要找体制内的了。

大家勉励吧,珍惜自己的好生活,千万不要落得跟我一样的下场,焦虑的睡不着。以后怎么办,我也不知道。

还有买盗版内容的人,有问题辛苦别再问我了,我真的有点心力交瘁,你们一问我问题,我第一反应就是为什么要落井下石~~~。

落难的时候其实大多数人都是冷眼旁观,也有不少落井下石,我培训期间骂我的,还有很多跟风落井下石的,我都数不过来了,但是也有少数几个拉自己的,这都算人生的贵人,每个人的人生都会遇到几个贵人,大家一定要懂得感恩。

今天我们分享内容--NiCo

在昨天分享的文献中,多处使用到了Nico进行分析

等等。

而NiCo这个方法本身也发了一遍高分文章

而且得到了nature的重点关注

NiCo(Niche Covariation)计算框架通过三方面推进CCC分析:

细胞类型注释:通过scRNA-seq标签转移对空间细胞类型进行高精度注释,优于其他方法,并结合直观的可视化呈现组织切片中的细胞分布模式。

互作推断:构建邻近矩阵捕获细胞类型共定位实例,通过分类器预测细胞类型间的互作强度,经模拟数据验证后可评估空间互作的功能关系。

基因程序共变预测:整合scRNA-seq数据,通过潜在基因因子(默认3个)回归分析,推断共定位细胞间基因程序的统计学显著关联,揭示CCC的潜在调控网络,超越单基因表达层面。

细胞转录状态的外在决定因素(源于微环境)可通过邻近细胞的基因表达共变揭示。NiCo(Niche Covariation)通过整合基于成像的空间转录组与匹配的scRNA-seq参考数据,在细胞类型分辨率下推断基因程序的生态位共变。创新点在于整合全基因组scRNA-seq数据与单细胞分辨率空间转录组,避免计算且噪声高的单细胞空间映射,转而提取可解释的潜在因子(反映scRNA-seq和空间数据中的细胞状态变异),并利用这些因子推断邻近细胞类型的基因程序共变。

需要输入的数据

空间数据:经细胞分割的基因-细胞计数矩阵及二维细胞中心坐标;

scRNA-seq数据:基因-细胞计数矩阵及涵盖空间数据中所有预期细胞类型的标签。

NiCo的多步骤分析流程

细胞类型注释:通过scRNA-seq标签转移标注空间数据中的细胞类型;

生态位结构解析:识别每个“中心细胞类型”(CC)的邻近生态位细胞类型;

共变推断:分析共定位细胞类型间的潜在因子共变,并关联至功能通路与分子信号互作

关键技术步骤

注释优化:通过互最近邻(MNN)校正技术偏差,利用Leiden聚类修剪离散锚点,迭代标注非锚点细胞。

生态位互作预测:训练正则化逻辑回归模型,根据局部生态位中细胞类型的标准化频率预测中心细胞身份,回归系数优先化潜在互作伙伴(图1“Interactions”)。

潜在因子提取:

整合性非负矩阵分解(NMF):联合空间与scRNA-seq数据(共享基因集)推断细胞状态变异的潜在因子;

替代方案:若空间数据受技术噪声(如分割误差导致的“信号溢出”)主导,则仅对scRNA-seq数据执行常规NMF,再推断空间数据中这些因子的细胞载荷。

共变分析:通过岭回归检验中心细胞潜在因子与生态位细胞因子的共变性,显著系数指示正/负共变关系,并结合scRNA-seq数据通过通路富集分析解析功能模块。

简单看一下代码

代码语言:javascript
复制
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)
代码语言:javascript
复制
###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)

image

image

Infer significant niche cell type interactions

代码语言:javascript
复制
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. 
)
代码语言:javascript
复制
###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

代码语言:javascript
复制
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))
代码语言:javascript
复制
###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

代码语言:javascript
复制
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)
代码语言:javascript
复制
# 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)

还有很多的可视化的方法,大家多多学习。

生活很好,有你更好

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 作者,Evil Genius
  • 今天给大家看个东西,希望大家以后都用不到这个东西。
  • 厄运总是如影随形,多的自己快麻木了。
  • 经常有人问培训应该挣了不少钱吧,说实话, 挣了一些,但是一分也没剩下, 23年出事的时候负债了40多万,父母急火攻心的住院,花了5万多,我也辞掉了上海的工作,回到了太原,当时仔细算了一下,饥荒都超过50万了。严格来讲培训也就做了2年,时至今日,才算是把债务都清了,能生活起来了。可是不等缓口气,又要面临劳动仲裁的命运。
  • 当初相亲,觉得女的要房要车要彩礼,好物质,可是结了婚以后,没房没车,还遭受各种厄运,经常会问自己她跟着自己吃这个苦是不是把人家姑娘给害了,不免会落泪啊~~~,也渐渐明白,为什么找对象要找体制内的了。
  • 大家勉励吧,珍惜自己的好生活,千万不要落得跟我一样的下场,焦虑的睡不着。以后怎么办,我也不知道。
  • 还有买盗版内容的人,有问题辛苦别再问我了,我真的有点心力交瘁,你们一问我问题,我第一反应就是为什么要落井下石~~~。
  • 落难的时候其实大多数人都是冷眼旁观,也有不少落井下石,我培训期间骂我的,还有很多跟风落井下石的,我都数不过来了,但是也有少数几个拉自己的,这都算人生的贵人,每个人的人生都会遇到几个贵人,大家一定要懂得感恩。
  • 今天我们分享内容--NiCo
  • 在昨天分享的文献中,多处使用到了Nico进行分析
  • 等等。
  • 而NiCo这个方法本身也发了一遍高分文章
  • 而且得到了nature的重点关注
  • NiCo(Niche Covariation)计算框架通过三方面推进CCC分析:
  • 细胞类型注释:通过scRNA-seq标签转移对空间细胞类型进行高精度注释,优于其他方法,并结合直观的可视化呈现组织切片中的细胞分布模式。
  • 互作推断:构建邻近矩阵捕获细胞类型共定位实例,通过分类器预测细胞类型间的互作强度,经模拟数据验证后可评估空间互作的功能关系。
  • 基因程序共变预测:整合scRNA-seq数据,通过潜在基因因子(默认3个)回归分析,推断共定位细胞间基因程序的统计学显著关联,揭示CCC的潜在调控网络,超越单基因表达层面。
  • 细胞转录状态的外在决定因素(源于微环境)可通过邻近细胞的基因表达共变揭示。NiCo(Niche Covariation)通过整合基于成像的空间转录组与匹配的scRNA-seq参考数据,在细胞类型分辨率下推断基因程序的生态位共变。创新点在于整合全基因组scRNA-seq数据与单细胞分辨率空间转录组,避免计算且噪声高的单细胞空间映射,转而提取可解释的潜在因子(反映scRNA-seq和空间数据中的细胞状态变异),并利用这些因子推断邻近细胞类型的基因程序共变。
  • 需要输入的数据
  • 空间数据:经细胞分割的基因-细胞计数矩阵及二维细胞中心坐标;
  • scRNA-seq数据:基因-细胞计数矩阵及涵盖空间数据中所有预期细胞类型的标签。
  • NiCo的多步骤分析流程
  • 细胞类型注释:通过scRNA-seq标签转移标注空间数据中的细胞类型;
  • 生态位结构解析:识别每个“中心细胞类型”(CC)的邻近生态位细胞类型;
  • 共变推断:分析共定位细胞类型间的潜在因子共变,并关联至功能通路与分子信号互作
  • 关键技术步骤
  • 注释优化:通过互最近邻(MNN)校正技术偏差,利用Leiden聚类修剪离散锚点,迭代标注非锚点细胞。
  • 生态位互作预测:训练正则化逻辑回归模型,根据局部生态位中细胞类型的标准化频率预测中心细胞身份,回归系数优先化潜在互作伙伴(图1“Interactions”)。
  • 潜在因子提取:
  • 整合性非负矩阵分解(NMF):联合空间与scRNA-seq数据(共享基因集)推断细胞状态变异的潜在因子;
  • 替代方案:若空间数据受技术噪声(如分割误差导致的“信号溢出”)主导,则仅对scRNA-seq数据执行常规NMF,再推断空间数据中这些因子的细胞载荷。
  • 共变分析:通过岭回归检验中心细胞潜在因子与生态位细胞因子的共变性,显著系数指示正/负共变关系,并结合scRNA-seq数据通过通路富集分析解析功能模块。
  • 简单看一下代码
  • Infer significant niche cell type interactions
  • Individual cell type niche plot
  • Perform niche cell state covariation analysis using latent factors
  • 还有很多的可视化的方法,大家多多学习。
  • 生活很好,有你更好
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档