10X空間轉(zhuǎn)錄組數(shù)據(jù)分析之功能信號(hào)網(wǎng)絡(luò)(Ligand---receptor----downstream genes network)

作者,追風(fēng)少年i

hello,大家好,周二了,幾天就要過(guò)完上半年了,不知道大家感覺(jué)如何了??人生總是有很多磨難,想要的東西總是讓我們得不到,所以我們會(huì)有時(shí)很羨慕別人,可能一輩子奮斗想要的東西,別人唾手可得~~~~??,可能越長(zhǎng)大,越要承認(rèn)自己的平凡,越是經(jīng)歷,越要珍惜所擁有的。

今天我們要繼續(xù)空間轉(zhuǎn)錄組的分析內(nèi)容,還是主要研究細(xì)胞在空間位置上的相互作用,參考文章在Decoding functional cell–cell communication events by multi-view graph learning on spatial transcriptomics,其實(shí)就是要利用空間轉(zhuǎn)錄組的信息推斷空間區(qū)域的配受體--靶基因網(wǎng)絡(luò),文章是清華大學(xué)的才子所發(fā),希望這位才子最后沒(méi)進(jìn)編制~~~??,繼續(xù)為科研而努力。

由多個(gè)配體-受體對(duì)介導(dǎo)的細(xì)胞間通訊事件(CEs)構(gòu)建了一個(gè)復(fù)雜的細(xì)胞間信號(hào)網(wǎng)絡(luò)。 通常只有一部分 CE 直接作用于特定微環(huán)境中的特定下游響應(yīng)。 將它們稱為功能通信事件 (FCE)。
圖片.png
空間轉(zhuǎn)錄組學(xué)方法可以描繪配體、受體及其下游基因的基因表達(dá)水平的空間分布。 這為揭示細(xì)胞間通信的全景提供了新的可能性。 這里開(kāi)發(fā)了一種計(jì)算方法 HoloNet,用于使用空間轉(zhuǎn)錄組數(shù)據(jù)解碼 FCE。 將 CE 建模為多視圖網(wǎng)絡(luò),在網(wǎng)絡(luò)上開(kāi)發(fā)了一個(gè)attention-based的圖學(xué)習(xí)模型來(lái)預(yù)測(cè)目標(biāo)基因的表達(dá),并通過(guò)解釋訓(xùn)練后的模型來(lái)解碼特定下游基因的 FCE。
圖片.png

先來(lái)看看技術(shù)背景

細(xì)胞間通訊對(duì)于多細(xì)胞生物的組織和維持以及疾病的發(fā)生至關(guān)重要。 當(dāng)Sender細(xì)胞向微環(huán)境釋放配體分子,而受體細(xì)胞通過(guò)受體感知配體時(shí),就會(huì)發(fā)生細(xì)胞間通訊事件 (CE)。 CEs 形成一個(gè)復(fù)雜的細(xì)胞間信號(hào)網(wǎng)絡(luò),參與各種基因的調(diào)控。 異常的CEs可以觸發(fā)異常的細(xì)胞表型,并可能導(dǎo)致許多疾病的發(fā)生。

CE 的全部應(yīng)包括Sender細(xì)胞、Receiver細(xì)胞、配體-受體對(duì)及其下游響應(yīng)。 值得注意的是,特定的下游響應(yīng)通常僅由部分推斷的 CE 引起。 將此類 CE 稱為其下游目標(biāo)的功能通信事件 (FCE)。 解碼 FCE 有助于了解特定微環(huán)境如何塑造細(xì)胞表型,因此有助于研究可能的疾病干預(yù)措施。

