跳转到主要内容

动力学图分析工具

项目描述

动力学图分析

CI codecov DOI

Python包,用于使用T.L. Hill开发的图示方法分析生化动力学图。

警告:此软件处于动态变化中,且API不稳定。

示例

KDA具有许多功能,所有功能都从定义系统的连接和反应速率(如有需要)开始。这是通过构建一个NxN数组来完成的,其中对角线值设为零,非对角线值(i, j)代表状态ij之间的连接(和反应速率)。如有需要,这些可以是边权重(表示为kij),但它们可以稍后指定。

以下是一个具有所有节点连接的简单3状态模型的示例

import numpy as np
import networkx as nx
from kda import graph_utils, calculations

# define matrix with reaction rates set to 1
K = np.array(
    [
        [0, 1, 1],
        [1, 0, 1],
        [1, 1, 0],
    ]
)
# initialize an empty graph object
G = nx.MultiDiGraph()
# populate the edge data
graph_utils.generate_edges(G, K, val_key="val", name_key="name")
# calculate the state probabilities
state_probabilities = calculations.calc_state_probs(G, key="val")
# get the state probabilities in expression form
state_probability_str = calculations.calc_state_probs(G, key="name", output_strings=True)
# print results
print("State probabilities: \n", state_probabilities)
print("State 1 probability expression: \n", state_probability_str[0])

上述示例的输出

$ python example_script.py
State probabilities:
 [0.33333333 0.33333333 0.33333333]
State 1 probability expression:
 (k21*k31 + k21*k32 + k23*k31)/(k12*k23 + k12*k31 + k12*k32 + k13*k21 + k13*k23 + k13*k32 + k21*k31 + k21*k32 + k23*k31)

正如预期的那样,状态概率是相等的,因为所有边权重都设置为1。

继续前面的示例,KDA的diagramsplotting模块可以用来显示导致上述概率表达式的图

import os
from kda import diagrams, plotting

# generate the set of directional diagrams for G
directional_diagrams = diagrams.generate_directional_diagrams(G)
# get the current working directory
cwd = os.getcwd()
# specify the positions of all nodes in NetworkX fashion
node_positions = {0: [0, 1], 1: [-0.5, 0], 2: [0.5, 0]}
# plot and save the input diagram
plotting.draw_diagrams(G, pos=node_positions, path=cwd, label="input")
# plot and save the directional diagrams as a panel
plotting.draw_diagrams(
    directional_diagrams,
    pos=node_positions,
    path=cwd,
    cbt=True,
    label="directional_panel",
)

这将在您的当前工作目录中生成两个文件,input.pngdirectional_panel.png

input.png

3-state model input diagram

directional.png

3-state model directional diagrams

注意:更多示例(如下所示)请访问KDA 示例仓库

4-state model with leakage input diagram 5-state model with leakage input diagram 6-state model with leakage input diagram

安装

从源码开发版本

要从源码安装最新开发版本,请运行

git clone git@github.com:Becksteinlab/kda.git
cd kda
python setup.py install

版权

版权所有(c)2020,Nikolaus Awtrey

致谢

本项目基于计算分子科学 Python Cookiecutter版本1.2。

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

kda-0.3.0.tar.gz (74.6 kB 查看哈希值

上传时间 源代码

构建分发

kda-0.3.0-py3-none-any.whl (64.9 kB 查看哈希值

上传时间 Python 3

由以下支持