流程升級---解剖細(xì)胞鄰域(CN)組織的iTME(高精度空間平臺、Stereo-seq、HD)

作者,Evil Genius

最近有一位學(xué)員問,為什么公司更新升級流程需要這么多的內(nèi)容?

原因很簡單,所謂流程升級,需要調(diào)研,把所有的分析方法、算法、使用場景、優(yōu)劣勢全部總結(jié)出來,比如現(xiàn)在的空間平臺,有Visium、Xenium、HD、Stereo-seq,再比如單細(xì)胞空間聯(lián)合分析的方法,幾十種,針對不同的平臺就需要不同的分析策略。

一言以蔽之,需要資源整合。

當(dāng)然了,大家自己的課題只需要多研究自己的方向即可,有時(shí)間就提升自己,我讀研沒有這種意識,水著就畢業(yè)了,現(xiàn)在后悔死了,和那些有高分文章發(fā)表的同學(xué),差距越來越大了,失之毫厘謬以千里絕對不是危言聳聽。希望大家引以為戒,讀研讀博不要浪費(fèi)時(shí)間,這是發(fā)文章最黃金的時(shí)間。

現(xiàn)在大家做HD、Stereo-seq,盡量不要再用bin分割模式,采用圖像識別的圖像分割模式,獲取單細(xì)胞級別的空間矩陣。

今天我們繼續(xù)升級分析流程,華大(Stereo-seq)為主。

以細(xì)胞組成為基礎(chǔ)解剖細(xì)胞鄰域(CN)組織的iTME
大多數(shù)用于細(xì)胞-細(xì)胞通訊分析的開源軟件都是基于基因表達(dá)或細(xì)胞距離設(shè)計(jì)的,而沒有考慮細(xì)胞-細(xì)胞之間的相互作用距離。
揭示異質(zhì)性空間TME引起的細(xì)胞間通信的深度空間共變。

分析框架

1、首先進(jìn)行細(xì)胞鄰域分析
2、分析細(xì)胞與細(xì)胞之間的空間相互作用,通過定量定義細(xì)胞與基因的空間接近程度和相互作用強(qiáng)度來檢測活性的L-R對。
3、構(gòu)建跨多個(gè)樣本的TME meta模塊,同時(shí),分析這些TME模塊和meta模塊相關(guān)聯(lián)的空間交互模塊。


將iTME解碼為細(xì)胞鄰域(CN)組織單元


空間細(xì)胞相互作用強(qiáng)度:推斷空間細(xì)胞間的通信


利用空間轉(zhuǎn)錄組學(xué)分析腫瘤微環(huán)境


組織TME相關(guān)的細(xì)胞鄰域


針對單個(gè)神經(jīng)網(wǎng)絡(luò)對iTME進(jìn)行反卷積

示例代碼

git clone https://github.com/STOmics/SCIITensor.git

cd SCIITensor

python setup.py install
Single sample analysis
import SCIITensor as sct
import scanpy as sc
import pandas as pd
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
import pickle

adata = sc.read("/data/work/LR_TME/Liver/LC5M/sp.h5ad")
lc5m = sct.core.scii_tensor.InteractionTensor(adata, interactionDB="/data/work/database/LR/cellphoneDB_interactions_add_SAA1.csv")
sct.core.scii_tensor.build_SCII(lc5m)
sct.core.scii_tensor.process_SCII(lc5m, bin_zero_remove=True, log_data=True)
sct.core.scii_tensor.eval_SCII_rank(lc5m)
sct.core.scii_tensor.SCII_Tensor(lc5m)
with open("LC5M_res.pkl", "wb") as f:
    pickle.dump(lc5m, f)


# Visualization
## heatmap
sct.core.scii_tensor.plot_tme_mean_intensity(lc5m, tme_module = 0, cellpair_module = 2, lrpair_module = 4,
    n_lr = 15, n_cc = 5,
    figsize = (10, 2), save = False, size = 2, vmax=1)
factor_cc = lc5m.cc_factor.copy()
factor_cc.columns = factor_cc.columns.map(lambda x: f"CC_Module {x}")

factor_lr = lc5m.lr_factor.copy()
factor_lr.columns = factor_lr.columns.map(lambda x: f"LR_Module {x}")

factor_tme = pd.DataFrame(lc5m.factors[2])
factor_tme.columns = factor_tme.columns.map(lambda x: f"TME {x}")

#draw the heatmap based on the cell-cell factor matrix
fig = sns.clustermap(factor_cc.T, cmap="Purples", standard_scale=0, metric='euclidean', method='ward', 
                     row_cluster=False, dendrogram_ratio=0.05, cbar_pos=(1.02, 0.6, 0.01, 0.3),
                     figsize=(24, 10),
                     )