當(dāng)前的分子譜分析技術(shù)提供bulk或單細(xì)胞基因表達(dá)譜,包括主要配體和受體基因、細(xì)胞類型特異性標(biāo)記基因和可能的下游反應(yīng)基因。最近的空間分子分析技術(shù),如空間轉(zhuǎn)錄組測(cè)序和 SeqFISH,可以提供有關(guān)細(xì)胞位置的更多信息。已經(jīng)開(kāi)發(fā)了一些數(shù)據(jù)驅(qū)動(dòng)的方法來(lái)研究基于這些技術(shù)的 CE。例如,NicheNet 和 MESSI 旨在表征配體-受體對(duì)與下游反應(yīng)之間的關(guān)系,而 NCEM 則專注于Sender-Receiver細(xì)胞依賴性以及相關(guān)表型。對(duì) FCE 的全面了解應(yīng)該包含對(duì)以下問(wèn)題的答案:哪些細(xì)胞類型充當(dāng)發(fā)送者和接收者,它們?cè)谀睦?,以及它們采用哪些配體-受體對(duì)來(lái)誘導(dǎo)什么樣的下游反應(yīng)。然而,仍然缺乏構(gòu)建這種 FCE 全息網(wǎng)絡(luò)的方法。

看一看構(gòu)建方法

Overview of HoloNet

HoloNet 是一種使用空間轉(zhuǎn)錄組數(shù)據(jù)解碼 FCE 的計(jì)算方法。 它需要空間數(shù)據(jù)、細(xì)胞類型標(biāo)簽和配對(duì)的配體-受體基因列表作為輸入。 所需的空間數(shù)據(jù)應(yīng)包含細(xì)胞的高維基因表達(dá)譜和空間位置。 用戶可以為基于spot的數(shù)據(jù)集提供從反卷積方法(例如 Seurat)派生的連續(xù)細(xì)胞類型百分比,或?yàn)榫哂袉渭?xì)胞分辨率的數(shù)據(jù)集提供分類細(xì)胞類型標(biāo)簽。 使用來(lái)自 connectomeDB2020 的配對(duì)配體-受體基因列表作為默認(rèn)設(shè)置,但也可以提供來(lái)自其他數(shù)據(jù)庫(kù)的基因列表。

HoloNet 首先使用空間數(shù)據(jù)和配對(duì)的配體-受體基因列表構(gòu)建了一個(gè)多視圖 CE 網(wǎng)絡(luò)。在 CE 中,配體分子由Sender細(xì)胞釋放,在組織內(nèi)擴(kuò)散一段距離,然后與受體細(xì)胞表達(dá)的受體結(jié)合。當(dāng)細(xì)胞通過(guò)多個(gè)配體-受體對(duì)與其他細(xì)胞進(jìn)行交流時(shí),CE 可以自然地建模為多視圖網(wǎng)絡(luò)。該網(wǎng)絡(luò)中的每個(gè)視圖都是一個(gè)有向圖,表示由一個(gè)配體-受體對(duì)介導(dǎo)的 CE,具有自己的加權(quán)edge。每個(gè)節(jié)點(diǎn)代表被測(cè)組織中的一個(gè)細(xì)胞或一個(gè)點(diǎn),并且多個(gè)視圖中的節(jié)點(diǎn)是對(duì)齊的。任何視圖中的有向邊都將Sender Cell連接到其相應(yīng)的Receiver cell。邊緣權(quán)重表示由發(fā)送者和接收者細(xì)胞之間的配體-受體對(duì)介導(dǎo)的 CE 強(qiáng)度。對(duì)于每個(gè)視圖,HoloNet 通過(guò)三個(gè)因素的函數(shù)計(jì)算每個(gè)邊的權(quán)重:Sender 細(xì)胞中配體的表達(dá)、Receiver Cell中受體的表達(dá)以及Sender 細(xì)胞和Receiver Cell的物理距離。 HoloNet 僅保留通過(guò)置換測(cè)試評(píng)估的高置信度edge。

HoloNet 提供了多種方法來(lái)分析和可視化多視圖 CE 網(wǎng)絡(luò)。 對(duì)于任何配體-受體對(duì),HoloNet 在相應(yīng)的視圖中執(zhí)行網(wǎng)絡(luò)中心性分析,以將具有高通信激活的細(xì)胞(或spot)檢測(cè)為 CE 熱點(diǎn)。 HoloNet 還為每個(gè)視圖構(gòu)建了一個(gè)細(xì)胞類型級(jí)別的 CE 網(wǎng)絡(luò),它代表了從一種細(xì)胞類型到另一種細(xì)胞類型的一般 CE 強(qiáng)度。 為了探索不同配體-受體對(duì)之間的關(guān)系,HoloNet 根據(jù)其局部特征量化不同網(wǎng)絡(luò)視圖之間的相似性,并執(zhí)行層次聚類方法來(lái)聚類配體-受體對(duì)。

