作者赢赊,Evil Genius
最近收到了很多粉絲的提問,其中對(duì)于空間通訊信號(hào)的用法需要在加強(qiáng)一點(diǎn)。
其實(shí)單獨(dú)運(yùn)用COMMOT做通訊信號(hào)流的做法并不完美嘶是,而實(shí)應(yīng)該和空間軌跡向量場(chǎng)結(jié)合起來(lái)才更具有意義。
所以這里我們需要做到的是蛛碌,
1聂喇、細(xì)胞的空間分布情況
2、細(xì)胞的空間分布趨勢(shì)
3蔚携、細(xì)胞之間的共定位情況
4希太、細(xì)胞的信號(hào)流向
前三點(diǎn)其實(shí)分享了很多了,關(guān)于空間軌跡向量場(chǎng)也都分享過酝蜒,這個(gè)地方我提醒大家一點(diǎn)誊辉,空間軌跡向量場(chǎng)表征的是細(xì)胞或者通路的聚集方向,信號(hào)流是通訊的方向亡脑,兩者之間的結(jié)合才更具有意義
COMMOT軟件特點(diǎn)
a package that infers CCC by simultaneously considering numerous ligand–receptor pairs for either spatial transcriptomics data or spatially annotated scRNA-seq data equipped with spatial distances between cells estimated from paired spatial imaging data; summarizes and compares directions of spatial signaling; identifies downstream effects of CCC on gene expressions using ensemble of trees models; and provides visualization utilities for the various analyses.
軟件總覽----COMMOT
配體和受體通常在有限的空間范圍內(nèi)與多種復(fù)合物相互作用堕澄⊙荆考慮到這一點(diǎn),作者提出了具有三個(gè)重要特征的collective optimal transport:首先蛙紫,the use of non-probability mass distributions to control the marginals of the transport plan to maintain comparability between species(需要一點(diǎn)數(shù)學(xué)背景知識(shí));其次拍屑,對(duì)CCC實(shí)施空間距離約束,以避免連接空間上相距較遠(yuǎn)的細(xì)胞;最后坑傅,將多種配體分布結(jié)合到多中受體分布以解釋多種相互作用丽涩。
這里我以一個(gè)空間肝癌樣本為例,分享一下COMMOT的用法裁蚁。
第一步看形態(tài)學(xué)劃分矢渊,這個(gè)看HE圖片應(yīng)該都能看出來(lái)。
數(shù)據(jù)的簡(jiǎn)單處理
import os
import gc
import ot
import pickle
import anndata
import scanpy as sc
import pandas as pd
import numpy as np
from scipy import sparse
from scipy.stats import spearmanr, pearsonr
from scipy.spatial import distance_matrix
import matplotlib.pyplot as plt
import commot as ct
####讀取空間數(shù)據(jù)
adata = sc.read_visium(sp_input,library_id = 'liver1')
adata.var_names_make_unique()
sc.pp.normalize_total(adata, inplace=True)
sc.pp.log1p(adata)
adata_dis500 = adata.copy()
sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)
adata = adata[:, adata.var.highly_variable]
sc.tl.pca(adata, svd_solver='arpack')
sc.pp.neighbors(adata, n_neighbors=10, n_pcs=40)
sc.tl.umap(adata)
sc.tl.leiden(adata, resolution=0.4)
這個(gè)地方我們看一下聚類和形態(tài)學(xué)的匹配度,癌區(qū)和正常區(qū)域有明顯的劃分
sc.pl.spatial(adata, color='leiden')
構(gòu)建通訊網(wǎng)絡(luò)
species = 'human'
df_cellchat = ct.pp.ligand_receptor_database(species=species, signaling_type='Secreted Signaling', database='CellChat')
df_cellchat_filtered = ct.pp.filter_lr_database(df_cellchat, adata_dis500, min_cell_pct=0.05)
ct.pp.filter_lr_database這個(gè)地方有一個(gè)參數(shù)需要注意枉证,min_cell_pct矮男,空間的通訊信號(hào)方向性我們需要知道主導(dǎo)的信號(hào),這個(gè)值適當(dāng)大一點(diǎn)室谚。
看一下信息:
df_cellchat_filtered
每列依次為配體毡鉴、受體、信號(hào)通路秒赤,配受體類型猪瞬,我們?cè)谟?jì)算的時(shí)候要把所有的信號(hào)都進(jìn)行計(jì)算,但是時(shí)間比較長(zhǎng)入篮,以其中EGF通訊為例陈瘦。
df_cellchat_filtered = df_cellchat_filtered.iloc[2:4,:]
pathway = 'EGF'
ct.tl.spatial_communication(adata_dis500,
database_name='cellchat', df_ligrec=df_cellchat_filtered, dis_thr=500, heteromeric=True, pathway_sum=True)
ct.tl.communication_direction(adata_dis500, database_name='cellchat', pathway_name=pathway, k=5)
ct.pl.plot_cell_communication(adata_dis500, database_name='cellchat', pathway_name=pathway, plot_method='grid', background_legend=True,scale=0.00003, ndsize=8, grid_density=0.4, summary='sender', background='image', clustering='leiden', cmap='Alphabet',normalize_v = True, normalize_v_quantile=0.995)
ct.pl.plot_cell_communication(adata_dis500, database_name='cellchat', pathway_name=pathway, plot_method='grid', background_legend=True,scale=0.000005, ndsize=8, grid_density=0.4, summary='sender', background='image', clustering='leiden', cmap='Alphabet',normalize_v = True, normalize_v_quantile=0.995)
ct.pl.plot_cell_communication(adata_dis500, database_name='cellchat', pathway_name=pathway, plot_method='stream', background_legend=True,scale=0.00001, ndsize=8, grid_density=0.4, summary='sender', background='image', clustering='leiden', cmap='Alphabet',normalize_v = True, normalize_v_quantile=0.995)