biomass-dev / biomass Goto Github PK
View Code? Open in Web Editor NEWA Python Framework for Modeling and Analysis of Signaling Systems
Home Page: http://biomass-core.rtfd.io
License: Apache License 2.0
A Python Framework for Modeling and Analysis of Signaling Systems
Home Page: http://biomass-core.rtfd.io
License: Apache License 2.0
This is because the remaining name after .
are misrecognized as a filename extension.
get_obj_val
for an objective function>>> from scipy.optimize import differential_evolution
>>> from biomass import Model
>>> from biomass.estimation import ExternalOptimizer
>>> from biomass.models import Nakakuki_Cell_2010
>>> model = Model(Nakakuki_Cell_2010.__package__).create()
>>> optimizer = ExternalOptimizer(model, differential_evolution)
>>> def obj_fun(x):
... '''Objective function to be minimized.'''
... return optimizer.get_obj_val(x)
>>> res = optimizer.run(
... obj_fun,
... [(0, 1) for _ in range(len(model.problem.bounds))],
... strategy="best2bin",
... maxiter=50,
... tol=1e-4,
... mutation=0.1,
... recombination=0.5,
... disp=True,
... polish=False,
... workers=-1,
... )
differential_evolution step 1: f(x)= 5.19392
differential_evolution step 2: f(x)= 2.32477
differential_evolution step 3: f(x)= 1.93583
...
differential_evolution step 50: f(x)= 0.519774
>>> from biomass import run_simulation
>>> param_values = model.problem.gene2val(res.x)
>>> optimizer.import_solution(param_values, x_id=0)
>>> run_simulation(model, viz_type="0")
Currently, flux vector v is in set_model.py
. To my mind, it is more preferable to have in reaction_network.py
.
As pasmopy 0.3.0 supports better text-to-model conversion method (pasmopy/pasmopy#78), we will need a tutorial that contains followings:
pasmopy.Text2Model
out/...
, figure/...
, sensitivity_coefficients/...
etc) directly into subdirectories to /models/<model_name>/The error message raised from line 73 in temporal_dynamics.py
is not user-friendly and difficult to identify what causes an error.
viz.py
in user-defined modelcmap
and shape
When enabling multiple_observables_options and execute run_simulation(..., viz_type="average")
, all trajectories for each simulation condition are divided by their maximum values.
Thanks Hayate Takagishi for reporting this error.
Text2Model of reversible reaction with one reactant and one product fails.
Text file containing:
A + C <--> B
A <--> B
Convert to model:
from biomass import Text2Model
model = Text2Model("test.txt")
model.convert(overwrite=True)
DetectionError
Unregistered words in line2: A <--> B
The following error was produced when running the example in the readme
RuntimeWarning: invalid value encountered in double_scalars
+ (y[V.Fn] / x[C.KF31]) ** x[C.nF31]
The code:
from biomass import Model, optimize
from biomass.models import Nakakuki_Cell_2010
model = Model(Nakakuki_Cell_2010.__package__).create()
run_simulation(model, viz_type="average", stdev=True)
I think it is caused by an undefined parameter and thus, I propose changing the model used in the exampleto another model that does not require manual input of parameters, or to pre-input the default parameter for the model.
Please let me know if this is a misunderstanding.
If not explicitly declaring observables, Text2Model fails in generating a valid observables.py file.
Text file containing:
A + C <--> B
Convert to model:
from biomass import Text2Model, create_model
model = Text2Model("test.txt")
model.convert(overwrite=True)
model = create_model(test)
IndentationError:
expected an indented block after 'else' statement on line 75
Change line 530 in text2model.py of kinetics branch to:
lines[line_num + 3] = f"{4 * self.indentation}pass\n"
Current implementation of Mass action kinetics is limited to 2 reactants or 2 products. Mass action rate law can however be generalized to n reactants and n products (see e.g. https://doi.org/10.1007/BF00251225 or https://doi.org/10.1371%2Fjournal.pcbi.1004012).
The easiest implementation I could find is the one as stated in the textbook "Systems Biology" Klipp et al. p.40 :
With
Species that appear on both sides of the equation could be treated as modulators.
Hi @formersbach, thanks for implementing amazing features!
As we discussed before, I have tried to create all files related to a single model in the model folder so that a user will not forget where he/she saved a file.
Accordingly, I would like to save graph in the model folder as well, which can easily be achieved by adding self.path
in the beginning of each path:
# Example, from
self.graph.draw(os.path.join(save_dir, file_name))
network.save_graph(os.path.join(save_dir, file_name))
# to
self.graph.draw(os.path.join(self.path, save_dir, file_name))
network.save_graph(os.path.join(self.path, save_dir, file_name))
If it is ok for you, I would like to set "graph" to save_dir
as a default folder name.
If "is phosphorylated" reaction rule is used with a unphosphorylated species that has been previously used, a second ODE is mistakenly generated.
Text file containing:
TNFR phosphorylates Ikk --> pIkk
Ikk is phosphorylated <--> pIkk
pIkk is phosphorylated <--> ppIkk
Convert to model:
from biomass import Text2Model, create_model
model = Text2Model("test.txt")
model.convert(overwrite=True)
model = create_model(test)
Add missing format string in line 1099:
elif "dydt[V.{phosphorylated_form}]" in eq:
to
elif f"dydt[V.{phosphorylated_form}]" in eq:
When choosing "DE" as a local_search_method
, the objective function value does not decrease.
numpy.ndarray
Hi @formersbach,
I thinks the type of show_controls
in the example code of dynamic_plot()
should be boolean, not string:
model.dynamic_plot(save_dir='example_dir', file_name='nfkb_dynamic.html' show_controls='True', which_controls=['physics', 'layout'])
If yes, I have a fix-doc branch and fix this.
Thank you!
When running
run_simulation(model, viz_type="experiment")
and len(x) != len(y)
, this will raise the following error message:
ValueError: 'x' and 'y' must have the same size
But it's difficult to identify the cause of the error from this.
https://biomass-core.readthedocs.io/en/latest/installation.html
In the Note, graph visualization functions <https://biomass-core.readthedocs.io/en/latest/graph_visualization.html>
_ should be graph visualization functions <https://biomass-core.readthedocs.io/en/latest/tutorial/nfkb.html>
_ now.
>>> from biomass.models import your_model
>>> from biomass import Model, optimize
>>> model = Model(your_model__package__).create()
>>> optimize(model, x_id=1) # x_id must be int
As pasmopy depends on biomass, it would be nice to host Text2Model
source code as a biomass core library for enabling text-to-model conversion without installing pasmopy.
TODO:
construction/
Equation where 1 reactant reacts to 2 products is not covered by state_transition
function but rather raises ValueError
in _bind_and_dissociate
.
I was trying to create a transcription event with mass action kinetics. I'm not sure whether this is "right" or "wrong", maybe you have an idea @himoto !
Text file containing:
nNfk --> nNfk + mIkb
Convert to model:
from biomass import Text2Model, create_model
model = Text2Model("test.txt")
model.convert(overwrite=True)
Raises :
ValueError
line1: nNfk <- Use a different name.
ODE:
dmIkb/dt = kf1 * nNfk
dnNfk/dt = 0
TODO:
pyvis
to requirements.txt
As implemented now, the simulated model time (duration and implicit unit) must be entered in observable.py, however, to truly adapt simulation time, also the plot script needs to be modified. Just as a suggestion, maybe this can be circumvented by adding some time variable to observable.py which is then passed to the plot script? Potentially, this could also include other plotting parameters such as axes limits etc. Some plotting parameters are currently hard coded, maybe there would be a way to dynamically adapt the plot range, potentially circumventing problems when working on several models in parallel.
optimizer_options['init']
.val2gene
is no longer usedgene2val
to ModelObject class?Old | New |
---|---|
set_model.py |
ode.py |
set_search_param.py |
search_param.py |
fitness.py |
problem.py |
TODO:
_check_indices()
in core.py
I have moved the usage example of graph visualization to a new directory (#176, #178) and accidentally left the link to graph unmodified. https://biomass-core.readthedocs.io/en/latest/tutorial/nfkb.html
Link to fos_model.txt
biomass/biomass/models/insulin_signaling/name2idx/species.py
Lines 26 to 27 in c6f351d
When trying to turn on the annotate_nodes option of dynamic_plot() in graph.py, the desired outcome is not produced.
The adjacency list for the graph cannot be computed.
When parameter estimation is interrupted and re-run it, e.g.,
from biomass import create_model, optimize
model = create_model(...)
optimize(model, x_id=1)
# KeyboardInterrupt
optimize(model, x_id=1)
This will raise ValueError:
ValueError: out/1 already exists in {your_model_dir}. Use another parameter id.
It would be nice to have a parameter: overwrite
in optimize
function, by which we can skip this error when set to True
.
Example:
from biomass.models import insulin_signaling
from biomass import run_simulation
model = insulin_signaling.create()
run_simulation(model, viz_type="original")
*c* argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapping will have precedence in case its length matches with 'x' & 'y'. Please use a 2-D array with a single row if you really want to specify the same RGB or RGBA value for all points
Currently kinetic information and the stoichiometric matrix is only available in the Text2Model object.
This is somewhat impractical since it is only accessible during initial generation of the Model. In my opinion transferring the information to the actual biomass model will be more sustainable for the future, since both the stoichiometric matrix and the kinetic information are vital parts for the downstream analysis of the system.
I'd propose adding the stoichiometric matrix information in ode.py
and the kinetic information to reaction_network.py
.
Currently biomass raises FutureWarning
if you use older module names, but from version 0.10 this will raise an error.
Old | New |
---|---|
set_model.py |
ode.py |
set_search_param.py |
search_param.py |
fitness.py |
problem.py |
Rate of Kinetic Info is supposed to contain the pure rate equation with just parameters and species. state_transition method wrongly adds concentration identifiers such as y[species].
Text file containing:
A --> B
Convert to model:
from biomass import Text2Model, create_model
model = Text2Model("test.txt")
model.convert(overwrite=True)
print(model.kinetics)
model.kinetics.rate
: kf1 * A
model.kinetics.rate
: kf1 * y[V.A]
It might be easier to use if you forward arguments of run_sim.py to the script, so that there will be no need to edit the script. For example
run_sim.py average show_all stdev
to produce:
simulate_all(viz_type='average',show_all=True,stdev=True)
TODO:
graph_visualization.rst
dynamic/static_plot()
Note:
If you want embed images, please put the source in _static/img/
folder. You can call them via .. image:: _static/img/xxx
in .rst files.
As Python 3.8 has long been stable and many packages (e.g., numpy
) dropped Python 3.7 support, it would make sense to follow..
Should be migrated to analysis/reaction.py
if self.exp.error_bar[i] is None
Currently they raise FutureWarning and will be removed from version 0.8.
I have made a docker image for the newest version:
https://hub.docker.com/repository/docker/jnicolaus/biomass
Haven't tested all the functions but so far seemed to work fine using singularity on HPC.
I can make a pull request if it will be required for the readme.
Originally posted by himoto July 23, 2022
BioMass requires users to manually install Graphviz for graph visualization but some packages derived from biomass, e.g., pasmpy, do not need it. Currently if we run import biomass
without Graphviz, it will raise an ImportError.
I would like to make this optional so that biomass-derived packages can be run without error even if Graphviz is not installed.
Ideas:
pygraphviz
and pyvis
from requirements.txt to extras_require in setup.pygraph.py
as follows:def to_graph(self):
try:
import pygraphviz as pgv
except ImportError:
print("pygraphviz is required to run this function.")
...
def dynamic_plot(self, ...):
try:
from pyvis.network import Network
except ImportError:
print("pyvis is required to run this function.")
@formersbach
I would be grateful if you could give me comments on this. I have a branch working on this and if it's ok, I will send a PR.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.