HoloNet 可以在構(gòu)建的多視圖 CE 網(wǎng)絡(luò)的基礎(chǔ)上揭示 FCE 的全息網(wǎng)絡(luò)。如果 CE 改變了接收細(xì)胞中感興趣基因的表達(dá),將 CE 視為 FCE。為了解碼 FCE,將所有單個(gè)細(xì)胞或spot中靶基因的表達(dá) E 分解為其基線表達(dá) E0,由其細(xì)胞類型和由多種細(xì)胞類型觸發(fā)并由多個(gè)配體-受體對(duì)介導(dǎo)的 CE 引起的表達(dá)變化 ΔE 決定. 采用多視圖圖神經(jīng)網(wǎng)絡(luò) (GNN) 來(lái)預(yù)測(cè)目標(biāo)基因的表達(dá)譜,并解釋訓(xùn)練后的模型以解碼 FCE。下圖d說(shuō)明了該過(guò)程。首先通過(guò) one-hot 編碼或每個(gè)spot的細(xì)胞類型百分比獲得了一個(gè)矩陣,該矩陣表示每個(gè)細(xì)胞的細(xì)胞類型。然后,采用該視圖的CE網(wǎng)絡(luò)作為鄰接矩陣,將細(xì)胞類型矩陣的每一列作為特征分配給每個(gè)圖的對(duì)應(yīng)節(jié)點(diǎn),為每個(gè)視圖構(gòu)建一個(gè)GNN。每個(gè)視圖的節(jié)點(diǎn)嵌入與注意力機(jī)制相結(jié)合。綜合結(jié)果進(jìn)一步輸入全連接層以估計(jì) ΔE。另一方面,構(gòu)建另一個(gè)全連接層以從細(xì)胞類型矩陣估計(jì) E0。整個(gè)模型被訓(xùn)練以最小化 E 與 E0 和 ΔE 之和之間的差異。

訓(xùn)練后,解釋 HoloNet 的attention weights,以指示多視圖網(wǎng)絡(luò)中的哪些視圖對(duì)目標(biāo)基因的表達(dá)貢獻(xiàn)更大。 與這些views相對(duì)應(yīng)的配體-受體對(duì)被認(rèn)為是調(diào)節(jié)靶基因表達(dá)的 FCE 的核心介質(zhì)。 所有訓(xùn)練模型中的所有注意力權(quán)重及其平均值都可視化為 FCE 中介圖。 可以基于圖卷積層進(jìn)一步識(shí)別 FCE 中主要的發(fā)送方和接收方細(xì)胞類型,以構(gòu)建細(xì)胞類型級(jí)的 FCE 連接網(wǎng)絡(luò)。 為了確保研究結(jié)果的可靠性,對(duì)每個(gè)目標(biāo)基因重復(fù)了訓(xùn)練過(guò)程,并整合了所有模型預(yù)測(cè)的基因表達(dá)和模型解釋結(jié)果。

The overall workflow of HoloNet

圖注:a Definition of CEs and FCEs. b Constructing multi-view CE networks using spatial transcriptomic data. c As CE visualization, HoloNet provides CE hotspots and cell-type-level CE networks. d Predicting specific gene expressions via multi-view graph learning on the constructed multi-view CE network. e As FCE visualization, HoloNet identifies the core mediators and core senders of FCEs for specific genes.

看一看分析示例

Characterizing the cell–cell communication landscape of a breast cancer Visium dataset by HoloNet

