From 90bee07627c8044a66318c50dbeb344dbaed4c10 Mon Sep 17 00:00:00 2001 From: "St. Elmo Wilken" Date: Mon, 1 Aug 2022 11:13:58 +0200 Subject: [PATCH 1/4] Update MMDF section --- docs/src/examples/12_mmdf.jl | 50 +++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/docs/src/examples/12_mmdf.jl b/docs/src/examples/12_mmdf.jl index 42071a70d..642b1201c 100644 --- a/docs/src/examples/12_mmdf.jl +++ b/docs/src/examples/12_mmdf.jl @@ -23,10 +23,10 @@ model = load_model("e_coli_core.json") # obtained e.g. from [eQuilibrator](https://equilibrator.weizmann.ac.il/) # (possibly using the existing [Julia # wrapper](https://github.com/stelmo/eQuilibrator.jl) that allows you to -# automate this step). +# automate this step in Julia). # # Here, we have gathered a dictionary that maps the reaction IDs to calculated -# Gibbs free energy of that reaction for each reaction (including the +# Gibbs free energy of reaction for each metabolic reaction (including the # transporters). The units of the measurements are not crucial for the # computation, but we use the usual kJ/mol for consistency. @@ -123,16 +123,16 @@ flux_solution = flux_balance_analysis_dict( # We can now run the MMDF. # -# In the call, we additionally specify the metabolite IDs of protons and water -# so that they are omitted from concentration calculations, water transport -# reaction (that should also be ignored), and additionally fix precise ratios -# of concentrations of certain metabolites to reflect the assumptions (and -# possibly measurements) about the organism. +# In the call, we specify the metabolite IDs of protons and water so that they +# are omitted from concentration calculations. Also, the water transport +# reaction should typically also be ignored. Additionally, we can fix the +# concentration ratios of certain metabolites directly. # -# The reason for removing the protons and water from concentration calculation -# is that because the Gibbs free energies of biochemical reactions are measured -# at constant pH. Allowing the model to change the pH would break the -# assumptions about validity of the thermodynamics of all reactions. +# The reason for removing the protons and water from the concentration +# calculations is because the Gibbs free energies of biochemical reactions are +# measured at constant pH in aqueous environments. Allowing the model to change +# the pH would break the assumptions about validity of the thermodynamic +# measurements. sol = max_min_driving_force( model, @@ -163,26 +163,28 @@ sol.mmdf #md # the MMDF will likely only have a zero solution. # Finally, we show how the concentrations are optimized to ensure that each -# reacction proceeds "down the hill" (ΔᵣG < 0). We can explore the glycolysis +# reaction proceeds "down the hill" (ΔᵣG < 0). We can explore the glycolysis # pathway reactions: glycolysis_pathway = ["GLCpts", "PGI", "PFK", "FBA", "TPI", "GAPD", "PGK", "PGM", "ENO", "PYK"] # We additionally scale the fluxes according to their stoichiometry in the -# pathway. From the output, we can clearly see that that metabolite -# concentrations play a large role in ensuring the thermodynamic consistency of -# in vivo reactions. - -# The flux from simple loopless FBA has several reactions with positive ΔᵣG: -Dict( - rid => reaction_standard_gibbs_free_energies[rid] * flux_solution[rid] for - rid in glycolysis_pathway -) +# pathway. From the output, we can clearly see that metabolite concentrations +# play a large role in ensuring the thermodynamic consistency of in vivo +# reactions. + +using CairoMakie + +standard_dg = cumsum([reaction_standard_gibbs_free_energies[rid] * flux_solution[rid] for rid in glycolysis_pathway]); +optimal_dg = cumsum([sol.dg_reactions[rid] * flux_solution[rid] for rid in glycolysis_pathway]); -# The solution optimized with [`max_min_driving_force`](@ref) is -# thermodynamically viable: -Dict(rid => sol.dg_reactions[rid] * flux_solution[rid] for rid in glycolysis_pathway) +f = Figure(); +ax = Axis(f[1,1], ylabel="Cumulative ΔG", xticks = (1:10, glycolysis_pathway)); +lines!(ax, 1:10, standard_dg .- first(standard_dg), color=:blue, label="ΔG⁰"); +lines!(ax, 1:10, optimal_dg .- first(optimal_dg), color=:red, label="MMDF solution"); +axislegend(ax) +f #md # !!! tip "Thermodynamic variability" #md # As with normal flux variability, thermodynamic constraints in a model also allow a certain amount of parameter selection freedom. From c9b648c34850e43eea131992bac62db9de36eb94 Mon Sep 17 00:00:00 2001 From: "St. Elmo Wilken" Date: Mon, 1 Aug 2022 11:27:17 +0200 Subject: [PATCH 2/4] add slightly more details to gecko --- docs/src/examples/15_gecko.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/src/examples/15_gecko.jl b/docs/src/examples/15_gecko.jl index 5931116f9..93ffe89c8 100644 --- a/docs/src/examples/15_gecko.jl +++ b/docs/src/examples/15_gecko.jl @@ -76,9 +76,13 @@ gecko_model = [stoichiometry(gecko_model); coupling(gecko_model)] -# Again, the resulting model can be used in any type of analysis. For example, balance: +# Again, the resulting model can be used in any type of analysis. For example, flux balance analysis: -flux_balance_analysis_dict(gecko_model, GLPK.Optimizer) +opt_model = flux_balance_analysis(gecko_model, GLPK.Optimizer) + +flux_sol = flux_dict(gecko_model, opt_model) + +gp_concs = gene_product_dict(model, opt_model) # Variability: @@ -87,3 +91,5 @@ flux_variability_analysis(gecko_model, GLPK.Optimizer, bounds = gamma_bounds(0.9 # ...and sampling: affine_hit_and_run(gecko_model, warmup_from_variability(gecko_model, GLPK.Optimizer))' * reaction_flux(gecko_model) + +# See also \ No newline at end of file From 1a180f1f830ed80584b58d0c384bd5f9e14b0935 Mon Sep 17 00:00:00 2001 From: "St. Elmo Wilken" Date: Mon, 1 Aug 2022 11:47:35 +0200 Subject: [PATCH 3/4] fix gecko --- docs/src/examples/15_gecko.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/examples/15_gecko.jl b/docs/src/examples/15_gecko.jl index 93ffe89c8..ac5c0f999 100644 --- a/docs/src/examples/15_gecko.jl +++ b/docs/src/examples/15_gecko.jl @@ -82,7 +82,9 @@ opt_model = flux_balance_analysis(gecko_model, GLPK.Optimizer) flux_sol = flux_dict(gecko_model, opt_model) -gp_concs = gene_product_dict(model, opt_model) +gp_concs = gene_product_dict(gecko_model, opt_model) + +gene_product_mass_group_dict(gecko_model, opt_model) # Variability: @@ -91,5 +93,3 @@ flux_variability_analysis(gecko_model, GLPK.Optimizer, bounds = gamma_bounds(0.9 # ...and sampling: affine_hit_and_run(gecko_model, warmup_from_variability(gecko_model, GLPK.Optimizer))' * reaction_flux(gecko_model) - -# See also \ No newline at end of file From d62e4fd8087c6b895b5c91a1915ae1305101c8ea Mon Sep 17 00:00:00 2001 From: stelmo Date: Mon, 1 Aug 2022 09:49:31 +0000 Subject: [PATCH 4/4] automatic formatting triggered by @stelmo on PR #643 --- docs/src/examples/12_mmdf.jl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/src/examples/12_mmdf.jl b/docs/src/examples/12_mmdf.jl index 642b1201c..0b0dd6d29 100644 --- a/docs/src/examples/12_mmdf.jl +++ b/docs/src/examples/12_mmdf.jl @@ -176,13 +176,17 @@ glycolysis_pathway = using CairoMakie -standard_dg = cumsum([reaction_standard_gibbs_free_energies[rid] * flux_solution[rid] for rid in glycolysis_pathway]); -optimal_dg = cumsum([sol.dg_reactions[rid] * flux_solution[rid] for rid in glycolysis_pathway]); +standard_dg = cumsum([ + reaction_standard_gibbs_free_energies[rid] * flux_solution[rid] for + rid in glycolysis_pathway +]); +optimal_dg = + cumsum([sol.dg_reactions[rid] * flux_solution[rid] for rid in glycolysis_pathway]); f = Figure(); -ax = Axis(f[1,1], ylabel="Cumulative ΔG", xticks = (1:10, glycolysis_pathway)); -lines!(ax, 1:10, standard_dg .- first(standard_dg), color=:blue, label="ΔG⁰"); -lines!(ax, 1:10, optimal_dg .- first(optimal_dg), color=:red, label="MMDF solution"); +ax = Axis(f[1, 1], ylabel = "Cumulative ΔG", xticks = (1:10, glycolysis_pathway)); +lines!(ax, 1:10, standard_dg .- first(standard_dg), color = :blue, label = "ΔG⁰"); +lines!(ax, 1:10, optimal_dg .- first(optimal_dg), color = :red, label = "MMDF solution"); axislegend(ax) f