fig.savefig("./factor_cc_heatmap.pdf")

#select the top ligand-receptor pairs, then draw the heatmap based on ligan-receptor factor matrix
lr_number = 120 #number of ligand-receptor pairs on the top that will remain
factor_lr_top = factor_lr.loc[factor_lr.sum(axis=1).sort_values(ascending=False).index[0:lr_number]]
fig = sns.clustermap(factor_lr_top.T, cmap="Purples", standard_scale=0, metric='euclidean', method='ward', 
                     row_cluster=False, dendrogram_ratio=0.05, cbar_pos=(1.02, 0.6, 0.01, 0.3),
                     figsize=(28, 10),
                     )
fig.savefig("./factor_lr_heatmap.pdf")

## sankey
core_df = sct.plot.sankey.core_process(lc5m.core)
sct.plot.sankey.sankey_3d(core_df, link_alpha=0.5, interval=0.001, save="sankey_3d.pdf")

## circles
interaction_matrix = sct.plot.scii_circos.interaction_select(lc5m.lr_mt_list, factor_cc, factor_lr, factor_tme, 
                               interest_TME='TME 0',
                               interest_cc_module='CC_Module 3',
                               interest_LR_module='LR_Module 4',
                               lr_number=20,
                               cc_number=10)

plt.figure(figsize=(8, 3))
sns.heatmap(interaction_matrix, vmax=1)

#Draw the circos diagram, which includes cell types, ligand-receptor genes, and the links between ligands and receptors.
cells = ['Hepatocyte', 'Fibroblast', 'Cholangiocyte', 'Endothelial', 'Macrophage', 'Malignant', 'B_cell', 'T_cell', 'DC', 'NK'] #list contains names of all cell types
sct.plot.scii_circos.cells_lr_circos(interaction_matrix, cells, save="cells_lr_circos.pdf")

#Draw the circos which only contains cell types and the links between them.
sct.plot.scii_circos.cells_circos(interaction_matrix, cells, save="cells_circos.pdf")

#Draw circos which only contains ligand-receptor genes
sct.plot.scii_circos.lr_circos(interaction_matrix, cells)

## igraph
sct.plot.scii_net.grap_plot(interaction_matrix, cells,
                   save="igrap_network.pdf")

cc_df = sankey.factor_process(lc5m.factors[0], lc5m.cellpair)
sct.plot.sankey.sankey_2d(cc_df)

Multiple sample analysis

adata_LC5P = sc.read("/data/work/LR_TME/Liver/LC5P/FE1/cell2location_map/sp.h5ad")
lc5p = sct.core.scii_tensor.InteractionTensor(adata_LC5P, interactionDB="/data/work/database/LR/cellphoneDB_interactions_add_SAA1.csv")
sct.core.scii_tensor.build_SCII(lc5p)
sct.core.scii_tensor.process_SCII(lc5p)
sct.core.scii_tensor.eval_SCII_rank(lc5p)
sct.core.scii_tensor.SCII_Tensor(lc5p)
with open('LC5P_res.pkl', "wb") as f:
    pickle.dump(lc5p, f)


adata_LC5T = sc.read("/data/work/LR_TME/Liver/LC5T/FD3/cell2location_map/sp.h5ad")
lc5t = sct.core.scii_tensor.InteractionTensor(adata_LC5T, interactionDB="/data/work/database/LR/cellphoneDB_interactions_add_SAA1.csv")
sct.core.scii_tensor.build_SCII(lc5t)
sct.core.scii_tensor.process_SCII(lc5t)
sct.core.scii_tensor.eval_SCII_rank(lc5t)
sct.core.scii_tensor.SCII_Tensor(lc5t)
with open('LC5T_res.pkl', "wb") as f:
    pickle.dump(lc5t, f)

## merge data
all_data = sct.core.scii_tensor.merge_data([lc5t, lc5m, lc5p], patient_id = ['LC5T', 'LC5M', 'LC5P'])
sct.core.scii_tensor.SCII_Tensor_multiple(all_data)

## heatmap
mpl.rcParams.update(mpl.rcParamsDefault)
sct.core.scii_tensor.plot_tme_mean_intensity_multiple(all_data, sample='LC5T',
                                                     tme_module=0, cellpair_module=0, lrpair_module=0, vmax=1)
示例代碼在GitHub - STOmics/SCIITensor

生活很好,有你更好

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
禁止轉(zhuǎn)載,如需轉(zhuǎn)載請通過簡信或評論聯(lián)系作者。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容