圖注:a The cell type with the highest percentage in each spot. Each dot printed on the slide represents a single invisible capture spot with a diameter of 55 μm. b The percentages of basal-like-1 and stromal cells in each spot. c The constructed single-view CE network based on the COL1A1:DDR1 pair. The size of a node indicates the degree centralities of the node in the network, and the color indicates the sender-receiver attribute of the node. The sender-receiver attribute is the result of subtracting the in-degree of a node from its out-degree. The redder the color of nodes, the more inclined the nodes are to act as a sender, and the bluer on the contrary. The thickness of an edge indicates the strength of CEs between cells linked by it. Nodes with too small size and edges with too low thickness are not displayed. Nodes are mapped to the spatial positions of their corresponding spots in the hematoxylin and eosin (H&E) stained histology image. d CE hotspot plot describes regions with active COL1A1:DDR1 signals. For (C), (D) and (E), the protruding region between parenchyma and stroma is highlighted. e Cell-type-level CE network plot describes the COL1A1:DDR1 communication landscape between cell types. The thickness of an edge reflects the summed weight of all edges in the CE network between the pair of cell types. f Low-dimensional representation of the eigenvector centrality vectors of each view plotted by UMAP. All ligand–receptors were hierarchically clustered into four groups based on the eigenvector centrality vectors.

看看代碼示例

安裝很簡(jiǎn)單
pip install HoloNet
分析以10X數(shù)據(jù)為例
import HoloNet as hn

import os
import pandas as pd
import numpy as np
import scanpy as sc
import matplotlib.pyplot as plt
import torch

import warnings
warnings.filterwarnings('ignore')
hn.set_figure_params(tex_fonts=False)
sc.settings.figdir = './figures/'
加載數(shù)據(jù)

Loading example spatial transcriptomic data

adata = hn.pp.load_brca_visium_10x()
####Visualize the cell-type percentages in each spot
hn.pl.plot_cell_type_proportion(adata, plot_cell_type='stroma')
圖片.png

The parameters of plotting functions in this tutorials are mainly inherited from two base plotting functions:

###The cell-type label of each spot (the cell-type with maximum percentage in the spot)
sc.pl.spatial(adata, color=['cell_type'], size=1.4, alpha=0.7,
             palette=hn.brca_default_color_celltype)
圖片.png
Loading ligand-receptor database
###We provide a database with pairwise ligand and receptor genes for users. Load the database and filter the LR pairs, requiring both ligand and receptor genes to be expressed in a certain percentage of cells (or spots).
LR_df = hn.pp.load_lr_df()
expressed_LR_df = hn.pp.get_expressed_lr_df(LR_df, adata, expressed_proportion=0.3)
expressed_LR_df.head(3)
圖片.png

Constructing multi-view CE network

Ligand molecules from a single source can only cover a certain region.
Before constructing multi-view communication network, we need to calculate the w_best to decide the region (‘how far is far’).
The parameters for culcalating w_best is shown in HoloNet.tools.default_w_visium()

w_best = hn.tl.default_w_visium(adata)
hn.pl.select_w(adata, w_best=w_best)
圖片.png

Based on w_best, we can build up the multi-view communication network.

We calculate the edge weights of the multi-view communication network. With the more attributions of ligands, HoloNet.tools.compute_ce_tensor() can set different w_best for secreted ligands and plasma-membrane-binding ligands.

Then we filter the edges with low specificities.

CE_tensor = hn.tl.compute_ce_tensor(adata, lr_df=expressed_LR_df, w_best=w_best)
CE_tensor_filtered = hn.tl.filter_ce_tensor(CE_tensor, adata,
                                            lr_df=expressed_LR_df, w_best=w_best)

Visualizing CEs

Based on the multi-view CE network, we provide two visualization methods:

CE hotspot plots for visualizing the centralities of spots. Provide two calculating methods:

  • Degree centrality: out-degree + in-degree, faithfully reflects the CE strength related to each spot.
  • Eigenvector centrality: reflects the core regions with active communication.

Cell-type-level CE network:

  • CE strengths among cell-types

Cell-type-level CE network

