作者,Evil Genius
小年了,俗话说,过了腊八就是年,现在我们都过小年了,就提醒一句啊,大家速度结婚。
今天我们复习,mistyR的python版本。
一些基础知识需要大家掌握
首先是decoupler,大家先要学习一下,链接在decoupler - Ensemble of methods to infer biological activities — decoupler 1.8.1 documentation
。
decoupler囊括了11个包,这11个软件很多大家都很熟悉。
decoupleR包里面封装了PROGENy, PROGENy是一个综合资源,包含精心挑选的通路及其目标基因集合,每个相互作用都有权重,下面是简单的介绍。
Androgen: involved in the growth and development of the male reproductive organs.
EGFR: regulates growth, survival, migration, apoptosis, proliferation, and differentiation in mammalian cells
Estrogen: promotes the growth and development of the female reproductive organs.
Hypoxia: promotes angiogenesis and metabolic reprogramming when O2 levels are low.
JAK-STAT: involved in immunity, cell division, cell death, and tumor formation.
MAPK: integrates external signals and promotes cell growth and proliferation.
NFkB: regulates immune response, cytokine production and cell survival.
p53: regulates cell cycle, apoptosis, DNA repair and tumor suppression.
PI3K: promotes growth and proliferation.
TGFb: involved in development, homeostasis, and repair of most tissues.
TNFa: mediates haematopoiesis, immune surveillance, tumour regression and protection from infection.
Trail: induces apoptosis.
VEGF: mediates angiogenesis, vascular permeability, and cell migration.
WNT: regulates organ morphogenesis during development and tissue repair.
我们获取一下
progeny = dc.get_progeny(organism='human', top=500)
progeny
当然了,这个软件的功能很多,重点部分已经给大家标注了。
然后就是我们今天的重点,空间细胞关系
MISTy是一个工具,帮助理解不同特征,如基因或细胞类型,在空间中的相互作用方式。MISTy通过学习细胞内和细胞外的关系来实现这一点-即发生在细胞/spot内部和之间的关系。MISTy的一个主要优势是其灵活性。它可以模拟不同的视角,或“视图”,每个视图描述标记物之间不同的关联方式。这些视图中的每一个都可以描述不同的空间背景,即定义标记物观察表达之间的关系,如细胞内调节或旁分泌调节。
我们来实现一下,先做好单细胞空间联合分析(cell2location)
#pip install "decoupler>=1.4.0"
import scanpy as sc
import decoupler as dc
import plotnine as p9
import liana as li
from liana.method import MistyData, genericMistyData, lrMistyData
from liana.method.sp import RandomForestModel, LinearModel, RobustLinearModel
adata = sc.read("test.h5ad")
adata.layers['counts'] = adata.X.copy()
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
sc.pl.spatial(adata, color=[None, 'celltype_niche'], size=1.3, palette='Set1')
看一下cell2location的结果,细胞矩阵。
adata.obsm['compositions']
对细胞类型采用缩写表示
# Rename to more informative names
full_names = {'Adipo': 'Adipocytes',
'CM': 'Cardiomyocytes',
'Endo': 'Endothelial',
'Fib': 'Fibroblasts',
'PC': 'Pericytes',
'prolif': 'Proliferating',
'vSMCs': 'Vascular_SMCs',
}
# but only for the ones that are in the data
adata.obsm['compositions'].columns = [full_names.get(c, c) for c in adata.obsm['compositions'].columns]
comps = li.ut.obsm_to_adata(adata, 'compositions')
comps.var
接下来估计通路活性, PROGENy。
# obtain genesets
progeny = dc.get_progeny(organism='human', top=500)
# use multivariate linear model to estimate activity
dc.run_mlm(
mat=adata,
net=progeny,
source='source',
target='target',
weight='weight',
verbose=True,
use_raw=False,
)
# extract progeny activities as an AnnData object
acts_progeny = li.ut.obsm_to_adata(adata, 'mlm_estimate')
# Check how the pathway activities look like
sc.pl.spatial(acts_progeny, color=['Hypoxia', 'JAK-STAT'], cmap='RdBu_r', size=1.3)
Formatting & Running MISTy
misty = genericMistyData(intra=comps, extra=acts_progeny, cutoff=0.05, bandwidth=200, n_neighs=6)
Learn Relationships with MISTy
misty(model=RandomForestModel, n_jobs=-1, verbose = True)
li.pl.interactions(misty, view='juxta', return_fig=True, figure_size=(7,5))
Ligand-Receptor Misty
sc.pp.highly_variable_genes(adata)
hvg = adata.var[adata.var['highly_variable']].index
misty = lrMistyData(adata[:, hvg], bandwidth=200, set_diag=False, cutoff=0.01, nz_threshold=0.1)
(
li.pl.interactions(misty, view='extra', return_fig=True, figure_size=(6, 5), top_n=25, key=abs) +
p9.scale_fill_gradient2(low = "blue", mid = "white", high = "red", midpoint = 0) +
p9.labs(y='Receptor', x='Ligand')
)