build based on bea55385
Showing
- dev/advanced/1_variants/index.html 1 addition, 1 deletiondev/advanced/1_variants/index.html
- dev/advanced/2_custom_model/index.html 1 addition, 1 deletiondev/advanced/2_custom_model/index.html
- dev/advanced/index.html 1 addition, 1 deletiondev/advanced/index.html
- dev/functions/analysis/index.html 22 additions, 22 deletionsdev/functions/analysis/index.html
- dev/functions/base/index.html 3 additions, 3 deletionsdev/functions/base/index.html
- dev/functions/index.html 1 addition, 1 deletiondev/functions/index.html
- dev/functions/io/index.html 3 additions, 3 deletionsdev/functions/io/index.html
- dev/functions/reconstruction/index.html 28 additions, 28 deletionsdev/functions/reconstruction/index.html
- dev/functions/types/index.html 13 additions, 13 deletionsdev/functions/types/index.html
- dev/functions/utils/index.html 31 additions, 31 deletionsdev/functions/utils/index.html
- dev/howToContribute/index.html 1 addition, 1 deletiondev/howToContribute/index.html
- dev/index.html 1 addition, 1 deletiondev/index.html
- dev/notebooks/1_loading_converting_saving.ipynb 0 additions, 0 deletionsdev/notebooks/1_loading_converting_saving.ipynb
- dev/notebooks/1_loading_converting_saving/index.html 1 addition, 1 deletiondev/notebooks/1_loading_converting_saving/index.html
- dev/notebooks/2_finding_balance/index.html 1 addition, 1 deletiondev/notebooks/2_finding_balance/index.html
- dev/notebooks/3_basic_stdmodel_usage.ipynb 0 additions, 0 deletionsdev/notebooks/3_basic_stdmodel_usage.ipynb
- dev/notebooks/3_basic_stdmodel_usage/index.html 1 addition, 1 deletiondev/notebooks/3_basic_stdmodel_usage/index.html
- dev/notebooks/4_basic_core_coupled_usage/index.html 1 addition, 1 deletiondev/notebooks/4_basic_core_coupled_usage/index.html
- dev/notebooks/5_basic_stdmodel_construction/index.html 1 addition, 1 deletiondev/notebooks/5_basic_stdmodel_construction/index.html
- dev/notebooks/6_screening.ipynb 0 additions, 0 deletionsdev/notebooks/6_screening.ipynb
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
%% Cell type:markdown id: tags: | ||
# Loading, converting, and saving models | ||
%% Cell type:markdown id: tags: | ||
`COBREXA` can load models stored in `.mat`, `.json`, and `.xml` formats (with | ||
the latter denoting SBML formatted models). | ||
%% Cell type:markdown id: tags: | ||
We will primarily use the *E. Coli* "core" model to demonstrate the utilities | ||
found in `COBREXA`. First, let's download the model in several formats. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
# Downloads the model files if they don't already exist | ||
!isfile("e_coli_core.mat") && | ||
download("http://bigg.ucsd.edu/static/models/e_coli_core.mat", "e_coli_core.mat"); | ||
!isfile("e_coli_core.json") && | ||
download("http://bigg.ucsd.edu/static/models/e_coli_core.json", "e_coli_core.json"); | ||
!isfile("e_coli_core.xml") && | ||
download("http://bigg.ucsd.edu/static/models/e_coli_core.xml", "e_coli_core.xml"); | ||
``` | ||
%% Cell type:markdown id: tags: | ||
Now, load the package: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
using COBREXA | ||
``` | ||
%% Cell type:markdown id: tags: | ||
## Loading models | ||
%% Cell type:markdown id: tags: | ||
Load the models using the `load_model` function. Each model is able to | ||
"pretty-print" itself, hiding the inner complexity. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
mat_model = load_model("e_coli_core.mat") | ||
``` | ||
%% Output | ||
Metabolic model of type MATModel | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀ | ||
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀ | ||
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀ | ||
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘ | ||
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄ | ||
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁ | ||
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀ | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀ | ||
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀ | ||
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈ | ||
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀ | ||
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀ | ||
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈ | ||
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
Number of reactions: 95 | ||
Number of metabolites: 72 | ||
%% Cell type:code id: tags: | ||
``` julia | ||
json_model = load_model("e_coli_core.json") | ||
``` | ||
%% Output | ||
Metabolic model of type JSONModel | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀ | ||
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀ | ||
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀ | ||
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘ | ||
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄ | ||
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁ | ||
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀ | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀ | ||
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀ | ||
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈ | ||
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀ | ||
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀ | ||
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈ | ||
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
Number of reactions: 95 | ||
Number of metabolites: 72 | ||
%% Cell type:code id: tags: | ||
``` julia | ||
sbml_model = load_model("e_coli_core.xml") | ||
``` | ||
%% Output | ||
Metabolic model of type SBMLModel | ||
⠀⠈⢀⠀⡀⠀⠀⠀⠀⡠⠂⠀⠀⠀⠀⠈⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⢀⠐⡀⠀⠀⠀⠀⠄ | ||
⠀⠐⠀⠀⠀⠀⠀⠀⡠⠂⠀⠀⠀⠀⢰⠱⣀⠀⡄⢐⠀⠀⢀⠀⠀⠀⡂⠄⠔⠁⠰⠀⠠⠀⣆⠀⠄⢠⢀⠄ | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠠⠀⠀⠐⠀⠀⠀⠀⠀⠀⢀⠀⠀⠐⠀⠂⠀⠀⠀⠄⠀⠐⠀⢁⠄⠀⠀⠀⠀⠀ | ||
⠀⢀⠀⠐⡈⠀⡀⠀⠂⠀⣀⠀⠑⡈⢀⠀⠀⠀⠀⠀⡀⡠⠀⡀⠰⠁⠈⠂⠁⠀⠠⠀⠀⠂⡂⠀⠂⠂⠀⠀ | ||
⠠⠀⠐⠀⠂⠀⠀⢀⠀⠀⠀⠀⠊⠀⡐⠊⠐⠀⠀⠀⠀⠀⠐⠀⠂⠀⠀⠐⠀⠀⠀⠀⠀⠁⠃⠠⠀⠁⠐⠀ | ||
⠀⠠⠀⡀⠄⠀⠀⠂⠀⠀⠀⠠⠀⠠⠀⠀⠄⠀⠨⠀⠀⠀⠐⠀⠀⠄⢀⠀⠀⠀⠈⠀⠀⠀⠁⠄⠀⠀⠀⠀ | ||
⠀⢐⠐⠀⠄⠀⡂⠀⢐⠀⠀⠀⠀⠂⢀⢀⠐⠂⡀⠈⠀⠀⠀⠂⠀⠈⠀⡀⡐⠀⢄⠀⢀⠀⡆⠀⡀⣀⡀⡐ | ||
⠀⠈⠀⠀⠀⠀⠀⠐⢂⠀⢀⠀⠈⠀⠀⠀⠀⠀⠠⠀⠀⠠⠀⠀⠀⠈⠂⠀⠀⠀⠄⠐⠐⠀⠁⠀⠀⠑⠁⠀ | ||
⠂⠠⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠠⠈⠀⠀⠀⠀⠀⠁⠀⠀⠠⠐⠀⠁⠈⠀⠁⢀⠀⠀⠀⠀⠀⠀⠀⠀⠌⠀ | ||
⠀⠀⠂⢨⠀⡀⠀⠐⠁⠐⠀⠐⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠢⠒⠈⠐⠐⠁⠂⠀⠀⠀⠄⠓⠕⠂⠃⠁⠀⠐ | ||
⠠⠀⠨⠀⠁⠤⠄⠀⠁⡄⠀⠂⠠⠄⢈⠌⠠⠄⠀⢀⠀⠀⠀⠄⠨⠀⡤⠀⢀⠀⢀⠠⠀⠁⡔⠨⠀⠈⠄⠀ | ||
⠀⢀⢀⣀⠀⡠⡒⢀⢀⣀⠀⢀⣀⡀⢀⠀⢀⠀⡀⠀⡀⠀⠈⣀⠀⢀⣀⠀⡀⠀⢀⠁⢀⣀⣀⡀⡠⡀⡀⣀ | ||
⠀⠄⠀⠀⠀⠀⠀⠀⠀⠂⠁⠀⠀⠀⠀⠀⠀⣠⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀ | ||
⢀⠂⠀⠀⠂⠀⠈⠀⠐⠀⠀⠀⠁⠀⠀⠀⡀⠔⠑⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠢⠀⠀⡀⠂⠈⠀⠀⠀⠄ | ||
⠀⠐⠀⠀⡂⠀⠂⠀⠀⠀⠒⠐⠄⠂⠐⠀⠘⡀⠀⠠⡂⠃⠀⠂⠄⠂⠀⠀⠀⠀⡀⠀⡀⠀⡂⠂⠀⠀⢀⠀ | ||
Number of reactions: 95 | ||
Number of metabolites: 72 | ||
%% Cell type:markdown id: tags: | ||
You can directly inspect the model objects, although only with a specific way | ||
for each specific type. | ||
%% Cell type:markdown id: tags: | ||
JSON models contain their corresponding JSON: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
json_model.json | ||
``` | ||
%% Output | ||
Dict{String, Any} with 6 entries: | ||
"metabolites" => Any[Dict{String, Any}("compartment"=>"e", "name"=>"D-Glucos… | ||
"id" => "e_coli_core" | ||
"compartments" => Dict{String, Any}("c"=>"cytosol", "e"=>"extracellular space… | ||
"reactions" => Any[Dict{String, Any}("name"=>"Phosphofructokinase", "metab… | ||
"version" => "1" | ||
"genes" => Any[Dict{String, Any}("name"=>"adhE", "id"=>"b1241", "notes… | ||
%% Cell type:markdown id: tags: | ||
SBML models contain a complicated structure from [`SBML.jl` | ||
package](https://github.com/LCSB-BioCore/SBML.jl): | ||
%% Cell type:code id: tags: | ||
``` julia | ||
typeof(sbml_model.sbml) | ||
``` | ||
%% Output | ||
SBML.Model | ||
%% Cell type:markdown id: tags: | ||
MAT models contain MATLAB data: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
mat_model.mat | ||
``` | ||
%% Output | ||
Dict{String, Any} with 17 entries: | ||
"description" => "e_coli_core" | ||
"c" => [0.0; 0.0; … ; 0.0; 0.0] | ||
"rev" => [0; 0; … ; 1; 0] | ||
"mets" => Any["glc__D_e"; "gln__L_c"; … ; "g3p_c"; "g6p_c"] | ||
"grRules" => Any["b3916 or b1723"; "((b0902 and b0903) and b2579) or (b09… | ||
"subSystems" => Any["Glycolysis/Gluconeogenesis"; "Pyruvate Metabolism"; … ;… | ||
"b" => [0.0; 0.0; … ; 0.0; 0.0] | ||
"metFormulas" => Any["C6H12O6"; "C5H10N2O3"; … ; "C3H5O6P"; "C6H11O9P"] | ||
"rxnGeneMat" => … | ||
"S" => [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0… | ||
"metNames" => Any["D-Glucose"; "L-Glutamine"; … ; "Glyceraldehyde 3-phosph… | ||
"lb" => [0.0; 0.0; … ; -1000.0; 0.0] | ||
"metCharge" => [0.0; 0.0; … ; -2.0; -2.0] | ||
"ub" => [1000.0; 1000.0; … ; 1000.0; 1000.0] | ||
"rxnNames" => Any["Phosphofructokinase"; "Pyruvate formate lyase"; … ; "O2… | ||
"rxns" => Any["PFK"; "PFL"; … ; "O2t"; "PDH"] | ||
"genes" => Any["b1241"; "b0351"; … ; "b2935"; "b3919"] | ||
%% Cell type:markdown id: tags: | ||
## Using the generic interface to access model details | ||
%% Cell type:markdown id: tags: | ||
To prevent the complexities of object representation, `COBREXA.jl` uses a set | ||
of generic interface functions that extract various important information | ||
from all supported model types. This approach ensures that the analysis | ||
functions can work on any data. | ||
%% Cell type:markdown id: tags: | ||
For example, you can check the reactions and metabolites contained in SBML | ||
and JSON models using the same accessor: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
reactions(json_model) | ||
``` | ||
%% Output | ||
95-element Vector{String}: | ||
"PFK" | ||
"PFL" | ||
"PGI" | ||
"PGK" | ||
"PGL" | ||
"ACALD" | ||
"AKGt2r" | ||
"PGM" | ||
"PIt2r" | ||
"ALCD2x" | ||
⋮ | ||
"MALt2_2" | ||
"MDH" | ||
"ME1" | ||
"ME2" | ||
"NADH16" | ||
"NADTRHD" | ||
"NH4t" | ||
"O2t" | ||
"PDH" | ||
%% Cell type:code id: tags: | ||
``` julia | ||
reactions(sbml_model) | ||
``` | ||
%% Output | ||
95-element Vector{String}: | ||
"R_EX_fum_e" | ||
"R_ACONTb" | ||
"R_TPI" | ||
"R_SUCOAS" | ||
"R_GLNS" | ||
"R_EX_pi_e" | ||
"R_PPC" | ||
"R_O2t" | ||
"R_G6PDH2r" | ||
"R_TALA" | ||
⋮ | ||
"R_THD2" | ||
"R_EX_h2o_e" | ||
"R_GLUSy" | ||
"R_ME1" | ||
"R_GLUN" | ||
"R_EX_o2_e" | ||
"R_FRUpts2" | ||
"R_ALCD2x" | ||
"R_PIt2r" | ||
%% Cell type:code id: tags: | ||
``` julia | ||
issetequal(reactions(json_model), reactions(mat_model)) # do models contain the same reactions? | ||
``` | ||
%% Output | ||
true | ||
%% Cell type:markdown id: tags: | ||
All accessors are defined in a single file in COBREXA source code; you may | ||
therefore get a list of all accessors as follows: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
using InteractiveUtils | ||
for method in filter( | ||
x -> endswith(string(x.file), "MetabolicModel.jl"), | ||
InteractiveUtils.methodswith(MetabolicModel, COBREXA), | ||
) | ||
println(method.name) | ||
end | ||
``` | ||
%% Output | ||
balance | ||
bounds | ||
coupling | ||
coupling_bounds | ||
gene_annotations | ||
gene_notes | ||
genes | ||
metabolite_annotations | ||
metabolite_charge | ||
metabolite_compartment | ||
metabolite_formula | ||
metabolite_notes | ||
metabolites | ||
n_coupling_constraints | ||
n_genes | ||
n_metabolites | ||
n_reactions | ||
objective | ||
precache! | ||
reaction_annotations | ||
reaction_gene_association | ||
reaction_notes | ||
reaction_stoichiometry | ||
reaction_subsystem | ||
reactions | ||
stoichiometry | ||
%% Cell type:markdown id: tags: | ||
## Converting between model types | ||
%% Cell type:markdown id: tags: | ||
It is possible to convert model types to-and-fro. To do this, use the | ||
`convert` function, which is overloaded from Julia's `Base`. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
m = convert(MATModel, json_model) | ||
``` | ||
%% Output | ||
Metabolic model of type MATModel | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀ | ||
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀ | ||
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀ | ||
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘ | ||
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄ | ||
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁ | ||
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀ | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀ | ||
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀ | ||
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈ | ||
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀ | ||
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀ | ||
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈ | ||
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
Number of reactions: 95 | ||
Number of metabolites: 72 | ||
%% Cell type:markdown id: tags: | ||
`m` will now contain the MATLAB-style matrix representation of the model: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
Matrix(m.mat["S"]) | ||
``` | ||
%% Output | ||
72×95 Matrix{Float64}: | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
1.0 0.0 0.0 0.0 1.0 1.0 1.0 0.0 0.0 -4.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 3.0 0.0 0.0 0.0 0.0 | ||
⋮ ⋮ ⋱ ⋮ | ||
-1.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 1.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
0.0 0.0 -1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 | ||
%% Cell type:markdown id: tags: | ||
The loading and conversion can be combined using a shortcut: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
m = load_model(MATModel, "e_coli_core.json") | ||
``` | ||
%% Output | ||
Metabolic model of type MATModel | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀ | ||
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀ | ||
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀ | ||
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘ | ||
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄ | ||
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁ | ||
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀ | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀ | ||
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀ | ||
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈ | ||
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀ | ||
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀ | ||
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈ | ||
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
Number of reactions: 95 | ||
Number of metabolites: 72 | ||
%% Cell type:markdown id: tags: | ||
## Saving and exporting models | ||
%% Cell type:markdown id: tags: | ||
`COBREXA.jl` supports exporting the models in JSON and MAT format, using `save_model`. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
save_model(m, "converted_model.json") | ||
save_model(m, "converted_model.mat") | ||
``` | ||
%% Cell type:markdown id: tags: | ||
If you need a non-standard suffix, use the type-specific saving functions: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
save_json_model(m, "file.without.a.good.suffix") | ||
save_mat_model(m, "another.file.matlab") | ||
``` | ||
%% Cell type:markdown id: tags: | ||
If you are saving the models only for future processing in Julia environment, | ||
it is often wasteful to encode the models to external formats and decode them | ||
back. Instead, you can use the "native" Julia data format, accessible with | ||
package `Serialization`. | ||
This way, you can use `serialize` to save even the `StandardModel` | ||
that has no file format associated: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
using Serialization | ||
sm = convert(StandardModel, m) | ||
open(f -> serialize(f, sm), "myModel.stdmodel", "w") | ||
``` | ||
%% Cell type:markdown id: tags: | ||
The models can then be loaded back using `deserialize`: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
sm2 = deserialize("myModel.stdmodel") | ||
issetequal(metabolites(sm), metabolites(sm2)) | ||
``` | ||
%% Output | ||
true | ||
%% Cell type:markdown id: tags: | ||
This form of loading operation is usually pretty quick: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
t = @elapsed deserialize("myModel.stdmodel") | ||
@info "Deserialization took $t seconds" | ||
``` | ||
%% Output | ||
┌ Info: Deserialization took 0.002031277 seconds | ||
┌ Info: Deserialization took 0.002527651 seconds | ||
└ @ Main.##258 string:2 | ||
%% Cell type:markdown id: tags: | ||
Notably, large and complicated models with thousands of reactions and | ||
annotations can take seconds to decode properly. Serialization allows you to | ||
almost completely remove this overhead, and scales well to tens of millions | ||
of reactions. | ||
%% Cell type:markdown id: tags: | ||
--- | ||
*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* |
This diff is collapsed.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
%% Cell type:markdown id: tags: | ||
# Basic usage of `StandardModel` | ||
%% Cell type:markdown id: tags: | ||
In this tutorial we will use `COBREXA`'s `StandardModel` and functions that | ||
specifically operate on it. As usual we will use the toy model of *E. coli* | ||
for demonstration. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
!isfile("e_coli_core.json") && | ||
download("http://bigg.ucsd.edu/static/models/e_coli_core.json", "e_coli_core.json") | ||
using COBREXA | ||
``` | ||
%% Cell type:markdown id: tags: | ||
## Loading a model | ||
%% Cell type:code id: tags: | ||
``` julia | ||
model = load_model(StandardModel, "e_coli_core.json") # we specifically want to load a StandardModel from the model file | ||
``` | ||
%% Output | ||
Metabolic model of type StandardModel | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀ | ||
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀ | ||
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀ | ||
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘ | ||
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄ | ||
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁ | ||
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀ | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀ | ||
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀ | ||
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈ | ||
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀ | ||
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀ | ||
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈ | ||
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
Number of reactions: 95 | ||
Number of metabolites: 72 | ||
%% Cell type:markdown id: tags: | ||
When using `load_model(StandardModel, file_location)` the model at | ||
`file_location` is first loaded into its inferred format and is then | ||
converted to a `StandardModel` using the generic accessor interface. | ||
Thus, data loss may occur. Always check your model to ensure that | ||
nothing important has been lost. | ||
%% Cell type:markdown id: tags: | ||
## Basic analysis | ||
%% Cell type:markdown id: tags: | ||
As before, for optimization based analysis we need to load an optimizer. Here we | ||
will use [`Tulip.jl`](https://github.com/ds4dm/Tulip.jl) to solve the linear | ||
programs of this tutorial. Refer to the basic constraint-based analysis | ||
tutorial for more informaiton. | ||
%% Cell type:markdown id: tags: | ||
All the normal analysis functions work on `StandardModel`, due to it also | ||
having the same generic accessor interface as all the other model types. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
using Tulip | ||
fluxes = flux_balance_analysis_dict( | ||
model, | ||
Tulip.Optimizer; | ||
modifications = [ | ||
change_objective("BIOMASS_Ecoli_core_w_GAM"), | ||
change_constraint("EX_glc__D_e"; lb = -12, ub = -12), | ||
change_constraint("EX_o2_e"; lb = 0, ub = 0), | ||
], | ||
) | ||
``` | ||
%% Output | ||
Dict{String, Float64} with 95 entries: | ||
"ACALD" => -9.78427 | ||
"PTAr" => 10.0729 | ||
"ALCD2x" => -9.78427 | ||
"PDH" => 1.98381e-9 | ||
"PYK" => 9.94501 | ||
"CO2t" => 0.487021 | ||
"EX_nh4_e" => -1.48633 | ||
"MALt2_2" => -0.0 | ||
"CS" => 0.294088 | ||
"PGM" => -22.8676 | ||
"TKT1" => -0.0487648 | ||
"EX_mal__L_e" => -0.0 | ||
"ACONTa" => 0.294088 | ||
"EX_pi_e" => -1.00274 | ||
"GLNS" => 0.069699 | ||
"ICL" => 5.34932e-11 | ||
"EX_o2_e" => -0.0 | ||
"FBA" => 11.7289 | ||
"EX_gln__L_e" => -0.0 | ||
⋮ => ⋮ | ||
%% Cell type:markdown id: tags: | ||
This is not very exciting yet, since every other model type can also do this. | ||
However, deeper inspection of flux results is possible when using | ||
`StandardModel`. | ||
%% Cell type:markdown id: tags: | ||
## Inspecting the flux solution: `atom_fluxes` | ||
%% Cell type:markdown id: tags: | ||
It is sometimes interesting to keep track of the atoms entering and leaving | ||
the system through boundary reactions. This can be inspected by calling | ||
`atom_fluxes`. That gives you the flux of individual atoms getting | ||
consumed and produced by all reactions, based on `fluxes`. We erase the | ||
reaction that consumes the atoms for creating biomass, to see how much mass | ||
the "rest" of the reaction produces for it: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
fluxes_without_biomass = copy(fluxes); | ||
delete!(fluxes_without_biomass, "BIOMASS_Ecoli_core_w_GAM"); | ||
atom_fluxes(model, fluxes_without_biomass) | ||
``` | ||
%% Output | ||
Dict{String, Float64} with 6 entries: | ||
"S" => 0.0 | ||
"C" => 11.5998 | ||
"N" => 1.48633 | ||
"P" => 1.00274 | ||
"H" => 20.7086 | ||
"O" => 12.995 | ||
%% Cell type:markdown id: tags: | ||
## Inspecting the flux solution: `metabolite_fluxes` | ||
%% Cell type:markdown id: tags: | ||
Another useful flux result analysis function is `metabolite_fluxes`. | ||
This function gives an overview of reactions consuming and producing each | ||
metabolite. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
consuming, producing = metabolite_fluxes(model, fluxes) | ||
consuming["atp_c"] # reactions consuming `atp_c` | ||
``` | ||
%% Output | ||
Dict{String, Float64} with 8 entries: | ||
"PFK" => -11.7289 | ||
"BIOMASS_Ecoli_core_w_GAM" => -16.3031 | ||
"GLNS" => -0.069699 | ||
"ATPM" => -8.39 | ||
"ADK1" => -1.66663e-10 | ||
"PPCK" => -5.66231e-11 | ||
"PPS" => -1.66662e-10 | ||
"ATPS4r" => -6.80168 | ||
%% Cell type:markdown id: tags: | ||
## Internals of `StandardModel` | ||
%% Cell type:markdown id: tags: | ||
Another benefit of `StandardModel` is that it supports a richer internal | ||
infrastructure that can be used to manipulate internal model attributes in a | ||
systematic way. Specifically, the genes, reactions, and metabolites with of a | ||
model each have a type. This is particularly useful when modifying or even | ||
constructing a model from scratch. | ||
%% Cell type:markdown id: tags: | ||
## `Gene`s, `Reaction`s, and `Metabolite`s | ||
%% Cell type:markdown id: tags: | ||
`StandardModel` is composed of ordered dictionaries of `Gene`s, `Metabolite`s | ||
and `Reaction`s. Ordered dictionaries are used because the order of the | ||
reactions and metabolites are important for constructing a stoichiometric | ||
matrix since the rows and columns should correspond to the order of the metabolites | ||
and reactions returned by calling the accessors `metabolites` and `reactions`. | ||
%% Cell type:markdown id: tags: | ||
Each `StandardModel` is composed of the following fields: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
fieldnames(StandardModel) # fields of a StandardModel | ||
``` | ||
%% Output | ||
(:id, :reactions, :metabolites, :genes) | ||
%% Cell type:markdown id: tags: | ||
The `:genes` field of a `StandardModel` contains an ordered dictionary of gene ids mapped to `Gene`s. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
model.genes # the keys of this dictionary are the same as genes(model) | ||
``` | ||
%% Output | ||
OrderedCollections.OrderedDict{String, Gene} with 137 entries: | ||
"b1241" => Gene("b1241", Dict("original_bigg_ids"=>["b1241"]), Dict("sbo"=>["… | ||
"b0351" => Gene("b0351", Dict("original_bigg_ids"=>["b0351"]), Dict("sbo"=>["… | ||
"s0001" => Gene("s0001", Dict("original_bigg_ids"=>["s0001"]), Dict("sbo"=>["… | ||
"b1849" => Gene("b1849", Dict("original_bigg_ids"=>["b1849"]), Dict("sbo"=>["… | ||
"b3115" => Gene("b3115", Dict("original_bigg_ids"=>["b3115"]), Dict("sbo"=>["… | ||
"b2296" => Gene("b2296", Dict("original_bigg_ids"=>["b2296"]), Dict("sbo"=>["… | ||
"b1276" => Gene("b1276", Dict("original_bigg_ids"=>["b1276"]), Dict("sbo"=>["… | ||
"b0118" => Gene("b0118", Dict("original_bigg_ids"=>["b0118"]), Dict("sbo"=>["… | ||
"b0474" => Gene("b0474", Dict("original_bigg_ids"=>["b0474"]), Dict("sbo"=>["… | ||
"b0116" => Gene("b0116", Dict("original_bigg_ids"=>["b0116"]), Dict("sbo"=>["… | ||
"b0727" => Gene("b0727", Dict("original_bigg_ids"=>["b0727"]), Dict("sbo"=>["… | ||
"b0726" => Gene("b0726", Dict("original_bigg_ids"=>["b0726"]), Dict("sbo"=>["… | ||
"b2587" => Gene("b2587", Dict("original_bigg_ids"=>["b2587"]), Dict("sbo"=>["… | ||
"b0356" => Gene("b0356", Dict("original_bigg_ids"=>["b0356"]), Dict("sbo"=>["… | ||
"b1478" => Gene("b1478", Dict("original_bigg_ids"=>["b1478"]), Dict("sbo"=>["… | ||
"b3734" => Gene("b3734", Dict("original_bigg_ids"=>["b3734"]), Dict("sbo"=>["… | ||
"b3733" => Gene("b3733", Dict("original_bigg_ids"=>["b3733"]), Dict("sbo"=>["… | ||
"b3736" => Gene("b3736", Dict("original_bigg_ids"=>["b3736"]), Dict("sbo"=>["… | ||
"b3737" => Gene("b3737", Dict("original_bigg_ids"=>["b3737"]), Dict("sbo"=>["… | ||
⋮ => ⋮ | ||
%% Cell type:markdown id: tags: | ||
The `Gene` type is a struct that can be used to store information about genes | ||
in a `StandardModel`. Each `Gene` is composed of the following fields: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
fieldnames(Gene) | ||
``` | ||
%% Output | ||
(:id, :notes, :annotations) | ||
%% Cell type:markdown id: tags: | ||
Use <tab> to quickly explore the fields of a struct. For example, | ||
Gene.<tab> will list all the fields shown above. | ||
%% Cell type:markdown id: tags: | ||
The keys used in the ordered dictionaries in | ||
`model.genes` are the ids returned using the generic accessor `genes`. `Gene`s | ||
have pretty printing, as demonstrated below for a random gene drawn from the | ||
model: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
random_gene_id = genes(model)[rand(1:n_genes(model))] | ||
model.genes[random_gene_id] | ||
``` | ||
%% Output | ||
Gene.id: b1852 | ||
Gene.id: b4151 | ||
Gene.notes: | ||
original_bigg_ids: ["b1852"] | ||
original_bigg_ids: ["b4151"] | ||
Gene.annotations: | ||
sbo: ["SBO:0000243"] | ||
uniprot: ["P0AC53"] | ||
ecogene: ["EG11221"] | ||
ncbigene: ["946370"] | ||
ncbigi: ["16129805"] | ||
refseq_locus_tag: ["b1852"] | ||
refseq_name: ["zwf"] | ||
asap: ["ABE-0006171"] | ||
refseq_synonym: ["JW1841", "ECK1853"] | ||
uniprot: ["P0A8Q3"] | ||
ecogene: ["EG10333"] | ||
ncbigene: ["948668"] | ||
ncbigi: ["16131976"] | ||
refseq_locus_tag: ["b4151"] | ||
refseq_name: ["frdD"] | ||
asap: ["ABE-0013595"] | ||
refseq_synonym: ["JW4112", "ECK4147"] | ||
%% Cell type:markdown id: tags: | ||
The same idea holds for both metabolites (stored as `Metabolite`s) and | ||
reactions (stored as `Reaction`s). This is demonstrated below. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
random_metabolite_id = metabolites(model)[rand(1:n_metabolites(model))] | ||
model.metabolites[random_metabolite_id] | ||
``` | ||
%% Output | ||
Metabolite.id: h2o_c | ||
Metabolite.formula: H2O1 | ||
Metabolite.charge: 0 | ||
Metabolite.id: mal__L_c | ||
Metabolite.formula: C4H4O5 | ||
Metabolite.charge: -2 | ||
Metabolite.compartment: c | ||
Metabolite.notes: | ||
original_bigg_ids: ["h2o_c"] | ||
original_bigg_ids: ["mal_L_c"] | ||
Metabolite.annotations: | ||
envipath: 650babc9-9d68-4b73-9... | ||
kegg.drug: ["D00001", "D06322"] | ||
kegg.compound: ["C00001", "C01328"] | ||
sabiork: ["1918"] | ||
kegg.compound: ["C00149"] | ||
sbo: ["SBO:0000247"] | ||
sabiork: ["40"] | ||
biocyc: META:CPD-15815, ..., META:OH | ||
chebi: CHEBI:13352, ..., CHEBI:44701 | ||
metanetx.chemical: ["MNXM2"] | ||
inchi_key: XLYOFNOQVPJJNP-UHFFF... | ||
hmdb: ["HMDB02111", "HMDB01039"] | ||
bigg.metabolite: ["h2o"] | ||
seed.compound: cpd27222, ..., cpd15275 | ||
reactome.compound: 113521, ..., 351603 | ||
biocyc: ["META:MAL"] | ||
chebi: CHEBI:15589, ..., CHEBI:11066 | ||
metanetx.chemical: ["MNXM98"] | ||
inchi_key: BJEPYKJPYRNKOW-REOHC... | ||
hmdb: ["HMDB00156"] | ||
bigg.metabolite: ["mal__L"] | ||
seed.compound: ["cpd00130"] | ||
reactome.compound: ["198498", "113544"] | ||
%% Cell type:code id: tags: | ||
``` julia | ||
random_reaction_id = reactions(model)[rand(1:n_reactions(model))] | ||
model.reactions[random_reaction_id] | ||
``` | ||
%% Output | ||
Reaction.id: ATPM | ||
Reaction.metabolites: 1.0 h2o_c + 1.0 atp_c → 1.0 adp_c + 1.0 pi_c + 1.0 h_c | ||
Reaction.lb: 8.39 | ||
Reaction.id: GAPD | ||
Reaction.metabolites: 1.0 nad_c + 1.0 g3p_c + 1.0 pi_c ↔ 1.0 13dpg_c + 1.0 h_c + 1.0 nadh_c | ||
Reaction.lb: -1000.0 | ||
Reaction.ub: 1000.0 | ||
Reaction.grr: --- | ||
Reaction.subsystem: Biomass and maintenance functions | ||
Reaction.grr: (b1779) | ||
Reaction.subsystem: Glycolysis/Gluconeogenesis | ||
Reaction.notes: | ||
original_bigg_ids: ["ATPM"] | ||
original_bigg_ids: ["GAPD"] | ||
Reaction.annotations: | ||
bigg.reaction: ["ATPM"] | ||
sabiork: ["75"] | ||
metanetx.reaction: ["MNXR96131"] | ||
rhea: 13066, ..., 13067 | ||
bigg.reaction: ["GAPD"] | ||
sabiork: ["7844"] | ||
metanetx.reaction: ["MNXR100040"] | ||
rhea: 10303, ..., 10301 | ||
sbo: ["SBO:0000176"] | ||
seed.reaction: rxn11300, ..., rxn00062 | ||
kegg.reaction: ["R00086"] | ||
biocyc: ["META:ATPASE-RXN"] | ||
ec-code: 3.6.1.5, ..., 3.6.3.49 | ||
seed.reaction: ["rxn00781"] | ||
kegg.reaction: ["R01061"] | ||
biocyc: META:GAPOXNPHOSPHN-R... | ||
reactome.reaction: R-ATH-70482, ..., R-BTA-70482 | ||
ec-code: ["1.2.1.12", "1.2.1.59"] | ||
Reaction.objective_coefficient: 0.0 | ||
%% Cell type:markdown id: tags: | ||
`StandardModel` can be used to build your own metabolic model or modify an | ||
existing one. One of the main use cases for `StandardModel` is that it can be | ||
used to merge multiple models or parts of multiple models together. Since the | ||
internals are uniform inside each `StandardModel`, attributes of other model | ||
types are squashed into the required format (using the generic accessors). | ||
This ensures that the internals of all `StandardModel`s are the same - | ||
allowing easy systematic evaluation. | ||
%% Cell type:markdown id: tags: | ||
## Checking the internals of `StandardModel`s: `annotation_index` | ||
%% Cell type:markdown id: tags: | ||
Often when models are automatically reconstructed duplicate genes, reactions | ||
or metabolites end up in a model. `COBREXA` exports `annotation_index` to | ||
check for cases where the id of a struct may be different, but the annotations | ||
the same (possibly suggesting a duplication). `annotation_index` builds a | ||
dictionary mapping annotation features to the ids of whatever struct you are | ||
inspecting. This makes it easy to find structs that share certain annotation features. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
rxn_annotations = annotation_index(model.reactions) | ||
``` | ||
%% Output | ||
Dict{String, Dict{String, Set{String}}} with 10 entries: | ||
"ec-code" => Dict("3.6.3.37"=>Set(["ATPM"]), "3.6.3.42"=>Set(["ATPM… | ||
"sabiork" => Dict("109"=>Set(["PGL"]), "762"=>Set(["GLUN"]), "155"=… | ||
"metanetx.reaction" => Dict("MNXR104869"=>Set(["TKT2"]), "MNXR99715"=>Set(["E… | ||
"rhea" => Dict("27626"=>Set(["TKT2"]), "10229"=>Set(["ACONTa"]),… | ||
"sbo" => Dict("SBO:0000627"=>Set(["EX_for_e", "EX_nh4_e", "EX_p… | ||
"seed.reaction" => Dict("rxn05297"=>Set(["GLUt2r"]), "rxn09717"=>Set(["PY… | ||
"kegg.reaction" => Dict("R00114"=>Set(["GLUSy"]), "R00199"=>Set(["PPS"]),… | ||
"biocyc" => Dict("META:TRANS-RXN-121B"=>Set(["FUMt2_2"]), "META:PE… | ||
"reactome.reaction" => Dict("R-TGU-71397"=>Set(["PDH"]), "R-XTR-70449"=>Set([… | ||
"bigg.reaction" => Dict("ACALD"=>Set(["ACALD"]), "PTAr"=>Set(["PTAr"]), "… | ||
%% Cell type:code id: tags: | ||
``` julia | ||
rxn_annotations["ec-code"] | ||
``` | ||
%% Output | ||
Dict{String, Set{String}} with 141 entries: | ||
"3.6.3.37" => Set(["ATPM"]) | ||
"3.6.3.42" => Set(["ATPM"]) | ||
"3.6.3.38" => Set(["ATPM"]) | ||
"3.6.3.19" => Set(["ATPM"]) | ||
"2.3.3.1" => Set(["CS"]) | ||
"1.6.1.2" => Set(["NADTRHD"]) | ||
"3.6.3.35" => Set(["ATPM"]) | ||
"6.2.1.5" => Set(["SUCOAS"]) | ||
"6.3.5.4" => Set(["GLUN"]) | ||
"3.6.3.49" => Set(["ATPM"]) | ||
"3.6.3.51" => Set(["ATPM"]) | ||
"1.2.1.12" => Set(["GAPD"]) | ||
"3.6.3.32" => Set(["ATPM"]) | ||
"2.3.3.3" => Set(["CS"]) | ||
"2.7.4.3" => Set(["ADK1"]) | ||
"6.3.5.5" => Set(["GLUN"]) | ||
"3.5.1.2" => Set(["GLUN"]) | ||
"1.1.1.49" => Set(["G6PDH2r"]) | ||
"5.3.1.9" => Set(["PGI"]) | ||
⋮ => ⋮ | ||
%% Cell type:markdown id: tags: | ||
The `annotation_index` function can also be used on `Reaction`s and | ||
`Gene`s in the same way. | ||
%% Cell type:markdown id: tags: | ||
## Checking the internals of `StandardModel`s: `check_duplicate_reaction` | ||
%% Cell type:markdown id: tags: | ||
Another useful function is `check_duplicate_reaction`, which checks for | ||
reactions that have duplicate (or similar) reaction equations. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
pgm_duplicate = Reaction() | ||
pgm_duplicate.id = "pgm2" # Phosphoglycerate mutase | ||
pgm_duplicate.metabolites = Dict{String,Float64}("3pg_c" => 1, "2pg_c" => -1) | ||
pgm_duplicate | ||
``` | ||
%% Output | ||
Reaction.id: pgm2 | ||
Reaction.metabolites: 1.0 2pg_c ↔ 1.0 3pg_c | ||
Reaction.lb: -1000.0 | ||
Reaction.ub: 1000.0 | ||
Reaction.grr: --- | ||
Reaction.subsystem: --- | ||
Reaction.notes: --- | ||
Reaction.annotations: --- | ||
Reaction.objective_coefficient: 0.0 | ||
%% Cell type:code id: tags: | ||
``` julia | ||
check_duplicate_reaction(pgm_duplicate, model.reactions; only_metabolites = false) # can also just check if only the metabolites are the same but different stoichiometry is used | ||
``` | ||
%% Output | ||
"PGM" | ||
%% Cell type:markdown id: tags: | ||
## Checking the internals of `StandardModel`s: `reaction_mass_balanced` | ||
%% Cell type:markdown id: tags: | ||
Finally, `reaction_mass_balanced` can be used to check if a reaction is mass | ||
balanced based on the formulas of the reaction equation. | ||
%% Cell type:code id: tags: | ||
``` julia | ||
rxn_dict = Dict{String,Float64}("3pg_c" => 1, "2pg_c" => -1, "h2o_c" => 1) | ||
reaction_mass_balanced(model, rxn_dict) | ||
``` | ||
%% Output | ||
false | ||
%% Cell type:markdown id: tags: | ||
Now to determine which atoms are unbalanced, you can use `reaction_atom_balance` | ||
%% Cell type:code id: tags: | ||
``` julia | ||
reaction_atom_balance(model, rxn_dict) | ||
``` | ||
%% Output | ||
Dict{String, Float64} with 4 entries: | ||
"C" => 0.0 | ||
"P" => 0.0 | ||
"H" => 2.0 | ||
"O" => 1.0 | ||
%% Cell type:markdown id: tags: | ||
Note, since `pgm_duplicate` is not in the model, we cannot use the other variants of this | ||
function because they find the reaction equation stored inside the `model`. | ||
%% Cell type:markdown id: tags: | ||
--- | ||
*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* |
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
%% Cell type:markdown id: tags: | ||
# Exploring model variants with `screen` | ||
%% Cell type:markdown id: tags: | ||
This notebooks demonstrates a simple use of `screen` to explore large | ||
number of model variants. On the toy *E. Coli* model, we try to map the | ||
impact of knocking out single reactions and 2-reaction combinations. | ||
%% Cell type:markdown id: tags: | ||
First, let's download the data and load the packages and the model | ||
%% Cell type:code id: tags: | ||
``` julia | ||
!isfile("e_coli_core.json") && | ||
download("http://bigg.ucsd.edu/static/models/e_coli_core.json", "e_coli_core.json"); | ||
using COBREXA, Tulip | ||
model = load_model(StandardModel, "e_coli_core.json") | ||
``` | ||
%% Output | ||
Metabolic model of type StandardModel | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢄⠀⠀⠀⠀⠀⠀⠀⠈⠶⠴⡆⠀⠀⠀⠀⠀⠀ | ||
⡀⢐⣀⢀⡀⡒⢒⣐⠀⣂⣂⠀⣂⣂⢂⠀⢀⠀⠀⠀⠀⠀⢀⠄⠀⠀⠀⢂⠀⢂⣀⣐⡒⡀⠆⢙⣀⠀⡀⠀ | ||
⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠈⢑⣀⣀⠀⠀ | ||
⠀⠀⠃⠀⠃⠀⠀⠀⠘⠀⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⡜⠀⡄⣤⢠⠘⠙⢣⡇⠘ | ||
⠀⠐⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠐⠁⠉⠀⠀⠀⠀⠀⠘⠄ | ||
⠀⢐⠀⠂⠀⠄⠠⠠⠀⠠⠆⠀⠄⠀⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠠⠀⠠⠀⠀⢀⠀⠀⠠⠀⠀⠁ | ||
⢀⠐⠀⠨⢀⠁⠈⣈⠀⢁⣁⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⠀⠁⢀⠀⢊⠉⠀⠀⠀⢀⠀⣀⠀⢀ | ||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠀⡀⠆⠀⠆⠀⡀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠆⠀ | ||
⠀⠀⠂⠀⡂⠀⠀⠁⠀⠀⠀⠈⠁⠀⠀⠀⠄⠄⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀ | ||
⠈⠀⠁⠀⠀⢀⡀⠀⠠⠁⠁⠀⠑⠀⠐⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠂⠀⠀⠀⠀⠀⠀⠊⠀⠀⠀⠈ | ||
⠄⠠⢠⠀⠰⠀⠠⠀⠤⠦⠄⠈⠀⠀⠀⠠⠀⠁⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠄⠠⠀⠀⠀⠀⠀ | ||
⠂⠐⠀⠀⠐⡠⢐⠘⢃⠒⠂⡀⠄⠀⠀⠐⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠒⠀⢀⢀⠀⠀⣀⠀⢀ | ||
⠈⠀⠁⠀⡀⠀⠀⠀⠈⠁⠅⠀⠁⠀⢀⠈⠄⠔⠀⠀⠀⠀⠀⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠈ | ||
⠣⠁⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⠀⠁⠁⠀⠈⡀⠀⠀⠀⠀⠀⠐⢣⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠂⠄⠤⠀⠀⠈⠂⠀⠀⠀⠀⠠⠀⠊⠒⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀ | ||
Number of reactions: 95 | ||
Number of metabolites: 72 | ||
%% Cell type:markdown id: tags: | ||
## Preparing the functions | ||
While we could use the `with_changed_bound` to limit the reaction rates, | ||
but we will make a slightly more precise, usage-tailored modification. This | ||
is a straightforward modification of the `with_changed_bound` that does | ||
not set bounds "outside" of the original bounds: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
with_limited_rate(reaction_id::String, limit) = | ||
model::StandardModel -> begin | ||
m = copy(model) | ||
m.reactions = copy(model.reactions) | ||
r = m.reactions[reaction_id] = copy(model.reactions[reaction_id]) | ||
if -limit > r.lb | ||
r.lb = -limit | ||
end | ||
if limit < r.ub | ||
r.ub = limit | ||
end | ||
m | ||
end | ||
``` | ||
%% Output | ||
with_limited_rate (generic function with 1 method) | ||
%% Cell type:markdown id: tags: | ||
## Knocking out single reactions | ||
This can be applied to see how much biomass can the model produce with | ||
certain reactions limited to almost zero: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
get_biomass(x) = isnothing(x) ? 0 : x["BIOMASS_Ecoli_core_w_GAM"] | ||
productions = screen_variants( | ||
model, | ||
[[with_limited_rate(rxn, 0.1)] for rxn in reactions(model)], | ||
model -> get_biomass(flux_balance_analysis_dict(model, Tulip.Optimizer)), | ||
) | ||
``` | ||
%% Output | ||
95-element Vector{Real}: | ||
0.7110773172306842 | ||
0.8739215069620168 | ||
0.8633809523181394 | ||
0.007974352115966855 | ||
0.8640171040038155 | ||
0.8739215063456838 | ||
0.87392150695555 | ||
0.009054524481803774 | ||
0.027183515911490083 | ||
0.8739215069216937 | ||
⋮ | ||
0.8739215022678488 | ||
0.8270283079105472 | ||
0.8739215065011818 | ||
0.8739215045533449 | ||
0.2134628028114079 | ||
0.8739215053667706 | ||
0.018339201041498398 | ||
0.21526265974680137 | ||
0.7975549891965422 | ||
%% Cell type:markdown id: tags: | ||
This can be nicely plotted to give a more comprehensive overview of which | ||
reactions are critical or not: | ||
%% Cell type:code id: tags: | ||
``` julia | ||
using CairoMakie | ||
disp_rxns = rand(1:95, 20) # only display 20 random fluxes to save space | ||
barplot( | ||
productions[disp_rxns], | ||
direction = :x, | ||
axis = ( | ||
yticks = (1:20, reactions(model)[disp_rxns]), | ||
xlabel = "Flux [mmol/gDW/h]", | ||
ylabel = "Reaction ID", | ||
), | ||
) | ||
``` | ||
%% Output | ||
FigureAxisPlot() | ||
%% Cell type:markdown id: tags: | ||
## Knocking out reaction combinations | ||
It is very easy to prepare matrices of biomass productions from all possible | ||
two-reaction knockouts. To make it more interesting, we will restrict one of | ||
the reactions of the pair a bit less, to see more possible outcomes. | ||
%% Cell type:markdown id: tags: | ||
We do not process all reactions here to make the notebook rendering | ||
efficient, but you can easily remove the restriction, and speed the process | ||
up using parallel execution, by specifying `workers` argument (see | ||
documentation of `screen` for details) | ||
%% Cell type:code id: tags: | ||
``` julia | ||
rxns = reactions(model) | ||
productions = screen_variants( | ||
model, | ||
[ | ||
[with_limited_rate(rxn1, 3), with_limited_rate(rxn2, 0.1)] for rxn1 in rxns, | ||
rxn2 in rxns | ||
], | ||
model -> get_biomass(flux_balance_analysis_dict(model, Tulip.Optimizer)), | ||
) | ||
f = Figure() | ||
ax = Axis( | ||
f[1, 1], | ||
ylabel = "Reaction KO", | ||
xlabel = "Reaction KO", | ||
yticks = (1:20, reactions(model)[disp_rxns]), | ||
xticks = (1:20, reactions(model)[disp_rxns]), | ||
xticklabelrotation = -pi / 4, | ||
) | ||
hm = heatmap!(ax, productions[disp_rxns, disp_rxns]) | ||
Colorbar(f[1, 2], hm, label = "Flux [mmol/gDW/h]") | ||
f | ||
``` | ||
%% Output | ||
Figure() | ||
%% Cell type:markdown id: tags: | ||
--- | ||
*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* |
Please register or sign in to comment