###Loading the cell-type percentage of each spot.
cell_type_mat, \
cell_type_names = hn.pr.get_continuous_cell_type_tensor(adata, continuous_cell_type_slot = 'predicted_cell_type',)
####Plotting the cell-type-level CE network. The thickness of the edge represents the strength of COL1A1:DDR1 communication between the two cell types.
_ = hn.pl.ce_cell_type_network_plot(CE_tensor_filtered, cell_type_mat, cell_type_names,
                                    lr_df=expressed_LR_df, plot_lr='COL1A1:DDR1', edge_thres=0.2,
                                    palette=hn.brca_default_color_celltype)
圖片.png

LR pair clustering

Agglomerative Clustering the ligand-receptor pairs based on the centrality of each spot. The cluster label of each ligand-receptor pair saved in clustered_expressed_LR_df['cluster']. The number of clusters can be selected using n_clusters parameter in HoloNet.tools.cluster_lr_based_on_ce()

cell_cci_centrality = hn.tl.compute_ce_network_eigenvector_centrality(CE_tensor_filtered)
clustered_expressed_LR_df = hn.tl.cluster_lr_based_on_ce(CE_tensor_filtered, adata, expressed_LR_df,
                                                         w_best=w_best, cell_cci_centrality=cell_cci_centrality)

Visualize the ligand-receptor pair clusters in a UMAP plot. Each ligand-receptor pair has a centrality vector, containing the centralities of spots in the view of CE network The UMAP plot is a low dimentional representation of the centrality vectors.

hn.pl.lr_umap(clustered_expressed_LR_df, cell_cci_centrality, plot_lr_list=['COL1A1:DDR1'], linewidths=0.7)
圖片.png

General CE hotspot of each ligand-receptor cluster (superimposing All CE hotspots of members in a cluster).

hn.pl.lr_cluster_ce_hotspot_plot(lr_df=clustered_expressed_LR_df,
                                 cell_cci_centrality=cell_cci_centrality,
                                 adata=adata)
圖片.png

解碼功能性細(xì)胞間通訊事件的全息圖

For each downstream target gene, HoloNet:

  • Identifies cell types serving as major senders
  • Identifies ligand–receptor pairs serving as core mediators

in FCEs for specific downstream genes.

The tutorial mainly follows these steps:
Load data and construct multi-view communication event (CE) network
Predict specific target gene expression.
Decode the FCEs for the gene by interpreting the trained model.
Identify genes more affected by cell–cell communication.

import HoloNet as hn

import os
import pandas as pd
import numpy as np
import scanpy as sc
import matplotlib.pyplot as plt
import torch

import warnings
warnings.filterwarnings('ignore')
hn.set_figure_params(tex_fonts=False)
sc.settings.figdir = './figures/'

Data loading and constructing multi-view CE network

adata = hn.pp.load_brca_visium_10x()
####Load the ligand-receptor (LR) pair database and filter the LR pair:
LR_df = hn.pp.load_lr_df()
expressed_LR_df = hn.pp.get_expressed_lr_df(LR_df, adata, expressed_proportion=0.3)

Then build multi-view CE network using HoloNet.tools.compute_ce_tensor() and HoloNet.tools.filter_ce_tensor().

w_best = hn.tl.default_w_visium(adata)
CE_tensor = hn.tl.compute_ce_tensor(adata, lr_df=expressed_LR_df, w_best=w_best)
CE_tensor_filtered = hn.tl.filter_ce_tensor(CE_tensor, adata,
                                            lr_df=expressed_LR_df, w_best=w_best)

Predicting the target gene expression using a graph model

construct a multi-view graph learning model to predict the expression of gene on interest.


圖片.png

Selecting the target gene to be predicted

Firstly, we select the target genes to be predicted.

The genes with too low, too sparse or too average expression are filtered out. The filtering parameters can be changed in HoloNet.predicting.get_gene_expr().
Then we select MMP11, a gene related to tumor invasion as an example target gene.

target_all_gene_expr, used_gene_list = hn.pr.get_gene_expr(adata, expressed_LR_df)
target = hn.pr.get_one_case_expr(target_all_gene_expr, cases_list=used_gene_list,
                                 used_case_name='MMP11')
