0

I tried run_ssa from Python PySB library using "Hello world" ODE simulation model (replacing the concentrations with corresponding molecular number and converting deterministic rates to stochastic equivalents).

This is trajectories obtained using odesolve method:

[(301.0, 180.0, 0.0, 0.0)
 (269.7114893451928, 148.71148934519294, 31.288510654807023, 31.288510654807023)
 (246.1336243593057, 125.13362435930587, 54.866375640694116, 54.866375640694116)
 (227.7848590843455, 106.78485908434567, 73.21514091565433, 73.21514091565433)
 (213.1444366774497, 92.1444366774498, 87.8555633225502, 87.8555633225502)...

which look reasonable.

And this is what run_ssa returns:

[(0.0, 0.0) (0.4, 27.0) (0.8, 54.0) (1.2, 73.0) (1.6, 81.0) (2.0, 98.0)
 (2.4, 116.0) (2.8, 124.0) (3.2, 129.0) (3.6, 135.0) (4.0, 137.0)
 (4.4, 141.0) (4.8, 144.0) (5.2, 145.0) (5.6, 146.0) (6.0, 149.0)
 (6.4, 153.0) (6.8, 157.0) (7.2, 159.0) (7.6, 160.0) (8.0, 162.0)
 (8.4, 162.0) (8.8, 165.0) (9.2, 164.0) (9.6, 166.0) (10.0, 167.0)
 (10.4, 168.0) (10.8, 171.0) (11.2, 172.0) (11.6, 172.0) (12.0, 174.0)
 (12.4, 175.0) (12.8, 176.0) (13.2, 176.0) (13.6, 176.0) (14.0, 176.0)
 (14.4, 177.0) (14.8, 177.0) (15.2, 177.0) (15.6, 177.0) (16.0, 177.0)
 (16.4, 177.0) (16.8, 177.0) (17.2, 177.0) (17.6, 177.0) (18.0, 177.0)
 (18.4, 177.0) (18.8, 177.0) (19.2, 177.0) (19.6, 178.0) (20.0, 178.0)
 (20.4, 178.0) (20.8, 178.0) (21.2, 178.0) (21.6, 178.0) (22.0, 178.0)
 (22.4, 178.0) (22.8, 179.0) (23.2, 179.0) (23.6, 179.0) (24.0, 180.0)
 (24.4, 180.0) (24.8, 180.0) (25.2, 180.0) (25.6, 180.0) (26.0, 180.0)
 (26.4, 180.0) (26.8, 180.0) (27.2, 180.0) (27.6, 180.0) (28.0, 180.0)
 (28.4, 180.0) (28.8, 180.0) (29.2, 180.0) (29.6, 180.0) (30.0, 179.0)
 (30.4, 179.0) (30.8, 179.0) (31.2, 179.0) (31.6, 179.0) (32.0, 179.0)
 (32.4, 179.0) (32.8, 179.0) (33.2, 179.0) (33.6, 179.0) (34.0, 179.0)
 (34.4, 179.0) (34.8, 179.0) (35.2, 180.0) (35.6, 180.0) (36.0, 180.0)
 (36.4, 180.0) (36.8, 180.0) (37.2, 180.0) (37.6, 180.0) (38.0, 180.0)
 (38.4, 180.0) (38.8, 180.0) (39.2, 180.0) (39.6, 180.0) (40.0, 180.0)]

Looks like instead of taking the initial conditions as a start point, it uses one of them as a limiting factor? And the first array looks like just time to me... According to description it is supposed to return trajectories just as ODE simulation...

By the look of it odesolve calles python library to solve ODE but run_ssa calls BioNetGen modelling language.

I've tried to implement both deterministic and stochastic models for Michaelis-Menten kinetics directly using BioNetGen and they looked fine.

So, the question is: has anyone ever got it working? Any working examples of using it?

The purpose of this is testing the library and I just need to know if it is possible to make it work and if anyone ever managed to do so.

4

2 回答 2

0

PySB 作者/开发者在这里。

看来问题出在我们身上(我在阅读这篇 SO 帖子后才发现)没有记录 run_ssa 函数的返回类型。这将得到补救。正如 AliceNCL 所提到的,run_ssa 返回的输出是从 BNG .gdat 文件中解析回来的。然而,返回的轨迹不是随机的:.gdat 文件包含模型中定义的唯一 Observable 的轨迹:“LR”,配体-受体复合物。另一方面,.cdat 文件包含模型中定义的所有物种的轨迹,简单编号为 1、2、3。因此,按照目前的实施,如果您希望获得特定物种的 SSA 轨迹,你会为它添加一个可观察的。

另一方面,odesolve 函数返回一个包含所有物种(索引为'_s0'、'_ s1 '、'__s2')命名的可观察对象'LR'的recarray。因此,有四个条目,最后两个是相同的:配体-受体复合物作为“物种 2”和命名为可观察的“LR”。

如果您(或其他任何人)在使用该库时遇到任何其他问题,请通过电子邮件发送到 PySB 邮件列表(请参阅 pysb.org 上的链接)或在 GitHub 上发布问题,让我们知道!我们只偶尔检查 Stack Overflow。

无论如何,这是一个工作示例:

from pysb import *
from pysb.examples.hello_pysb import model
from pylab import *
from pysb import bng
from pysb.integrate import odesolve

ion()
t_end = 100

# BNG SSA simulation
ssa_sim = bng.run_ssa(model, t_end=t_end, n_steps=1000)
figure()
plot(ssa_sim['time'], ssa_sim['LR'], color='r')

# ODE simulation
t = linspace(0, t_end)
ode_sim = odesolve(model, t)
plot(t, ode_sim['LR'], color='g')

它产生以下内容:http: //imgur.com/xDNQDIL

于 2014-03-21T04:43:09.793 回答
0

谢谢,我确实意识到它最终到底做了什么,并设法产生了一些工作示例。但它需要一些挖掘代码和 BNG 文档:)。问题是文档示例中的 odesolve 实际上返回了所有轨迹,并且您在绘图时选择了您想要的轨迹,而不仅仅是可观察的轨迹,所以这让我感到困惑。当然,这个工作示例的添加和对文档的更多解释肯定会对研究有很大帮助!除此之外,这是一个很好且有用的库

于 2014-03-22T20:29:39.283 回答