Tutorial 2: graph visualization
This tutorial will show you how to turn your Pasmopy Text model into a graph and generate both static and dynamic images from it. For demonstration purposes we will use a text representation of the nfkb_pathway model included in biomass. For a detailed description of the model, please refer to the following paper:
Oppelt, A. et al. Model-based identification of TNFα-induced IKKβ-mediated and IκBα-mediated regulation of NFκB signal transduction as a tool to quantify the impact of drug-induced liver injury compounds. npj Syst. Biol. Appl. 4, 23 (2018). https://doi.org/10.1038/s41540-018-0058-z
Requirements
biomass>=0.9.0
pygraphviz>=1.9
pyvis>=0.2.1
graphviz>=2.42
Installation instructions can be found here
Prepare a text file describing the model
1TNF synthesizes TNFR| kf=1 | TNF=1
2TNFR is degraded | kf=0.001
3TNFR + Ikk --> pIkk + TNFR | kf=0.0714 | Ikk=1
4pIkk is phosphorylated --> ppIkk | kf=0.0648
5ppIkk --> iIkk | kf=0.166
6iIkk --> Ikk | kf=0.0041
7pIkk + NfkIkb --> NfkpIkb + pIkk | kf=0.398 | NfkIkb=1
8pNfkIkb is phosphorylated --> pNfkpIkb | kf=1.3897
9pIkk + pNfkIkb --> pNfkpIkb + pIkk | kf=0.389
10pIkk + NfkIkb --> pNfkIkb + pIkk | kf=0.6438
11pIkk + NfkpIkb --> pNfkpIkb + pIkk | kf=0.2816
12NfkpIkb --> Nfk + pIkb | kf=0.0811
13pNfkpIkb --> pNfk + pIkb | kf=1
14Nfk + Ikb --> NfkIkb | kf=2.839
15nNfk synthesizes mIkb | kf=0.0047
16mIkb is degraded | kf=0.0313
17mIkb synthesizes Ikb | kf=1
18pIkb is degraded | kf=0.6308
19Ikb translocates from cytoplasm to nucleus (1, 1) --> nIkb | kf=0.1226
20pNfk translocates from cytoplasm to nucleus (1, 1) --> pnNfk | kf=0.179585
21Nfk translocates from cytoplasm to nucleus (1, 1) --> nNfk | kf=0.01
22pnNfk --> nNfk | kf=1000
23nIkb binds nNfk --> nNfkIkb | kf=1000
24nNfkIkb translocates from nucleus to cytoplasm (1, 1) --> NfkIkb | kf=1000
25nNfk synthesizes RnaA20_1 | kf=1
26RnaA20_1 --> RnaA20 | kf=0.0311
27RnaA20 is degraded | kf=0.0089
28RnaA20 synthesizes A20 | kf=0.0006
29A20 is degraded | kf=0.0116
30
31@obs nuclear_IkBa: u[nIkb]
32@obs nuclear_NFkB: u[nNfk]
33
34@sim tspan: [0, 200]
Import the model
from biomass import Text2Model
model = Text2Model('name_of_your_txt_file.txt')
model.convert()
Graph generation and static image
The graph is constructed from the kinetic information gained during model construction. Connections always go from reactants/modifiers to products. There is no destinction made between modifiers and reactants, as well as activating and inhibiting modifiers.
model.graph
The graph property contains an instance of the AGraph class implemented by pygraphviz. For available methods please refer to their documentation. You can for example manually add/remove nodes or save the graph into a .dot file and import it into another 3rd party software.
A static image of the graph is drawn using
model.static_plot(save_dir='example_dir', file_name='nfkb_static.png')
model.static_plot(save_dir='example_dir', file_name='nfkb_static_cust.png',
gviz_args='-Nshape=parallelogram -Nstyle=bold -Estyle=dashed')
The desired file format is inferred from the ending of file_name. Graphviz provides a variety of different engines that automatically generate a layout for the graph. By default the ‘dot’ engine is used, since it uses a hierarchical approach that is natural for biological data. Feel free to play around with the available engines, but be aware that biological networks can quickly become messy due to the prevalance of feedback interactions. Additionally graphviz provides a large variety of customization options, that have to be passed in the command line format. For a comprehensive list see the graphviz manual.
Dynamic image
Thanks to the package pyvis we can also provide an interactive graph. The generation is just as simple as for the static image:
model.dynamic_plot(save_dir='example_dir', file_name='nfkb_dynamic.html' show_controls=True, which_controls=['physics', 'layout'])
By default the plot will be immediately displayed in your browser. Set show
to False
if you don’t want that. pyvis
provides a variety of customization options as well. They can be directly accessed in the html file by setting show_controls
to True
. You can also specify which controls you want.