sc.pl.spatial(adata, color=['MMP11'], cmap='Spectral_r', size=1.4, alpha=0.7)
圖片.png

Getting inputs of the graph model

In the multi-view graph learning model, we:

  • Use the cell-type matrix as the feature matrix.
  • Use normalized multi-view CE network as the adjacency matrix.

Get the feature matrix and adjacency matrix

X, cell_type_names = hn.pr.get_continuous_cell_type_tensor(adata, continuous_cell_type_slot = 'predicted_cell_type',)
adj = hn.pr.adj_normalize(adj=CE_tensor_filtered, cell_type_tensor=X, only_between_cell_type=True)

If selecting to use categorical cell-type labels, the feature matrix can be derived from HoloNet.predicting.get_one_hot_cell_type_tensor().

Training the graph model

The we train the graph model to predict MMP11 expression. If GPU is avaiable, you can set the device parameter as ‘gpu’. Otherwise, we use CPU by default. The predicted MMP11 expression pattern are similar to the true pattern.

trained_MGC_model_MMP11_list = hn.pr.mgc_repeat_training(X, adj, target, device='gpu')
predict_result_MMP11 = hn.pl.plot_mgc_result(trained_MGC_model_MMP11_list, adata, X, adj)
np.corrcoef(predict_result_MMP11.T, target.T)[0,1]
圖片.png

Decode the FCEs for the gene by interpreting the trained model

After training the graph model and find the predicted expression profile similar to the true one, we can interprete the trained model to reveal the holography of FCEs.

For each target gene, there are three main output figure:

LR rank

  • Identify ligand–receptor (LR) pairs serving as core mediators in FCEs for the target gene.

Cell-type-level FCE network

  • Identifies cell types serving as major senders
  • The cell-type-level FCE network can be LR-pair-specific or general.

Delta E proportion in each cell-type

  • Identify target gene expression in which cell-types are more dominated by FCEs.
LR rank

Plot the top 15 LR pairs (15 can be changed using plot_lr_num parameter) with the highest view attention weights The heatmap displays the attention weights of each view obtained from repeated training for 50 times. The bar plot represents the mean values of the attention weights of each view.

ranked_LR_df_for_MMP11 = hn.pl.lr_rank_in_mgc(trained_MGC_model_MMP11_list, expressed_LR_df,
                                              plot_cluster=False, repeat_attention_scale=True)
圖片.png

If you want plot the LR-pair clustering results in the LR rank plot, you can set cluster_col=True and provide clustering results in expressed_LR_df.
LR pair clustering can see the first tutorial and HoloNet.tools.cluster_lr_based_on_ce().

Cell-type-level FCE network

Cell-type-level POSTN:PTK7 FCE network for MMP11. The thickness of the edge represents the strength of POSTN:PTK7 FCEs between the two cell types. The network are derived from interpreting the graph convolutional layer.

In the plot, you can focus on one cell-type and look the edges targeted on it, in order to identify which cell-types are the major sender for it.

_ = hn.pl.fce_cell_type_network_plot(trained_MGC_model_MMP11_list, expressed_LR_df, X, adj,
                                     cell_type_names, plot_lr='POSTN:PTK7', edge_thres=0.2,
                                     palette=hn.brca_default_color_celltype,)
圖片.png

If plot_lr is one of the LR pair in the expressed_LR_df, HoloNet.plotting.fce_cell_type_network_plot() will plot the cell-type-level FCE network for a specific LR pair. If plot_lr='all', it will plot the general cell-type-level FCE network for all LR pairs.

Delta E proportion in each cell-type

Identify target gene expression in which cell-types are more dominated by FCEs.

The ratio of the expression change caused by CEs (ΔE) to the sum of ΔE and the baseline MMP11 expression (E0) in each cell type.

delta_e = hn.pl.delta_e_proportion(trained_MGC_model_MMP11_list, X, adj,
                                    cell_type_names,
                                    palette = hn.brca_default_color_celltype)
圖片.png

Identify genes more affected by cell–cell communication

We train the graph model for all selected target genes. (HoloNet.predicting.get_gene_expr() select target gene to be predicted)

