RNAvelocity10 : scVelo应用—微分动力学
分享是一种态度
微分动力学
一个重要的问题是处理代表多个谱系和过程的系统,其中基因可能在亚群中表现出不同的动力学行为。不同的细胞状态和谱系通常受基因调控网络中不同变异的制约,因此可能表现出不同的拼接动力学。这产生了在相空间中显示多个轨迹的基因。
为此,动力学模型可用于对微分动力学进行可能性比率检验。这样,我们就可以检测显示动力学行为的群,这些动力学行为无法通过整体动力学的单个模型很好地解释。将细胞类型聚类到它们不同的动力学体系中,然后允许将每个系统分开匹配。
我们应用微分动力学分析来牙齿陀螺神经形成数据集[1]来示例,它包括多个异质亚群。
[ ]:
# update to the latest version, if not done yet.
!pip install scvelo --upgrade --quiet
[1]:
import scvelo as scv
scv.logging.print_version()
Running scvelo 0.2.0 (python 3.8.2) on 2020-05-15 00:57.
[2]:
scv.settings.verbosity = 3 # show errors(0), warnings(1), info(2), hints(3)
scv.settings.presenter_view = True # set max width size for presenter view
scv.settings.set_figure_params('scvelo') # for beautified visualization
准备数据
预处理包括基因选择、log标准化和计算时刻。有关进一步解释,请参阅以前的教程。
[3]:
adata = scv.datasets.dentategyrus()
[4]:
scv.pp.filter_and_normalize(adata, min_shared_counts=30, n_top_genes=2000)
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)
Filtered out 11019 genes that are detected in less than 30 counts (shared).
Normalized count data: X, spliced, unspliced.
Logarithmized X.
computing neighbors
finished (0:00:02) --> added
'distances' and 'connectivities', weighted adjacency matrices (adata.obsp)
computing moments based on connectivities
finished (0:00:00) --> added
'Ms' and 'Mu', moments of spliced/unspliced abundances (adata.layers)
基本速率估计
[5]:
scv.tl.velocity(adata)
scv.tl.velocity_graph(adata)
computing velocities
finished (0:00:00) --> added
'velocity', velocity vectors for each individual cell (adata.layers)
computing velocity graph
finished (0:00:05) --> added
'velocity_graph', sparse matrix with cosine correlations (adata.uns)
[6]:
scv.pl.velocity_embedding_stream(adata, basis='umap')
computing velocity embedding
finished (0:00:00) --> added
'velocity_umap', embedded velocity vectors (adata.obsm)
微分动力学检测
不同的细胞类型和谱系可能表现出不同的动力学体系,因为这些可能由不同的网络结构来支配。即使细胞类型或谱系相关,由于可变剪切、可变多腺苷酸化和降解调节,动力学也可以是微分的。
动态模型使我们能够通过微分动力学的可能性比率检测来解决这个问题,以检测显示动力学行为的群/谱系,而整个动力学的单个模型无法充分解释这些行为。每个细胞类型都经过检验,独立拟合是否产生显著改善的可能性。
可以通过卡方分布之后可能性比率检验其显著性。请注意,出于效率原因,默认情况下使用正交回归而不是全相轨迹来检验集群,看是否能由整体动力学或表现出不同的动力学很好地解释。
[7]:
var_names = ['Tmsb10', 'Fam155a', 'Hn1', 'Rpl6']
scv.tl.differential_kinetic_test(adata, var_names=var_names, groupby='clusters')
recovering dynamics
finished (0:00:02) --> added
'fit_pars', fitted parameters for splicing dynamics (adata.var)
outputs model fit of gene: Rpl6
testing for differential kinetics
finished (0:00:00) --> added
'fit_diff_kinetics', clusters displaying differential kinetics (adata.var)
'fit_pval_kinetics', p-values of differential kinetics (adata.var)
outputs model fit of gene: Rpl6
[7]:
<scvelo.tools.dynamical_model.DynamicsRecovery at 0x12390f4a8>
[8]:
scv.get_df(adata[:, var_names], ['fit_diff_kinetics', 'fit_pval_kinetics'], precision=2)
[8]:
[9]:
kwargs = dict(linewidth=2, add_linfit=True, frameon=False)
scv.pl.scatter(adata, basis=var_names, add_outline='fit_diff_kinetics', **kwargs)
例如,在Tmsb10中,内皮细胞显示一种动力学行为(黑线),这不能用整体动力学(紫色曲线)来很好地解释。
[10]:
diff_clusters=list(adata[:, var_names].var['fit_diff_kinetics'])
scv.pl.scatter(adata, legend_loc='right', size=60, title='diff kinetics',
add_outline=diff_clusters, outline_width=(.8, .2))
检测top基因
通过筛选高可能性基因,我们发现一些基因的动态显示多种动力学行为。
[11]:
scv.tl.recover_dynamics(adata)
#adata.write('data/pancreas.h5ad', compression='gzip')
#adata = scv.read('data/pancreas.h5ad')
recovering dynamics
finished (0:06:39) --> added
'fit_pars', fitted parameters for splicing dynamics (adata.var)
[12]:
top_genes = adata.var['fit_likelihood'].sort_values(ascending=False).index[:100]
scv.tl.differential_kinetic_test(adata, var_names=top_genes, groupby='clusters')
testing for differential kinetics
finished (0:00:21) --> added
'fit_diff_kinetics', clusters displaying differential kinetics (adata.var)
'fit_pval_kinetics', p-values of differential kinetics (adata.var)
特别是在不同于主要的细胞类型 - 如 Cck/Tox、GABA、内皮细胞和微胶质细胞中,更常见。
[13]:
scv.pl.scatter(adata, basis=top_genes[:15], ncols=5, add_outline='fit_diff_kinetics', **kwargs)
[14]:
scv.pl.scatter(adata, basis=top_genes[15:30], ncols=5, add_outline='fit_diff_kinetics', **kwargs)
重新计算速率
最后,可以利用多种相互竞争的动力学系统的信息重新计算速率。
[15]:
scv.tl.velocity(adata, diff_kinetics=True)
scv.tl.velocity_graph(adata)
computing velocities
finished (0:00:00) --> added
'velocity', velocity vectors for each individual cell (adata.layers)
computing velocity graph
finished (0:00:05) --> added
'velocity_graph', sparse matrix with cosine correlations (adata.uns)
[16]:
scv.pl.velocity_embedding(adata, dpi=120, arrow_size=2, arrow_length=2)
computing velocity embedding
finished (0:00:00) --> added
'velocity_umap', embedded velocity vectors (adata.obsm)
文中链接
牙齿陀螺神经形成数据集: https://scvelo.readthedocs.io/scvelo.datasets.dentategyrus
如果你对单细胞转录组研究感兴趣,但又不知道如何入门,也许你可以关注一下下面的课程
看完记得顺手点个“在看”哦!
长按扫码可关注