Comparing with prediction only using cell-type information, the target with higher performance improvement after considering CEs can be regarded as the genes more affected by cell–cell communication.

trained_MGC_model_only_type_list, \
trained_MGC_model_type_GCN_list = hn.pr.mgc_training_for_multiple_targets(X, adj, target_all_gene_expr, device='gpu')

The training process will take a lot of time, you can select to:

Get the predicting results of all target genes

predicted_expr_type_GCN_df = hn.pr.get_mgc_result_for_multiple_targets(trained_MGC_model_type_GCN_list,
                                                                        X, adj,
                                                                        used_gene_list, adata)
predicted_expr_only_type_df = hn.pr.get_mgc_result_for_multiple_targets(trained_MGC_model_only_type_list,
                                                                        X, adj,
                                                                        used_gene_list, adata)

Calculate the Pearson correlation between the predicted expression and the true expression. Compare the correlation from model only using cell-type information and the ones from HoloNet.

The head target genes in only_type_vs_GCN_all table are the genes more affected by cell–cell communication. Gene Ontology (GO) enrichment can be implemented based on the table.

only_type_vs_GCN_all = hn.pl.find_genes_linked_to_ce(predicted_expr_type_GCN_df,
                                                     predicted_expr_only_type_df,
                                                     used_gene_list, target_all_gene_expr,
                                                     plot_gene_list = ['MMP11'], linewidths=0.5)
圖片.png
only_type_vs_GCN_all.head(15)
圖片.png

Model saving and loading?

Trained model can be saved to avoid repetitive training. The models will be saved in ‘model_save_folder/project_name/gene_name’. The ‘gene_name’ are genes in the target_gene_name_list. For different trained model, you can set different project_name.

hn.pr.save_model_list(trained_MGC_model_type_GCN_list,
                      project_name='BRCA_10x_generating_all_target_gene_type_GCN',
                      target_gene_name_list=used_gene_list)
hn.pr.save_model_list(trained_MGC_model_only_type_list,
                      project_name='BRCA_10x_generating_all_target_gene_only_type',
                      target_gene_name_list=used_gene_list)

Setting the target_gene_name_list as one gene, the trained model for MMP11 can be saved in the same way.

Model loading. used_genes are the list of ‘gene_name’ before. Note that the order of used_genes is different from the used_gene_list before.

trained_MGC_model_only_type_list_tmp, \
used_genes = hn.pr.load_model_list(X, adj, project_name='BRCA_10x_generating_all_target_gene_only_type',
                                   only_cell_type=True)
trained_MGC_model_type_GCN_list_tmp, \
used_genes = hn.pr.load_model_list(X, adj, project_name='BRCA_10x_generating_all_target_gene_type_GCN')

Using the loaded model, you can repeat the results in the previous section.

predicted_expr_type_GCN_df_tmp = hn.pr.get_mgc_result_for_multiple_targets(trained_MGC_model_type_GCN_list_tmp,
                                                                        X, adj,
                                                                        used_genes, adata)
predicted_expr_only_type_df_tmp = hn.pr.get_mgc_result_for_multiple_targets(trained_MGC_model_only_type_list_tmp,
                                                                        X, adj,
                                                                        used_genes, adata)
only_type_vs_GCN_all2 = hn.pl.find_genes_linked_to_ce(predicted_expr_type_GCN_df_tmp.loc[:,used_gene_list],
                                                     predicted_expr_only_type_df_tmp.loc[:,used_gene_list],
                                                     used_gene_list, target_all_gene_expr,
                                                     plot_gene_list = ['MMP11'], linewidths=0.5)
圖片.png

參考網(wǎng)址在HoloNet: Decoding functional cell–cell communication events by multi-view graph learning on spatial transcriptomics

好了,已經(jīng)分享給大家了,生活很好,有你更好,百度文庫(kù)出現(xiàn)了大量抄襲我的文章,對(duì)此我深表無(wú)奈,我寫(xiě)的文章,別人掛上去賺錢(qián),抄襲可恥,掛到百度文庫(kù)的人更可恥

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

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

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