diff --git a/docs/build/.documenter-siteinfo.json b/docs/build/.documenter-siteinfo.json index 4013b16..f73f4d1 100644 --- a/docs/build/.documenter-siteinfo.json +++ b/docs/build/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-11-12T11:05:44","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-11-12T14:39:50","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/docs/build/index.html b/docs/build/index.html index 2fd2c7f..3ba1c7a 100644 --- a/docs/build/index.html +++ b/docs/build/index.html @@ -1,2 +1,2 @@ -MarkovWeightedEFMs.jl · MarkovWeightedEFMs.jl

MarkovWeightedEFMs.jl

MarkovWeightedEFMs.jl is a package to decompose steady state metabolic fluxes onto elementary flux mode (EFM) weights and atomic elementary flux mode (AEFM) weights. EFM flux decomposition works only for closed-loop networks of unimolecular reactions. AEFM flux decomposition works on metabolic flux networks with known metabolite structures.

Usage

See Getting started for package installation and Python dependencies (RXNMapper) for AEFM enumeration and flux decomposition. Once installed, the package is loaded in a julia session by typing:

julia> using MarkovWeightedEFMs

See the tutorial sections for EFM or AEFM enumeration and flux decomposition.

Citing MarkovWeightedEFMs.jl

Please cite the following papers if you use our method for (A)EFM enumeration and flux decomposition.

Justin G. Chitpin and Theodore J. Perkins, Atomic elementary flux modes explain the steady state flow of metabolites in flux networks. biorXiv preprint doi: XX.XXXX/XXXX.XX.XX.XXXXXX

Justin G. Chitpin and Theodore J. Perkins, A Markov constraint to uniquely identify elementary flux mode weights in unimolecular metabolic networks. J Theor Biol. 2023 Nov 7;575:111632. doi: 10.1016/j.jtbi.2023.111632

License

This software is released under the MIT license.

Contact information

Justin G. Chitpin at jchit069@uottawa.ca for questions.

+MarkovWeightedEFMs.jl · MarkovWeightedEFMs.jl

MarkovWeightedEFMs.jl

MarkovWeightedEFMs.jl is a package to decompose steady state metabolic fluxes onto elementary flux mode (EFM) weights and atomic elementary flux mode (AEFM) weights. EFM flux decomposition works only for closed-loop networks of unimolecular reactions. AEFM flux decomposition works on metabolic flux networks with known metabolite structures.

Usage

See Getting started for package installation and Python dependencies (RXNMapper) for AEFM enumeration and flux decomposition. Once installed, the package is loaded in a julia session by typing:

julia> using MarkovWeightedEFMs

See the tutorial sections for EFM or AEFM enumeration and flux decomposition.

Citing MarkovWeightedEFMs.jl

Please cite the following papers if you use our method for (A)EFM enumeration and flux decomposition.

Justin G. Chitpin and Theodore J. Perkins, Atomic elementary flux modes explain the steady state flow of metabolites in flux networks. biorXiv preprint doi: XX.XXXX/XXXX.XX.XX.XXXXXX

Justin G. Chitpin and Theodore J. Perkins, A Markov constraint to uniquely identify elementary flux mode weights in unimolecular metabolic networks. J Theor Biol. 2023 Nov 7;575:111632. doi: 10.1016/j.jtbi.2023.111632

License

This software is released under the MIT license.

Contact information

Justin G. Chitpin at jchit069@uottawa.ca for questions.

diff --git a/docs/build/installation/installation/index.html b/docs/build/installation/installation/index.html index 584df25..dce7c02 100644 --- a/docs/build/installation/installation/index.html +++ b/docs/build/installation/installation/index.html @@ -1,5 +1,5 @@ -Getting started · MarkovWeightedEFMs.jl

Getting started

To install this package, open a julia session and enter:

julia> ]
+Getting started · MarkovWeightedEFMs.jl

Getting started

To install this package, open a julia session and enter:

julia> ]
 (@v1.10) pkg> add https://github.com/jchitpin/MarkovWeightedEFMs.jl.git

Alternatively, you can load Pkg and install by:

julia> using Pkg
 julia> Pkg.add("https://github.com/jchitpin/MarkovWeightedEFMs.jl.git")

Python dependencies for AEFM analysis

AEFM-specific analyses depend on the atom mapping program RXNMapper. This package must be installed and built with PyCall.jl after installing MarkovWeightedEFMs.jl. Tested to work with python version 3.10 and 3.11

This can be done by creating a python virtual environment, installing RXNMapper, and setting the PYTHON environment variable to the python executable in the virtual environment.

$ pip install virtualenv
 $ virtualenv --python="/usr/bin/python3.10" "virtualenv" # name of virtual environment
@@ -12,4 +12,4 @@
 (virtualenv) $ pip install CTSgetPy
 (virtualenv) $ julia
julia> using Pkg, PyCall
 julia> ENV["PYTHON"] = joinpath(ENV["VIRTUAL_ENV"], "bin", "python")
-julia> Pkg.build("PyCall")

Note PyCall.jl will need to be rebuilt whenever you update your Julia version. See PyCall.jl documentation for more options on setting up Python in Julia.

See Exact Python dependencies for RXNMapper for more information.

+julia> Pkg.build("PyCall")

Note PyCall.jl will need to be rebuilt whenever you update your Julia version. See PyCall.jl documentation for more options on setting up Python in Julia.

See Exact Python dependencies for RXNMapper for more information.

diff --git a/docs/build/installation/python-dependencies/index.html b/docs/build/installation/python-dependencies/index.html index 5991808..221b637 100644 --- a/docs/build/installation/python-dependencies/index.html +++ b/docs/build/installation/python-dependencies/index.html @@ -1,5 +1,5 @@ -Exact Python dependencies for RXNMapper · MarkovWeightedEFMs.jl

Exact Python dependencies for RXNMapper

Python version

(rxnmapper-virtual-environment)
+Exact Python dependencies for RXNMapper · MarkovWeightedEFMs.jl

Exact Python dependencies for RXNMapper

Python version

(rxnmapper-virtual-environment)
 $ python
 Python 3.10.14 (main, Jul 31 2024, 21:14:36) [GCC 14.1.1 20240720] on linux
 Type "help", "copyright", "credits" or "license" for more information.
@@ -74,4 +74,4 @@
 typing_extensions        4.12.2
 tzdata                   2024.1
 urllib3                  2.2.2
-wheel                    0.43.0
+wheel 0.43.0
diff --git a/docs/build/library/chmc-atomic/index.html b/docs/build/library/chmc-atomic/index.html index a9f6f75..2d251f0 100644 --- a/docs/build/library/chmc-atomic/index.html +++ b/docs/build/library/chmc-atomic/index.html @@ -1,52 +1,52 @@ -Atomic CHMC · MarkovWeightedEFMs.jl

Atomic CHMC

Public functions

MarkovWeightedEFMs.CHMC.Atomic.find_atomic_chmc_input_errorsFunction
find_atomic_chmc_input_errors(S::Matrix{<:Real}, v::Vector{<:Real})

Performs a series of checks on stoichiometry matrix S and steady state flux vector v to determine whether they meet the atomic CHMC requirements. Returns an CHMCAtomicErrorSummary structure that can be printed via print(res::CHMCAtomicErrorSummary).

source
find_atomic_chmc_input_errors(S::Matrix{<:Real})

Performs a series of checks on stoichiometry matrix S to determine whether they meet the atomic CHMC requirements for atomic EFM enumeration. Returns an CHMCAtomicErrorSummary structure that can be printed via print(res::CHMCAtomicErrorSummary).

source
MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_errorsFunction
correct_atomic_chmc_input_errors(#
+Atomic CHMC · MarkovWeightedEFMs.jl

Atomic CHMC

Public functions

MarkovWeightedEFMs.CHMC.Atomic.find_atomic_chmc_input_errorsFunction
find_atomic_chmc_input_errors(S::Matrix{<:Real}, v::Vector{<:Real})

Performs a series of checks on stoichiometry matrix S and steady state flux vector v to determine whether they meet the atomic CHMC requirements. Returns an CHMCAtomicErrorSummary structure that can be printed via print(res::CHMCAtomicErrorSummary).

source
find_atomic_chmc_input_errors(S::Matrix{<:Real})

Performs a series of checks on stoichiometry matrix S to determine whether they meet the atomic CHMC requirements for atomic EFM enumeration. Returns an CHMCAtomicErrorSummary structure that can be printed via print(res::CHMCAtomicErrorSummary).

source
MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_errorsFunction
correct_atomic_chmc_input_errors(#
     res::CHMCAtomicErrorSummary,
     S::Matrix{<:Real},
     v::Vector{<:Real},
     mets::Vector{String},
     rxns::Vector{String}
-)

Corrects all errors identified by find_atomic_chmc_input_errors except for the steady state flux requirement. Returns a corrected version of each input.

S is the m by n stoichiometry matrix. v is the steady state flux vector of length n. mets is the vector of metabolite names of length m. rxns is the vector of reaction names of length n.

source
correct_atomic_chmc_input_errors(#
+)

Corrects all errors identified by find_atomic_chmc_input_errors except for the steady state flux requirement. Returns a corrected version of each input.

S is the m by n stoichiometry matrix. v is the steady state flux vector of length n. mets is the vector of metabolite names of length m. rxns is the vector of reaction names of length n.

source
correct_atomic_chmc_input_errors(#
     res::CHMCAtomicErrorSummary,
     S::Matrix{<:Real},
     mets::Vector{String},
     rxns::Vector{String}
-)

Corrects all errors identified by find_atomic_chmc_input_errors except for the steady state flux requirement. Returns a corrected version of each input.

S is the m by n stoichiometry matrix. mets is the vector of metabolite names of length m. rxns is the vector of reaction names of length n.

source
Base.printMethod
print(res::CHMCAtomicErrorSummary)

Write CHMCAtomicErrorSummary to stdout.

source
Base.printMethod
print(res::CHMCAtomicErrorSummary)

Write CHMCAtomicErrorSummary to stdout.

source
MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_smilesFunction
correct_atomic_chmc_input_smiles(#
     S::Matrix{<:Real},
     v::Vector{<:Real},
     mets::Vector{String},
     rxns::Vector{String},
     smiles::Vector{String},
     H::Bool=false
-)

Updates the inputs by (1) removing pseudometabolites and (2) reactions whose reaction strings exceed the RXNMapper character limit. Pseudometabolites are defined as either metabolites with no defined chemical structure/SMILES representation, or metabolites whose SMILES strings contain symbols absent from the periodic table (including metabolites with an R-group). Reactions that exceed the RXNMapper character limit are converted into unimolecular sources and sinks to maintain steady state flux. Returns the corrected inputs with a list of removed metabolites/reactions.

S is the m by n stoichiometry matrix.

v is the steady state flux vector of length n.

mets is the vector of metabolite names of length m.

rxns is the vector of reaction names of length n.

smiles is the vector of metabolite smiles matching mets.

H = false will not check for hydrogen conservation in each reaction.

source
correct_atomic_chmc_input_smiles(#
+)

Updates the inputs by (1) removing pseudometabolites and (2) reactions whose reaction strings exceed the RXNMapper character limit. Pseudometabolites are defined as either metabolites with no defined chemical structure/SMILES representation, or metabolites whose SMILES strings contain symbols absent from the periodic table (including metabolites with an R-group). Reactions that exceed the RXNMapper character limit are converted into unimolecular sources and sinks to maintain steady state flux. Returns the corrected inputs with a list of removed metabolites/reactions.

S is the m by n stoichiometry matrix.

v is the steady state flux vector of length n.

mets is the vector of metabolite names of length m.

rxns is the vector of reaction names of length n.

smiles is the vector of metabolite smiles matching mets.

H = false will not check for hydrogen conservation in each reaction.

source
correct_atomic_chmc_input_smiles(#
     S::Matrix{<:Real},
     mets::Vector{String},
     rxns::Vector{String},
     smiles::Vector{String},
     H::Bool=false
-)

Updates the inputs by (1) removing pseudometabolites and (2) reactions whose reaction strings exceed the RXNMapper character limit. Pseudometabolites are defined as either metabolites with no defined chemical structure/SMILES representation, or metabolites whose SMILES strings contain symbols absent from the periodic table (including metabolites with an R-group). Reactions that exceed the RXNMapper character limit are converted into unimolecular sources and sinks to maintain steady state flux. Returns the corrected inputs with a list of removed metabolites/reactions.

S is the m by n stoichiometry matrix.

mets is the vector of metabolite names of length m.

rxns is the vector of reaction names of length n.

smiles is the vector of metabolite smiles matching mets.

H = false will not check for hydrogen conservation in each reaction.

source
MarkovWeightedEFMs.CHMC.Atomic.exchange_atomic_chmc_input_metabolitesFunction
exchange_atomic_chmc_input_metabolites(#
+)

Updates the inputs by (1) removing pseudometabolites and (2) reactions whose reaction strings exceed the RXNMapper character limit. Pseudometabolites are defined as either metabolites with no defined chemical structure/SMILES representation, or metabolites whose SMILES strings contain symbols absent from the periodic table (including metabolites with an R-group). Reactions that exceed the RXNMapper character limit are converted into unimolecular sources and sinks to maintain steady state flux. Returns the corrected inputs with a list of removed metabolites/reactions.

S is the m by n stoichiometry matrix.

mets is the vector of metabolite names of length m.

rxns is the vector of reaction names of length n.

smiles is the vector of metabolite smiles matching mets.

H = false will not check for hydrogen conservation in each reaction.

source
MarkovWeightedEFMs.CHMC.Atomic.exchange_atomic_chmc_input_metabolitesFunction
exchange_atomic_chmc_input_metabolites(#
     S::Matrix{<:Real},
     v::Vector{<:Real},
     mets::Vector{String},
     rxns::Vector{String},
     smiles::Vector{String},
     ii::Vector{Int64}
-)

Removes internal metabolites ii from the remaining inputs by converting each metabolite i ∈ ii into a pair of sink and source metabolites. Returns an updated copy of inputs S, v, mets, rxns, and smiles.

S is the m by n stoichiometry matrix.

v is the steady state flux vector of length n.

mets is the vector of metabolite names of length m.

rxns is the vector of reaction names of length n.

smiles is the vector of metabolite smiles matching mets.

ii is the vector of metabolite indices to exchange for pairs of sinks/sources.

source
exchange_atomic_chmc_input_metabolites(#
+)

Removes internal metabolites ii from the remaining inputs by converting each metabolite i ∈ ii into a pair of sink and source metabolites. Returns an updated copy of inputs S, v, mets, rxns, and smiles.

S is the m by n stoichiometry matrix.

v is the steady state flux vector of length n.

mets is the vector of metabolite names of length m.

rxns is the vector of reaction names of length n.

smiles is the vector of metabolite smiles matching mets.

ii is the vector of metabolite indices to exchange for pairs of sinks/sources.

source
exchange_atomic_chmc_input_metabolites(#
     S::Matrix{<:Real},
     mets::Vector{String},
     rxns::Vector{String},
     smiles::Vector{String},
     ii::Vector{Int64}
-)

Removes internal metabolites ii from the remaining inputs by converting each metabolite i ∈ ii into a pair of sink and source metabolites. Returns an updated copy of inputs S, mets, rxns, and smiles.

S is the m by n stoichiometry matrix.

mets is the vector of metabolite names of length m.

rxns is the vector of reaction names of length n.

smiles is the vector of metabolite smiles matching mets.

ii is the vector of metabolite indices to exchange for pairs of sinks/sources.

source
MarkovWeightedEFMs.CHMC.Atomic.get_max_atomsFunction
get_max_atoms(s::Vector{String}, a::Symbol)

Returns the maximum number of atoms of type a for each SMILES string in s. Returns a vector of all source metabolites in stoichiometry matrix S.

s is the vector of metabolite SMILES strings.

a is a periodic table element symbol.

source
MarkovWeightedEFMs.CHMC.Atomic.map_reaction_stringsFunction
map_reaction_strings(#
+)

Removes internal metabolites ii from the remaining inputs by converting each metabolite i ∈ ii into a pair of sink and source metabolites. Returns an updated copy of inputs S, mets, rxns, and smiles.

S is the m by n stoichiometry matrix.

mets is the vector of metabolite names of length m.

rxns is the vector of reaction names of length n.

smiles is the vector of metabolite smiles matching mets.

ii is the vector of metabolite indices to exchange for pairs of sinks/sources.

source
MarkovWeightedEFMs.CHMC.Atomic.get_max_atomsFunction
get_max_atoms(s::Vector{String}, a::Symbol)

Returns the maximum number of atoms of type a for each SMILES string in s. Returns a vector of all source metabolites in stoichiometry matrix S.

s is the vector of metabolite SMILES strings.

a is a periodic table element symbol.

source
MarkovWeightedEFMs.CHMC.Atomic.map_reaction_stringsFunction
map_reaction_strings(#
     S::Matrix{<:Real},
     smiles::Vector{String},
     rxns::Vector{String},
     H::Bool=false
-)

Constructs reaction strings from the smiles and then returns the atom-mapped reaction strings via RXNMapper.

S is the stoichiometry matrix.

smiles is the vector of SMILES strings for metabolites in S.

rxns is the vector of reaction names in S.

H = false will not check for hydrogen conservation in each reaction.

source
MarkovWeightedEFMs.CHMC.Atomic.precompute_atom_tracing_dictionaryFunction
precompute_atom_tracing_dictionary(#
+)

Constructs reaction strings from the smiles and then returns the atom-mapped reaction strings via RXNMapper.

S is the stoichiometry matrix.

smiles is the vector of SMILES strings for metabolites in S.

rxns is the vector of reaction names in S.

H = false will not check for hydrogen conservation in each reaction.

source
MarkovWeightedEFMs.CHMC.Atomic.precompute_atom_tracing_dictionaryFunction
precompute_atom_tracing_dictionary(#
     S::Matrix{Int16},
     ms::Vector{String},
     amax::Vector{Int64},
     a::Symbol
-)

Precomputes a dictionary mapping each atom in a given substrate stoichiometric copy to its product atom across every reaction. The dictionary is used in steady_state_efm_distribution.

S is the stoichiometry matrix.

ms is the vector of mapped reaction SMILES strings.

amax is the total number of atom a in each metabolite row of S.

a is a periodic table element symbol.

source
MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distributionMethod
steady_state_efm_distribution(#
     S::Matrix{<:Integer},
     v::Vector{<:Real},
     ms::Vector{String},
@@ -57,7 +57,14 @@
     } = Dict{NTuple{4,Int64}, Tuple{Int64,Int64}}();
     solver = nothing,
     verbose::Bool = true
-)

Enumerates the atomic EFMs from stoichiometry matrix S and compute the steady state probabilities of each EFM according to the discrete-time, cycle-history Markov chain.

S is a fully-connected, unimolecular, m by n stoichiometry matrix with m metabolites and n reactions.

v is the n-length steady state flux vector associated with S.

ms is the vector of mapped reaction SMILES strings.

I is a triplet of the metabolite row index in S, the atom index, and the atom index type. It is the initial starting state for rooting the cycle-history Markov chain.

D is the precomputed dictionary from precompute_atom_tracing_dictionary.

solver is the type used for eigenvector calculations. Default is nothing and LinearSolve will pick the best solver. Consult LinearSolve.jl for specifying other solvers.

source
MarkovWeightedEFMs.CHMC.Atomic.export_atom_tracing_dictionaryFunction
export_atom_tracing_dictionary(#
+)

Enumerates the atomic EFMs from stoichiometry matrix S and compute the steady state probabilities of each EFM according to the discrete-time, cycle-history Markov chain.

S is a fully-connected, unimolecular, m by n stoichiometry matrix with m metabolites and n reactions.

v is the n-length steady state flux vector associated with S.

ms is the vector of mapped reaction SMILES strings.

I is a triplet of the metabolite row index in S, the atom index, and the atom index type. It is the initial starting state for rooting the cycle-history Markov chain.

D is the precomputed dictionary from precompute_atom_tracing_dictionary.

solver is the type used for eigenvector calculations. Default is nothing and LinearSolve will pick the best solver. Consult LinearSolve.jl for specifying other solvers.

source

Index

+)

Export atom tracing dictionary D to text file fname.

fname is the filename to write the atom tracing dictionary results.

D is the dictionary from precompute_atom_tracing_dictionary.

source
MarkovWeightedEFMs.CHMC.Atomic.preprocess_all_for_atomic_chmcFunction
preprocess_all_for_atomic_chmc(#
+    S::Matrix{<:Real},
+    v::Vector{<:Real},
+    mets::Vector{String},
+    rxns::Vector{String},
+    smiles::Vector{String},
+    atom::Symbol
+)

Wrapper function to run pre-processing functions and return the updated model, atomic info, and error/warning logs.

S is the m by n stoichiometry matrix. v is the steady state flux vector of length n. mets is the vector of metabolite names of length m. rxns is the vector of reaction names of length n. smiles is the vector of metabolite SMILES strings of length m. a is a periodic table element symbol.

source

Index

diff --git a/docs/build/library/chmc-plots-atomic/index.html b/docs/build/library/chmc-plots-atomic/index.html index 5f0d4ff..0fdc16a 100644 --- a/docs/build/library/chmc-plots-atomic/index.html +++ b/docs/build/library/chmc-plots-atomic/index.html @@ -1,10 +1,10 @@ -Plotting (ACHMC) · MarkovWeightedEFMs.jl

Plotting (ACHMC)

Atomic CHMC

MarkovWeightedEFMs.Plots.plot_mapped_reactionFunction
function plot_mapped_reaction(#
+Plotting (ACHMC) · MarkovWeightedEFMs.jl

Plotting (ACHMC)

Atomic CHMC

MarkovWeightedEFMs.Plots.plot_mapped_reactionFunction
function plot_mapped_reaction(#
     s::String,
     fname::String = "";
     view::Bool = false,
     canvas_width::Int64 = 3000,
-    canvas_height::Int64 = 1000

)

Plot mapped reaction SMILES string s as an SVG and save to fname if specified.

canvas_width is the width of the SVG.

canvas_height is the height of the SVG.

view = true will plot the SVG assuming a plotting backend is specified. For example, loading the ElectronDisplay package will plot the SVG to an Electron window.

source
MarkovWeightedEFMs.Plots.plot_atomic_chmcFunction
function plot_atomic_chmc(#
+    canvas_height::Int64 = 1000

)

Plot mapped reaction SMILES string s as an SVG and save to fname if specified.

canvas_width is the width of the SVG.

canvas_height is the height of the SVG.

view = true will plot the SVG assuming a plotting backend is specified. For example, loading the ElectronDisplay package will plot the SVG to an Electron window.

source
MarkovWeightedEFMs.Plots.plot_atomic_chmcFunction
function plot_atomic_chmc(#
     res::CHMCAtomicSummary,
     S::Matrix{Int16},
     mets::Vector{String},
@@ -21,4 +21,4 @@
     } = ((1,0),(0,1)),
     show_all::Bool=false,
     width::Int64=620,
-    height::Int64=310

)

Plot atomic cycle-history Markov chain.

S is the m by n stoichiometry matrix.

mets is the vector of metabolite names of length m.

rs is the vector of reaction SMILES strings of length n.

node_label_textsize is the text size of the node labels indexed from T.

edge_label_textsize is the text size of the edge labels taken from T.

arrow_shift is the percentage shift of the arrow head from src to dst.

x_pad is the left/right x coordinate padding of the plotting box.

y_pad is the up/down y coordinate padding of the plotting box.

tfactor scales the distance of the bezier control point relative to the distance of the src and dst nodes.

tangents is the tangent of the src vertex and dst vertex.

show_all=true explicitly plots the upstream transition from all EFMs that pass through the initial state/node I. By default, these arrows stemming from the green nodes are omitted for visual clarity.

width and height specify the plotting window dimensions in pixel units.

source

Index

    + height::Int64=310

    )

    Plot atomic cycle-history Markov chain.

    S is the m by n stoichiometry matrix.

    mets is the vector of metabolite names of length m.

    rs is the vector of reaction SMILES strings of length n.

    node_label_textsize is the text size of the node labels indexed from T.

    edge_label_textsize is the text size of the edge labels taken from T.

    arrow_shift is the percentage shift of the arrow head from src to dst.

    x_pad is the left/right x coordinate padding of the plotting box.

    y_pad is the up/down y coordinate padding of the plotting box.

    tfactor scales the distance of the bezier control point relative to the distance of the src and dst nodes.

    tangents is the tangent of the src vertex and dst vertex.

    show_all=true explicitly plots the upstream transition from all EFMs that pass through the initial state/node I. By default, these arrows stemming from the green nodes are omitted for visual clarity.

    width and height specify the plotting window dimensions in pixel units.

    source

    Index

      diff --git a/docs/build/library/chmc-plots-standard/index.html b/docs/build/library/chmc-plots-standard/index.html index 98d0a25..2000000 100644 --- a/docs/build/library/chmc-plots-standard/index.html +++ b/docs/build/library/chmc-plots-standard/index.html @@ -1,5 +1,5 @@ -Plotting (CHMC) · MarkovWeightedEFMs.jl

      Plotting (CHMC)

      CHMC

      MarkovWeightedEFMs.Plots.plot_chmcFunction
      function plot_chmc(#
      +Plotting (CHMC) · MarkovWeightedEFMs.jl

      Plotting (CHMC)

      CHMC

      MarkovWeightedEFMs.Plots.plot_chmcFunction
      function plot_chmc(#
           T::Matrix{<:Real},
           I::Int64=1;
           node_label_textsize::Real=15,
      @@ -12,4 +12,4 @@
               Tuple{<:Real, <:Real},
               Tuple{<:Real, <:Real}
           } = ((1,0),(0,1)),
      -    show_all::Bool=false

      )

      Plot cycle-history Markov chain from transition probability matrix T rooted on state/node I.

      T is a right stochastic transition probability matrix with rows summing to one.

      I is a state in 1:size(T,1).

      node_label_textsize is the text size of the node labels indexed from T.

      edge_label_textsize is the text size of the edge labels taken from T.

      arrow_shift is the percentage shift of the arrow head from src to dst.

      x_pad is the left/right x coordinate padding of the plotting box.

      y_pad is the up/down y coordinate padding of the plotting box.

      tfactor scales the distance of the bezier control point relative to the distance of the src and dst nodes.

      tangents is the tangent of the src vertex and dst vertex.

      show_all=true explicitly plots the upstream transition from all EFMs that pass through the initial state/node I. By default, these arrows stemming from the green nodes are omitted for visual clarity.

      source

      Index

        + show_all::Bool=false

        )

        Plot cycle-history Markov chain from transition probability matrix T rooted on state/node I.

        T is a right stochastic transition probability matrix with rows summing to one.

        I is a state in 1:size(T,1).

        node_label_textsize is the text size of the node labels indexed from T.

        edge_label_textsize is the text size of the edge labels taken from T.

        arrow_shift is the percentage shift of the arrow head from src to dst.

        x_pad is the left/right x coordinate padding of the plotting box.

        y_pad is the up/down y coordinate padding of the plotting box.

        tfactor scales the distance of the bezier control point relative to the distance of the src and dst nodes.

        tangents is the tangent of the src vertex and dst vertex.

        show_all=true explicitly plots the upstream transition from all EFMs that pass through the initial state/node I. By default, these arrows stemming from the green nodes are omitted for visual clarity.

        source

        Index

          diff --git a/docs/build/library/chmc-standard/index.html b/docs/build/library/chmc-standard/index.html index 41badfe..f861609 100644 --- a/docs/build/library/chmc-standard/index.html +++ b/docs/build/library/chmc-standard/index.html @@ -1,5 +1,5 @@ -CHMC · MarkovWeightedEFMs.jl

          CHMC

          Public functions

          MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distributionFunction
          steady_state_efm_distribution(#
          +CHMC · MarkovWeightedEFMs.jl

          CHMC

          Public functions

          MarkovWeightedEFMs.CHMC.Standard.stoichiometry_to_transition_matrixFunction
          stoichiometry_to_transition_matrix(S::Matrix{<:Integer}, v::Vector{<:Real})

          Convert stoichiometry matrix S with vector of steady state fluxes to a right stochastic transition probability matrix with rows summing to one.

          S is the m by n stoichiometry matrix with m metabolites and n reactions.

          v is the steady state flux vector with length n.

          Examples

          julia> S = [#
          + 0.2147858996605714
          source
          MarkovWeightedEFMs.CHMC.Standard.stoichiometry_to_transition_matrixFunction
          stoichiometry_to_transition_matrix(S::Matrix{<:Integer}, v::Vector{<:Real})

          Convert stoichiometry matrix S with vector of steady state fluxes to a right stochastic transition probability matrix with rows summing to one.

          S is the m by n stoichiometry matrix with m metabolites and n reactions.

          v is the steady state flux vector with length n.

          Examples

          julia> S = [#
             -1  0  0  0  0  0  0  0  0  0  1
              1 -1  1 -1  0  0  0  0  0  0  0
              0  1 -1  0 -1  1  0  0  0  0  0
          @@ -90,7 +90,7 @@
            0.0  0.0   0.0       0.0  1.0   0.0  0.0
            0.0  0.0   0.333333  0.0  0.0   0.5 0.166667
            1.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
          source
          MarkovWeightedEFMs.CHMC.Standard.reshape_efm_matrixFunction
          reshape_efm_matrix(ϕ::Matrix{Int64}, S::Matrix{<:Real})

          Convert a matrix of EFMs ϕ to a nested vector of EFMs from a stoichiometry matrix S. Stoichiometry matrix may only contain unimolecular reactions.

          ϕ is the n by k EFM matrix with n reactions (rows) and k EFMs (cols).

          S is the m by n stoichiometry matrix with m metabolites (rows) and n reactions (cols).

          Examples

          julia> ϕ = [#
          + 0.0  0.0   0.0       0.0  1.0   0.0  0.0
          source
          MarkovWeightedEFMs.CHMC.Standard.reshape_efm_matrixFunction
          reshape_efm_matrix(ϕ::Matrix{Int64}, S::Matrix{<:Real})

          Convert a matrix of EFMs ϕ to a nested vector of EFMs from a stoichiometry matrix S. Stoichiometry matrix may only contain unimolecular reactions.

          ϕ is the n by k EFM matrix with n reactions (rows) and k EFMs (cols).

          S is the m by n stoichiometry matrix with m metabolites (rows) and n reactions (cols).

          Examples

          julia> ϕ = [#
             1  1  0  0  0  0
             1  0  1  0  0  0
             0  0  1  0  0  1
          @@ -119,7 +119,7 @@
            [2, 3, 2]
            [3, 5, 3]
            [5, 7, 5]
          - [3, 2, 4, 5, 3]
          source
          MarkovWeightedEFMs.CHMC.Standard.reshape_efm_vectorFunction
          reshape_efm_vector(ϕ::Vector{Vector{Int64}}, S::Matrix{<:Real})

          Convert nested vector of EFM indices ϕ with length k to an n by k matrix of EFMs based on m by n stoichiometry matrix S. Stoichiometry matrix may only contain unimolecular reactions.

          ϕ is the nested vector of EFMs with length k and elements corresponding to EFM metabolite indices in S.

          S is the m by n stoichiometry matrix with m metabolites (rows) and n reactions (cols).

          Examples

          julia> ϕ = [#
          + [3, 2, 4, 5, 3]
          source
          MarkovWeightedEFMs.CHMC.Standard.reshape_efm_vectorFunction
          reshape_efm_vector(ϕ::Vector{Vector{Int64}}, S::Matrix{<:Real})

          Convert nested vector of EFM indices ϕ with length k to an n by k matrix of EFMs based on m by n stoichiometry matrix S. Stoichiometry matrix may only contain unimolecular reactions.

          ϕ is the nested vector of EFMs with length k and elements corresponding to EFM metabolite indices in S.

          S is the m by n stoichiometry matrix with m metabolites (rows) and n reactions (cols).

          Examples

          julia> ϕ = [#
             [1, 2, 3, 5, 6, 1],
             [1, 2, 4, 5, 6, 1],
             [2, 3, 2], [3, 5, 3], [5, 7, 5], [2, 4, 5, 3, 2]
          @@ -145,4 +145,4 @@
            1  1  0  0  0  0
            0  0  0  0  1  0
            0  0  0  0  1  0
          - 1  1  0  0  0  0
          source

          Index

          + 1 1 0 0 0 0
          source

          Index

          diff --git a/docs/build/objects.inv b/docs/build/objects.inv index f936d08..3bed5a4 100644 Binary files a/docs/build/objects.inv and b/docs/build/objects.inv differ diff --git a/docs/build/search_index.js b/docs/build/search_index.js index 5040280..245f2de 100644 --- a/docs/build/search_index.js +++ b/docs/build/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"library/chmc-plots-standard/#Plotting-(CHMC)","page":"Plotting (CHMC)","title":"Plotting (CHMC)","text":"","category":"section"},{"location":"library/chmc-plots-standard/#CHMC","page":"Plotting (CHMC)","title":"CHMC","text":"","category":"section"},{"location":"library/chmc-plots-standard/","page":"Plotting (CHMC)","title":"Plotting (CHMC)","text":"plot_chmc","category":"page"},{"location":"library/chmc-plots-standard/#MarkovWeightedEFMs.Plots.plot_chmc","page":"Plotting (CHMC)","title":"MarkovWeightedEFMs.Plots.plot_chmc","text":"function plot_chmc(#\n T::Matrix{<:Real},\n I::Int64=1;\n node_label_textsize::Real=15,\n edge_label_textsize::Real=12,\n arrow_shift::Real=0.85,\n x_pad::Real=0.75,\n y_pad::Real=0.75,\n tfactor::Real=0.15,\n tangents::Tuple{#\n Tuple{<:Real, <:Real},\n Tuple{<:Real, <:Real}\n } = ((1,0),(0,1)),\n show_all::Bool=false\n\n)\n\nPlot cycle-history Markov chain from transition probability matrix T rooted on state/node I.\n\nT is a right stochastic transition probability matrix with rows summing to one.\n\nI is a state in 1:size(T,1).\n\nnode_label_textsize is the text size of the node labels indexed from T.\n\nedge_label_textsize is the text size of the edge labels taken from T.\n\narrow_shift is the percentage shift of the arrow head from src to dst.\n\nx_pad is the left/right x coordinate padding of the plotting box.\n\ny_pad is the up/down y coordinate padding of the plotting box.\n\ntfactor scales the distance of the bezier control point relative to the distance of the src and dst nodes.\n\ntangents is the tangent of the src vertex and dst vertex.\n\nshow_all=true explicitly plots the upstream transition from all EFMs that pass through the initial state/node I. By default, these arrows stemming from the green nodes are omitted for visual clarity.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-plots-standard/#Index","page":"Plotting (CHMC)","title":"Index","text":"","category":"section"},{"location":"library/chmc-plots-standard/","page":"Plotting (CHMC)","title":"Plotting (CHMC)","text":"Pages = [\"chmc-plots.md\"]","category":"page"},{"location":"installation/installation/#Getting-started","page":"Getting started","title":"Getting started","text":"","category":"section"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"To install this package, open a julia session and enter:","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"julia> ]\n(@v1.10) pkg> add https://github.com/jchitpin/MarkovWeightedEFMs.jl.git","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"Alternatively, you can load Pkg and install by:","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"julia> using Pkg\njulia> Pkg.add(\"https://github.com/jchitpin/MarkovWeightedEFMs.jl.git\")","category":"page"},{"location":"installation/installation/#Python-dependencies-for-AEFM-analysis","page":"Getting started","title":"Python dependencies for AEFM analysis","text":"","category":"section"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"AEFM-specific analyses depend on the atom mapping program RXNMapper. This package must be installed and built with PyCall.jl after installing MarkovWeightedEFMs.jl. Tested to work with python version 3.10 and 3.11","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"This can be done by creating a python virtual environment, installing RXNMapper, and setting the PYTHON environment variable to the python executable in the virtual environment.","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"$ pip install virtualenv\n$ virtualenv --python=\"/usr/bin/python3.10\" \"virtualenv\" # name of virtual environment\n$ source virtualenv/bin/activate\n(virtualenv) $ pip install rxnmapper\n(virtualenv) $ pip install rdkit\n(virtualenv) $ pip install requests\n(virtualenv) $ pip install tdqm\n(virtualenv) $ pip install bs4\n(virtualenv) $ pip install CTSgetPy\n(virtualenv) $ julia","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"julia> using Pkg, PyCall\njulia> ENV[\"PYTHON\"] = joinpath(ENV[\"VIRTUAL_ENV\"], \"bin\", \"python\")\njulia> Pkg.build(\"PyCall\")","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"Note PyCall.jl will need to be rebuilt whenever you update your Julia version. See PyCall.jl documentation for more options on setting up Python in Julia.","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"See Exact Python dependencies for RXNMapper for more information.","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#CHMC-(ion-channels)","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"This section demonstrates how to use the functions in MarkovWeightedEFMs.jl to analyze the steady state dynamics of the following ion channel with three possible binding sites reproduced from (Bicknell and Goodhill)[https://doi.org/10.1073/pnas.1604090113].","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"(Image: Markov chain model of IP3 receptor from Bicknell and Goodhill (https://doi.org/10.1073/pnas.1604090113))","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"using MarkovWeightedEFMs","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#Markov-state-model-of-IP3-channel-activity","page":"CHMC (ion channels)","title":"Markov state model of IP3 channel activity","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/#Rate-constants","page":"CHMC (ion channels)","title":"Rate constants","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"using MarkovWeightedEFMs\n\n# Parameters\nc = 0.1 # Ca2+ (uM)\nI = 0.1 # IP3 (uM)\na1 = 50\na2 = 0.035\na4 = 3.5\na5 = 65\na6 = 25\na7 = 10\na8 = 0.035\na9 = 0.15\na10 = 1.25\na11 = 110\nb1 = 2.5\nb2 = 1.25\nb3 = 0.25\nb4 = 12.5\nb5 = 10\nb7 = 0.25\nb9 = 0.2\nb10 = 2.5\nb11 = 20\nK1 = b1 / a1\nK2 = b2 / a2\nK4 = b4 / a4\nK5 = b5 / a5\nK7 = b7 / a7\nK9 = b9 / a9\nK10 = b10 / a10\na3 = (b3 * K4) / (K1 * K2)\nb6 = (a6 * K5 * K7) / K1\nb8 = (a8 * K2 * K10) / K9\nnothing # hide","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#Generator-and-transition-matrix","page":"CHMC (ion channels)","title":"Generator and transition matrix","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"# Markov transition rate matrix\nQ = [#\n 0 c*a6 0 I*a7 0 0 0 0 0 0\n b6 0 c*a4 0 I*a1 0 0 0 0 0\n 0 b4 0 0 0 I*a3 0 0 0 0\n b7 0 0 0 c*a5 0 a9 0 0 0\n 0 b1 0 b5 0 c*a2 0 a9 0 a11\n 0 0 b3 0 b2 0 0 0 a10 0\n 0 0 0 b9 0 0 0 c*a5 0 0\n 0 0 0 0 b9 0 b5 0 c*a8 0\n 0 0 0 0 0 b10 0 b8 0 0\n 0 0 0 0 b11 0 0 0 0 0\n];\n\n# Markov transition probability matrix\nT = Q ./ sum(Q, dims=2)","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#Enumerating-EFMs-and-computing-their-probabilities","page":"CHMC (ion channels)","title":"Enumerating EFMs and computing their probabilities","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"The Markov state model contains 39 EFMs. If one were to simulate trajectories from this model for an infinite period of time and decompose these trajectories into simple cycles, the resulting frequencies would converge on the following EFM probabilities. For example, the active-inactive-active transition involving states 10-5-10 occurs ~83.8% of the time on average in this model.","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"res = steady_state_efm_distribution(T);\n\n# EFMs/simple cycles and their corresponding probabilities\nreduce(hcat, [res.e, res.p])","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#Visualizing-the-CHMC","page":"CHMC (ion channels)","title":"Visualizing the CHMC","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"The blue node represents state 1 and is the root of the tree. All green nodes return back to the blue node but these arrows are hidden to limit visual clutter.","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"using GLMakie\nGLMakie.activate!()\nplot_chmc(T, 1) # arbitrarily rooted on state 1","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"(Image: )","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#CHMC-(metabolic-networks)","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"This section demonstrates how to use the functions in MarkovWeightedEFMs.jl to analyze the following unimolecular reaction network.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"(Image: Example unimolecular reaction network)","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"using MarkovWeightedEFMs","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#Problem-statement","page":"CHMC (metabolic networks)","title":"Problem statement","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"Given the metabolic network above, its steady state fluxes, and its elementary flux modes (EFMs), what is the set of EFM weights that reconstructs the observed network fluxes?","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#Inputs","page":"CHMC (metabolic networks)","title":"Inputs","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"For this type of problem, we require the following:","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"Stoichiometry matrix of unimolecular reactions (must be unimolecular and strongly-connected; either open or closed loop)\nSteady state fluxes along each reaction.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The network metabolites and reactions are typically encoded in an m by r stoichiometry matrix S. The steady state flux vector is stored as a separate vector.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"using MarkovWeightedEFMs # load package\n\n# Stoichiometry matrix and flux vector for the example network\nS = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 -1 1 0\n 0 0 0 0 0 0 0 1 0 0 -1\n 0 0 0 0 0 0 0 0 1 -1 0\n]\nv = [3, 2, 1, 2, 3, 2, 2, 3, 1, 1, 3]\nnothing # hide","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"We can check that the flux vector satisfies the steady state requirements.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"all(S * v .== 0) # should evaluate as true","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#Solving-for-EFM-sequences,-probabilities,-and-weights","page":"CHMC (metabolic networks)","title":"Solving for EFM sequences, probabilities, and weights","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The following function applies our (discrete-time) cycle-history Markov chain (CHMC) method to compute the network EFMs, their steady state EFM probabilities, and weights. By default, the last parameter is 1 and can be omitted from the function. This parameter is the (arbitrary) initial state to root the CHMC. The choice of root state does not change the EFM probabilities or weights and is explained further in the section below.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"res = steady_state_efm_distribution(S, v, 1)","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The enumerated EFM sequences are","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"res.e","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The corresponding EFM probabilities are","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"res.p","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The corresponding EFM weights are","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"res.w","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"We can check that the EFM weights reconstruct the observed network fluxes","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"E = reshape_efm_vector(res.e, S) # matrix of EFM weights\nE * res.w ≈ v # passes","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"A binary EFM matrix with rows = # reactions and columns = # EFMs can be converted back to the array of EFM sequences by","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"reshape_efm_matrix(E, S)","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#Visualizing-the-CHMC","page":"CHMC (metabolic networks)","title":"Visualizing the CHMC","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The following plotting function visualizes the CHMC rooted on a metabolite state (1 by default).","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"using GLMakie # Makie backend\nGLMakie.activate!()\nT = stoichiometry_to_transition_matrix(S, v)\nplot_chmc(T, 1) # the last parameter is the rooted metabolite index","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"(Image: )","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"If using the GLMakie backend, ensure OpenGL is installed on your machine and accessible by Julia. The GLMakie plot is interactive and allows users to drag nodes and zoom in/out. Otherwise, you could choose another backend such as CairoMakie to generate and save a static plot. A prettier, hand-coded version of the transformed network is shown below.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The blue node is the root of the tree and the green nodes indicate that there is an edge back up to the root. By default, these arrows are omitted to avoid cluttering the plot.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"(Image: )","category":"page"},{"location":"library/chmc-atomic/#Atomic-CHMC","page":"Atomic CHMC","title":"Atomic CHMC","text":"","category":"section"},{"location":"library/chmc-atomic/#Public-functions","page":"Atomic CHMC","title":"Public functions","text":"","category":"section"},{"location":"library/chmc-atomic/","page":"Atomic CHMC","title":"Atomic CHMC","text":"canonicalize_smiles\nfind_atomic_chmc_input_errors\ncorrect_atomic_chmc_input_errors\nprint(res::CHMCAtomicErrorSummary)\ncorrect_atomic_chmc_input_smiles\nexchange_atomic_chmc_input_metabolites\nget_source_metabolites\nget_max_atoms\nmap_reaction_strings\nprecompute_atom_tracing_dictionary\nMarkovWeightedEFMs.CHMC.Atomic.steady_state_efm_distribution(#\n S::Matrix{<:Integer},\n v::Vector{<:Real},\n ms::Vector{String},\n I::Tuple{Int64,Int64,Symbol};\n D::Dict{#\n NTuple{4,Int64},\n Tuple{Int64,Int64}\n }=Dict{NTuple{4,Int64}, Tuple{Int64,Int64}}(),\n tmp_dir::String=\"\"\n)\nget_efm_metabolite_atom_indices\nget_efm_reaction_atom_indices\nchmc_to_mc_matrix\nexport_atom_tracing_dictionary\nimport_atom_tracing_dictionary","category":"page"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.canonicalize_smiles","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.canonicalize_smiles","text":"canonicalize_smiles(m::Vector{String})\n\nCanonicalize input SMILES string m for RXNMapper mapping.\n\n\n\n\n\ncanonicalize_smiles(m::String)\n\nCanonicalize input SMILES string m for RXNMapper mapping.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.find_atomic_chmc_input_errors","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.find_atomic_chmc_input_errors","text":"find_atomic_chmc_input_errors(S::Matrix{<:Real}, v::Vector{<:Real})\n\nPerforms a series of checks on stoichiometry matrix S and steady state flux vector v to determine whether they meet the atomic CHMC requirements. Returns an CHMCAtomicErrorSummary structure that can be printed via print(res::CHMCAtomicErrorSummary).\n\n\n\n\n\nfind_atomic_chmc_input_errors(S::Matrix{<:Real})\n\nPerforms a series of checks on stoichiometry matrix S to determine whether they meet the atomic CHMC requirements for atomic EFM enumeration. Returns an CHMCAtomicErrorSummary structure that can be printed via print(res::CHMCAtomicErrorSummary).\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_errors","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_errors","text":"correct_atomic_chmc_input_errors(#\n res::CHMCAtomicErrorSummary,\n S::Matrix{<:Real},\n v::Vector{<:Real},\n mets::Vector{String},\n rxns::Vector{String}\n)\n\nCorrects all errors identified by find_atomic_chmc_input_errors except for the steady state flux requirement. Returns a corrected version of each input.\n\nS is the m by n stoichiometry matrix. v is the steady state flux vector of length n. mets is the vector of metabolite names of length m. rxns is the vector of reaction names of length n.\n\n\n\n\n\ncorrect_atomic_chmc_input_errors(#\n res::CHMCAtomicErrorSummary,\n S::Matrix{<:Real},\n mets::Vector{String},\n rxns::Vector{String}\n)\n\nCorrects all errors identified by find_atomic_chmc_input_errors except for the steady state flux requirement. Returns a corrected version of each input.\n\nS is the m by n stoichiometry matrix. mets is the vector of metabolite names of length m. rxns is the vector of reaction names of length n.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#Base.print-Tuple{CHMCAtomicErrorSummary}","page":"Atomic CHMC","title":"Base.print","text":"print(res::CHMCAtomicErrorSummary)\n\nWrite CHMCAtomicErrorSummary to stdout.\n\n\n\n\n\n","category":"method"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_smiles","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_smiles","text":"correct_atomic_chmc_input_smiles(#\n S::Matrix{<:Real},\n v::Vector{<:Real},\n mets::Vector{String},\n rxns::Vector{String},\n smiles::Vector{String},\n H::Bool=false\n)\n\nUpdates the inputs by (1) removing pseudometabolites and (2) reactions whose reaction strings exceed the RXNMapper character limit. Pseudometabolites are defined as either metabolites with no defined chemical structure/SMILES representation, or metabolites whose SMILES strings contain symbols absent from the periodic table (including metabolites with an R-group). Reactions that exceed the RXNMapper character limit are converted into unimolecular sources and sinks to maintain steady state flux. Returns the corrected inputs with a list of removed metabolites/reactions.\n\nS is the m by n stoichiometry matrix.\n\nv is the steady state flux vector of length n.\n\nmets is the vector of metabolite names of length m.\n\nrxns is the vector of reaction names of length n.\n\nsmiles is the vector of metabolite smiles matching mets.\n\nH = false will not check for hydrogen conservation in each reaction.\n\n\n\n\n\ncorrect_atomic_chmc_input_smiles(#\n S::Matrix{<:Real},\n mets::Vector{String},\n rxns::Vector{String},\n smiles::Vector{String},\n H::Bool=false\n)\n\nUpdates the inputs by (1) removing pseudometabolites and (2) reactions whose reaction strings exceed the RXNMapper character limit. Pseudometabolites are defined as either metabolites with no defined chemical structure/SMILES representation, or metabolites whose SMILES strings contain symbols absent from the periodic table (including metabolites with an R-group). Reactions that exceed the RXNMapper character limit are converted into unimolecular sources and sinks to maintain steady state flux. Returns the corrected inputs with a list of removed metabolites/reactions.\n\nS is the m by n stoichiometry matrix.\n\nmets is the vector of metabolite names of length m.\n\nrxns is the vector of reaction names of length n.\n\nsmiles is the vector of metabolite smiles matching mets.\n\nH = false will not check for hydrogen conservation in each reaction.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.exchange_atomic_chmc_input_metabolites","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.exchange_atomic_chmc_input_metabolites","text":"exchange_atomic_chmc_input_metabolites(#\n S::Matrix{<:Real},\n v::Vector{<:Real},\n mets::Vector{String},\n rxns::Vector{String},\n smiles::Vector{String},\n ii::Vector{Int64}\n)\n\nRemoves internal metabolites ii from the remaining inputs by converting each metabolite i ∈ ii into a pair of sink and source metabolites. Returns an updated copy of inputs S, v, mets, rxns, and smiles.\n\nS is the m by n stoichiometry matrix.\n\nv is the steady state flux vector of length n.\n\nmets is the vector of metabolite names of length m.\n\nrxns is the vector of reaction names of length n.\n\nsmiles is the vector of metabolite smiles matching mets.\n\nii is the vector of metabolite indices to exchange for pairs of sinks/sources.\n\n\n\n\n\nexchange_atomic_chmc_input_metabolites(#\n S::Matrix{<:Real},\n mets::Vector{String},\n rxns::Vector{String},\n smiles::Vector{String},\n ii::Vector{Int64}\n)\n\nRemoves internal metabolites ii from the remaining inputs by converting each metabolite i ∈ ii into a pair of sink and source metabolites. Returns an updated copy of inputs S, mets, rxns, and smiles.\n\nS is the m by n stoichiometry matrix.\n\nmets is the vector of metabolite names of length m.\n\nrxns is the vector of reaction names of length n.\n\nsmiles is the vector of metabolite smiles matching mets.\n\nii is the vector of metabolite indices to exchange for pairs of sinks/sources.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.get_source_metabolites","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.get_source_metabolites","text":"get_source_metabolites(S::Matrix{Int16})\n\nReturns a vector of all source metabolites in stoichiometry matrix S.\n\nS is the m by n stoichiometry matrix.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.get_max_atoms","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.get_max_atoms","text":"get_max_atoms(s::Vector{String}, a::Symbol)\n\nReturns the maximum number of atoms of type a for each SMILES string in s. Returns a vector of all source metabolites in stoichiometry matrix S.\n\ns is the vector of metabolite SMILES strings.\n\na is a periodic table element symbol.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.map_reaction_strings","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.map_reaction_strings","text":"map_reaction_strings(#\n S::Matrix{<:Real},\n smiles::Vector{String},\n rxns::Vector{String},\n H::Bool=false\n)\n\nConstructs reaction strings from the smiles and then returns the atom-mapped reaction strings via RXNMapper.\n\nS is the stoichiometry matrix.\n\nsmiles is the vector of SMILES strings for metabolites in S.\n\nrxns is the vector of reaction names in S.\n\nH = false will not check for hydrogen conservation in each reaction.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.precompute_atom_tracing_dictionary","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.precompute_atom_tracing_dictionary","text":"precompute_atom_tracing_dictionary(#\n S::Matrix{Int16},\n ms::Vector{String},\n amax::Vector{Int64},\n a::Symbol\n)\n\nPrecomputes a dictionary mapping each atom in a given substrate stoichiometric copy to its product atom across every reaction. The dictionary is used in steady_state_efm_distribution.\n\nS is the stoichiometry matrix.\n\nms is the vector of mapped reaction SMILES strings.\n\namax is the total number of atom a in each metabolite row of S.\n\na is a periodic table element symbol.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution-Tuple{Matrix{<:Integer}, Vector{<:Real}, Vector{String}, Tuple{Int64, Int64, Symbol}}","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution","text":"steady_state_efm_distribution(#\n S::Matrix{<:Integer},\n v::Vector{<:Real},\n ms::Vector{String},\n I::Tuple{Int64,Int64,Symbol},\n D::Dict{#\n NTuple{4,Int64},\n Tuple{Int64,Int64}\n } = Dict{NTuple{4,Int64}, Tuple{Int64,Int64}}();\n solver = nothing,\n verbose::Bool = true\n)\n\nEnumerates the atomic EFMs from stoichiometry matrix S and compute the steady state probabilities of each EFM according to the discrete-time, cycle-history Markov chain.\n\nS is a fully-connected, unimolecular, m by n stoichiometry matrix with m metabolites and n reactions.\n\nv is the n-length steady state flux vector associated with S.\n\nms is the vector of mapped reaction SMILES strings.\n\nI is a triplet of the metabolite row index in S, the atom index, and the atom index type. It is the initial starting state for rooting the cycle-history Markov chain.\n\nD is the precomputed dictionary from precompute_atom_tracing_dictionary.\n\nsolver is the type used for eigenvector calculations. Default is nothing and LinearSolve will pick the best solver. Consult LinearSolve.jl for specifying other solvers.\n\n\n\n\n\n","category":"method"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.get_efm_metabolite_atom_indices","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.get_efm_metabolite_atom_indices","text":"get_efm_metabolite_atom_indices(res::CHMCAtomicSummary, i::Int64)\n\nConverts the sequence of metabolite indices for atomic EFM index i into metabolite names. The length of the vector of metabolite names is one element shorter than res.e[i] because the pseudometabolite connecting sink and source reactions is omitted.\n\nres are the results from steady_state_efm_distribution.\n\ni is the index for a given EFM.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.get_efm_reaction_atom_indices","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.get_efm_reaction_atom_indices","text":"get_efm_reaction_indices(res::CHMCAtomicSummary, i::Int64)\n\nConverts the sequence of metabolite indices for atomic EFM index i into reaction names. \n\nres are the results from steady_state_efm_distribution.\n\ni is the index for a given EFM.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.chmc_to_mc_matrix","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.chmc_to_mc_matrix","text":"chmc_to_mc_matrix(res::CHMCAtomicSummary, v::Vector{<:Real})\n\nConverts CHMC transition matrix res.T to a Markov chain with probabilities taken from steady state flux vector v.\n\nres are the results from steady_state_efm_distribution.\n\nv is the steady state flux vector used as input from steady_state_efm_distribution.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.export_atom_tracing_dictionary","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.export_atom_tracing_dictionary","text":"export_atom_tracing_dictionary(#\n fname::String,\n D::Dict{NTuple{4, Int64}, Tuple{Int64, Int64}}\n)\n\nExport atom tracing dictionary D to text file fname.\n\nfname is the filename to write the atom tracing dictionary results.\n\nD is the dictionary from precompute_atom_tracing_dictionary.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.import_atom_tracing_dictionary","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.import_atom_tracing_dictionary","text":"import_atom_tracing_dictionary(fname::String)\n\nImport atomic tracing dictionary from text file fname.\n\nfname is the filename containing the atom tracing dictionary results.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#Index","page":"Atomic CHMC","title":"Index","text":"","category":"section"},{"location":"library/chmc-atomic/","page":"Atomic CHMC","title":"Atomic CHMC","text":"Pages = [\"chmc-atomic.md\"]","category":"page"},{"location":"library/chmc-plots-atomic/#Plotting-(ACHMC)","page":"Plotting (ACHMC)","title":"Plotting (ACHMC)","text":"","category":"section"},{"location":"library/chmc-plots-atomic/#Atomic-CHMC","page":"Plotting (ACHMC)","title":"Atomic CHMC","text":"","category":"section"},{"location":"library/chmc-plots-atomic/","page":"Plotting (ACHMC)","title":"Plotting (ACHMC)","text":"plot_mapped_reaction\nplot_atomic_chmc","category":"page"},{"location":"library/chmc-plots-atomic/#MarkovWeightedEFMs.Plots.plot_mapped_reaction","page":"Plotting (ACHMC)","title":"MarkovWeightedEFMs.Plots.plot_mapped_reaction","text":"function plot_mapped_reaction(#\n s::String,\n fname::String = \"\";\n view::Bool = false,\n canvas_width::Int64 = 3000,\n canvas_height::Int64 = 1000\n\n)\n\nPlot mapped reaction SMILES string s as an SVG and save to fname if specified.\n\ncanvas_width is the width of the SVG.\n\ncanvas_height is the height of the SVG.\n\nview = true will plot the SVG assuming a plotting backend is specified. For example, loading the ElectronDisplay package will plot the SVG to an Electron window.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-plots-atomic/#MarkovWeightedEFMs.Plots.plot_atomic_chmc","page":"Plotting (ACHMC)","title":"MarkovWeightedEFMs.Plots.plot_atomic_chmc","text":"function plot_atomic_chmc(#\n res::CHMCAtomicSummary,\n S::Matrix{Int16},\n mets::Vector{String},\n rs::Vector{String};\n node_label_textsize::Real=15,\n edge_label_textsize::Real=12,\n arrow_shift::Real=0.85,\n x_pad::Real=0.75,\n y_pad::Real=0.75,\n tfactor::Real=0.15,\n tangents::Tuple{#\n Tuple{<:Real, <:Real},\n Tuple{<:Real, <:Real}\n } = ((1,0),(0,1)),\n show_all::Bool=false,\n width::Int64=620,\n height::Int64=310\n\n)\n\nPlot atomic cycle-history Markov chain.\n\nS is the m by n stoichiometry matrix.\n\nmets is the vector of metabolite names of length m.\n\nrs is the vector of reaction SMILES strings of length n.\n\nnode_label_textsize is the text size of the node labels indexed from T.\n\nedge_label_textsize is the text size of the edge labels taken from T.\n\narrow_shift is the percentage shift of the arrow head from src to dst.\n\nx_pad is the left/right x coordinate padding of the plotting box.\n\ny_pad is the up/down y coordinate padding of the plotting box.\n\ntfactor scales the distance of the bezier control point relative to the distance of the src and dst nodes.\n\ntangents is the tangent of the src vertex and dst vertex.\n\nshow_all=true explicitly plots the upstream transition from all EFMs that pass through the initial state/node I. By default, these arrows stemming from the green nodes are omitted for visual clarity.\n\nwidth and height specify the plotting window dimensions in pixel units.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-plots-atomic/#Index","page":"Plotting (ACHMC)","title":"Index","text":"","category":"section"},{"location":"library/chmc-plots-atomic/","page":"Plotting (ACHMC)","title":"Plotting (ACHMC)","text":"Pages = [\"chmc-plots.md\"]","category":"page"},{"location":"library/chmc-standard/#CHMC","page":"CHMC","title":"CHMC","text":"","category":"section"},{"location":"library/chmc-standard/#Public-functions","page":"CHMC","title":"Public functions","text":"","category":"section"},{"location":"library/chmc-standard/","page":"CHMC","title":"CHMC","text":"MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution(S::Matrix{<:Integer}, v::Vector{<:Real}, I::Int64=1)\nMarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution(T::Matrix{<:Real}, I::Int64=1)\nstoichiometry_to_transition_matrix\nreshape_efm_matrix\nreshape_efm_vector","category":"page"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution","text":"steady_state_efm_distribution(#\n S::Matrix{<:Integer},\n v::Vector{<:Real},\n I::Int64 = 1;\n solver = nothing,\n issparse::Bool = false\n)\n\nEnumerate the EFMs from stoichiometry matrix S and compute the steady state probabilities of each EFM according to the discrete-time, cycle-history Markov chain.\n\nS is a fully-connected, unimolecular, m by n stoichiometry matrix with m metabolites and n reactions.\n\nv is the n-length steady state flux vector associated with S.\n\nI is the initial starting state for rooting the cycle-history Markov chain. The choice of initial starting state does not affect the steady state EFM probabilities. The default is 1 and must be a whole number between 1:m.\n\nsolver is the type used for eigenvector calculations. Default is nothing and LinearSolve will pick the best solver. Consult LinearSolve.jl for specifying other solvers.\n\nissparse is true will use a sparse transition probability for the CHMC to save memory.\n\nExample\n\njulia> S = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 1 -1 0\n 0 0 0 0 0 0 0 0 0 1 -1\n 0 0 0 0 0 0 0 1 -1 0 0\n];\njulia> v = [3, 2, 1, 2, 3, 2, 2, 1, 1, 3, 3];\njulia> res = steady_state_efm_distribution(S, v);\njulia> res.e # EFM state sequences\n6-element Vector{Vector{Int64}}:\n [3, 2, 3]\n [3, 2, 4, 5, 3]\n [3, 5, 3]\n [6, 1, 2, 4, 5, 6]\n [7, 5, 7]\n [6, 1, 2, 3, 5, 6]\n\njulia> res.p # EFM probabilities\n6-element Vector{Float64}:\n 0.10638297872340426\n 0.0425531914893617\n 0.25531914893617025\n 0.1914893617021277\n 0.14893617021276595\n 0.25531914893617025\n\njulia> res.w # EFM weights\n6-element Vector{Float64}:\n 0.7142857142857142\n 0.2857142857142857\n 1.7142857142857144\n 1.2857142857142858\n 0.9999999999999999\n 1.7142857142857144\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution-2","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution","text":"steady_state_efm_distribution(#\n T::Union{Matrix{<:Real}, SparseMatrixCSC{Float64, Int64}},\n I::Int64 = 1;\n solver = nothing,\n verbose::Bool = true\n)\n\nEnumerate the EFMs from (right) transition probability matrix T whose rows sum to one, and compute the steady state probabilities of each EFM according to the discrete-time, cycle-history Markov chain.\n\nT is the discrete-time transition probability matrix with probabilities proportional to the outgoing fluxes.\n\nI is the initial starting state for rooting the cycle-history Markov chain. The choice of initial starting state does not affect the steady state EFM probabilities. The default is 1 and must be a whole number between 1:m.\n\nsolver is the type used for eigenvector calculations. Default is nothing and LinearSolve will pick the best solver. Consult LinearSolve.jl for specifying other solvers.\n\nExample\n\njulia> T = [#\n 0.0 1.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.5 0.5 0.0 0.0 0.0\n 0.0 0.25 0.0 0.0 0.75 0.0 0.0\n 0.0 0.0 0.0 0.0 1.0 0.0 0.0\n 0.0 0.0 0.333333 0.0 0.0 0.5 0.166667\n 1.0 0.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.0 0.0 1.0 0.0 0.0\n];\njulia> res = steady_state_efm_distribution(T);\njulia> res.e # EFM state sequences\n6-element Vector{Vector{Int64}}:\n [3, 2, 3]\n [3, 2, 4, 5, 3]\n [3, 5, 3]\n [6, 1, 2, 3, 5, 6]\n [7, 5, 7]\n [6, 1, 2, 4, 5, 6]\n\njulia> res.p # EFM probabilities\n6-element Vector{Float64}:\n 0.13723110896294213\n 0.035797649943428565\n 0.26989203316869914\n 0.20302350628312624\n 0.13926980198123254\n 0.2147858996605714\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.stoichiometry_to_transition_matrix","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.stoichiometry_to_transition_matrix","text":"stoichiometry_to_transition_matrix(S::Matrix{<:Integer}, v::Vector{<:Real})\n\nConvert stoichiometry matrix S with vector of steady state fluxes to a right stochastic transition probability matrix with rows summing to one.\n\nS is the m by n stoichiometry matrix with m metabolites and n reactions.\n\nv is the steady state flux vector with length n.\n\nExamples\n\njulia> S = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 -1 1 0\n 0 0 0 0 0 0 0 1 0 0 -1\n 0 0 0 0 0 0 0 0 1 -1 0\n]\njulia> v = [2, 2, 2, 2, 2, 2, 2, 2, 4]\njulia> stoich_to_transition(S, v)\n7x7 Matrix{Float64}:\n 0.0 1.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.5 0.5 0.0 0.0 0.0\n 0.0 0.25 0.0 0.0 0.75 0.0 0.0\n 0.0 0.0 0.0 0.0 1.0 0.0 0.0\n 0.0 0.0 0.333333 0.0 0.0 0.5 0.166667\n 1.0 0.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.0 0.0 1.0 0.0 0.0\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.reshape_efm_matrix","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.reshape_efm_matrix","text":"reshape_efm_matrix(ϕ::Matrix{Int64}, S::Matrix{<:Real})\n\nConvert a matrix of EFMs ϕ to a nested vector of EFMs from a stoichiometry matrix S. Stoichiometry matrix may only contain unimolecular reactions.\n\nϕ is the n by k EFM matrix with n reactions (rows) and k EFMs (cols).\n\nS is the m by n stoichiometry matrix with m metabolites (rows) and n reactions (cols).\n\nExamples\n\njulia> ϕ = [#\n 1 1 0 0 0 0\n 1 0 1 0 0 0\n 0 0 1 0 0 1\n 0 1 0 0 0 1\n 1 0 0 1 0 0\n 0 0 0 1 0 1\n 0 1 0 0 0 1\n 1 1 0 0 0 0\n 0 0 0 0 1 0\n 0 0 0 0 1 0\n 1 1 0 0 0 0\n]\njulia> S = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 -1 1 0\n 0 0 0 0 0 0 0 1 0 0 -1\n 0 0 0 0 0 0 0 0 1 -1 0\n]\njulia> efm_vector = reshape_efm_matrix(ϕ, S)\n6-element Vector{Vector{Int64}}:\n [1, 2, 3, 5, 6, 1]\n [1, 2, 4, 5, 6, 1]\n [2, 3, 2]\n [3, 5, 3]\n [5, 7, 5]\n [3, 2, 4, 5, 3]\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.reshape_efm_vector","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.reshape_efm_vector","text":"reshape_efm_vector(ϕ::Vector{Vector{Int64}}, S::Matrix{<:Real})\n\nConvert nested vector of EFM indices ϕ with length k to an n by k matrix of EFMs based on m by n stoichiometry matrix S. Stoichiometry matrix may only contain unimolecular reactions.\n\nϕ is the nested vector of EFMs with length k and elements corresponding to EFM metabolite indices in S.\n\nS is the m by n stoichiometry matrix with m metabolites (rows) and n reactions (cols).\n\nExamples\n\njulia> ϕ = [#\n [1, 2, 3, 5, 6, 1],\n [1, 2, 4, 5, 6, 1],\n [2, 3, 2], [3, 5, 3], [5, 7, 5], [2, 4, 5, 3, 2]\n]\njulia> S = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 -1 1 0\n 0 0 0 0 0 0 0 1 0 0 -1\n 0 0 0 0 0 0 0 0 1 -1 0\n]\njulia> efm_matrix = reshape_efm_vector(ϕ, S)\n11x6 Matrix{Int64}:\n 1 1 0 0 0 0\n 1 0 1 0 0 0\n 0 0 1 0 0 1\n 0 1 0 0 0 1\n 1 0 0 1 0 0\n 0 0 0 1 0 1\n 0 1 0 0 0 1\n 1 1 0 0 0 0\n 0 0 0 0 1 0\n 0 0 0 0 1 0\n 1 1 0 0 0 0\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#Index","page":"CHMC","title":"Index","text":"","category":"section"},{"location":"library/chmc-standard/","page":"CHMC","title":"CHMC","text":"Pages = [\"chmc-standard.md\"]","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Boilerplate-code-for-ACHMC-analysis-of-BiGG-models","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"The following code is provided to quickly construct ACHMC models of BiGG metabolic models and others stored in the SBML file format. Each code block is designed to be standalone with calculations saved to file and re-loaded in a subsequent code block. Unfortunately, BiGG does not store SMILES strings so these will need to be manually compiled by the user.","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"Note we recommend starting with relatively small networks (<500 metabolites and reactions in the original metabolic model) for computational feasibility.","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Inputs-(from-BiGG)","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Inputs (from BiGG)","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"This section shows how to extract relevant information from a BiGG metabolic model called e_coli_core.xml","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"# Import file names\nim_sbml = \"e_coli_core.xml\"\n\n# Export file names\nex_stoich = \"stoich.csv\"\nex_metabolites_compartments = \"metabolites-compartments.csv\"\nex_reactions = \"reactions.csv\"\nex_formulas = \"metabolite-formulas.csv\"\n\n# Packages\nusing SBML, CSV, Tables\n\n# Load SBML model\nmdl = readSBML(im_sbml)\nmetabolites, reactions, S = stoichiometry_matrix(mdl)\n\n# Dense stoichiometry matrix\nS = Array(S)\n\n# Metabolite names\nmets = [mdl.species[m].name for m in metabolites]\nmets = replace.(mets, \" \" => \"_\")\n\n# Metabolite names concatenated with compartment\nmetsc = [#\n join([mdl.species[m].name, mdl.species[m].compartment], \"_\")\n for m in metabolites\n]\nmetsc = replace.(metsc, \" \" => \"_\")\n\n# Metabolite formulas\nformulas = [mdl.species[m].formula for m in metabolites]\nformulas[isnothing.(formulas)] .= \"\"\n\n# Reaction names\nrxns = [mdl.reactions[r].name for r in reactions]\n\n# Export to text file\nCSV.write(ex_stoich, Tables.table(S), header = false)\nCSV.write(ex_metabolites, Tables.table(mets), header = false)\nCSV.write(ex_metabolites_compartments, Tables.table(metsc), header = false)\nCSV.write(ex_reactions, Tables.table(rxns), header = false)\nCSV.write(ex_formulas, Tables.table(formulas), header = false)","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Pre-processing-inputs-(for-AEFM-enumeration)","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Pre-processing inputs (for AEFM enumeration)","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"This section pre-processes the BiGG inputs to meet the ACHMC requirements.","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"# Import file names\nim_stoich = \"stoich.csv\"\nim_mets = \"metabolites-compartments.csv\"\nim_rxns = \"reactions.csv\"\nim_smiles = \"smiles-isomeric.csv\"\n\n# Export file names\nex_stoich = \"stoichiometry-matrix-processed.csv\"\nex_mets = \"metabolites-processed.csv\"\nex_rxns = \"reactions-processed.csv\"\nex_smiles = \"smiles-isomeric-processed.csv\"\nex_reaction_smiles = \"reaction-smiles-processed.csv\"\nex_mapped_reaction_smiles = \"mapped-reaction-smiles-strings-processed.csv\"\nex_dict_carbon = \"dictionary-atom-tracing-carbon.csv\"\n\n# Packages\nusing CSV, Tables, MarkovWeightedEFMs, BenchmarkTools\n\n## Load previous inputs\n# Stoichiometry matrix\nS = CSV.read(im_stoich, Tables.matrix, header = false)\n\n# Metabolites\nmets = vec(CSV.read(im_mets, Tables.matrix, header = false))\n\n# Reactions\nrxns = String.(vec(CSV.read(im_rxns, Tables.matrix, header = false)))\n\n## Pre-processing\n# (1) Identify problems with S/v inputs\nerrors = find_atomic_chmc_input_errors(S)\nprint(errors) # summary of errors associated with S\n\n# (2) Clean S inputs\nS2, mets2, rxns2 = correct_atomic_chmc_input_errors(errors, S, mets, rxns)\nprint(find_atomic_chmc_input_errors(S2)) # confirm errors have been fixed\n\n# (3) Construct vector of smiles corresponding to the remaining metabolites in S\n# The SMILES strings for pseudometabolites with no defined chemical structure\n# are given an arbitrary SMILES of 'R' (or character that does not represent\n# a periodic table element)\n# SMILES strings matching S2\nsmiles3 = vec(CSV.read(im_smiles, Tables.matrix, header = false))\n\n# (4) Remove pseudometabolites and reactions exceeding RXNMapper character limit\nS4, mets4, rxns4, smiles4, i4 = correct_atomic_chmc_input_smiles(#\n S2, mets2, rxns2, smiles3\n)\ni4.dropped_rows_pseudometabolites # pseudometabolite rows removed from S2\ni4.dropped_cols_pseudometabolites # pseudometabolite reactions removed from S2\ni4.dropped_cols_rxnmapper_limit # reactions in S2 removed bc of RXNMapper limit\nprint(find_atomic_chmc_input_errors(S4)) # confirm no errors\n\n# (5) Construct the reaction strings and map atoms via RXNMAPPER\nsmiles5 = canonicalize_smiles(smiles4) # smiles strings must be canonicalized!\nrs5, ms5 = map_reaction_strings(S4, smiles5, rxns4, false)\n\n# (6) Precompute atom tracing dictionary (for carbons)\namax = get_max_atoms(smiles5, :C)\nD_C = precompute_atom_tracing_dictionary(S4, ms5, amax, :C)\n\n# Export to text file\nCSV.write(ex_stoich, Tables.table(S4), header = false)\nCSV.write(ex_mets, Tables.table(mets4), header = false)\nCSV.write(ex_rxns, Tables.table(rxns4), header = false, quotestrings = true)\nCSV.write(ex_smiles, Tables.table(smiles5), header = false)\nCSV.write(ex_reaction_smiles, Tables.table(rs5), header = false)\nCSV.write(ex_mapped_reaction_smiles, Tables.table(ms5), header = false)\nCSV.write(ex_dict_carbon, D_C, header = false)","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Pre-processing-inputs-(for-AEFM-weight-assignment)","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Pre-processing inputs (for AEFM weight assignment)","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"Assuming there is a steady state flux vector v, the pre-processing steps are slightly different:","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"## Pre-processing\n# (1) Identify problems with S/v inputs\nerrors = find_atomic_chmc_input_errors(S, v)\nprint(errors) # summary of errors associated with S/v\n\n# (2) Clean S/v inputs\nS2, v2, mets2, rxns2 = correct_atomic_chmc_input_errors(errors, S, v, mets, rxns)\nprint(find_atomic_chmc_input_errors(S2, v2)) # confirm errors have been fixed\n\n# (3) Construct vector of smiles corresponding to the remaining metabolites in S\nsmiles3 = vec(CSV.read(im_smiles, Tables.matrix, header = false))\n\n# (4) Remove pseudometabolites and reactions exceeding RXNMapper character limit\nS4, v4, mets4, rxns4, smiles4, i4 = correct_atomic_chmc_input_smiles(#\n S2, v2, mets2, rxns2, smiles3\n)\ni4.dropped_rows_pseudometabolites # 33 pseudometabolite rows removed from S2\ni4.dropped_cols_pseudometabolites # 46 pseudometabolite reactions removed from S2\ni4.dropped_cols_rxnmapper_limit # 3 reactions in S2 removed bc of RXNMapper limit\nprint(find_atomic_chmc_input_errors(S4, v4)) # confirm no errors\n\n# (5) Construct the reaction strings and map atoms via RXNMAPPER\nsmiles5 = canonicalize_smiles(smiles4) # smiles strings must be canonicalized!\nrs5, ms5 = map_reaction_strings(S4, smiles5, rxns, false)\n\n# (6) Precompute atom tracing dictionary (for carbons)\namax = get_max_atoms(smiles5, :C)\nD_C = precompute_atom_tracing_dictionary(S4, ms5, amax, :C)","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Enumerating-AEFMs-across-all-source-metabolite-carbons","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Enumerating AEFMs across all source metabolite carbons","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"# Verbosity of AEFM enumeration function (provides a progress meter)\nverbose = true\n\n# File names\nstoich_loc = \"stoichiometry-matrix-processed.csv\"\nsmiles_loc = \"smiles-isomeric-processed.csv\"\nmets_loc = \"metabolites-processed.csv\"\nD_C_loc = \"dictionary-atom-tracing-carbon.csv\"\nD_N_loc = \"dictionary-atom-tracing-nitrogen.csv\"\nms_loc = \"mapped-reaction-smiles-strings-processed.csv\"\nrxns_loc = \"reactions-processed.csv\"\n\n# Packages\nusing CSV, Tables, MarkovWeightedEFMs, JLD2, Dates\n\n## Load final data\n# Load stoichiometry matrix\nS = Int16.(CSV.read(stoich_loc, Tables.matrix, header = false))\n\n# Load SMILES strings matching the stoichiometry rows\nsmiles = vec(CSV.read(smiles_loc, Tables.matrix, header = false))\n\n# Load metabolites\nmets = vec(CSV.read(mets_loc, Tables.matrix, header = false))\n\n# Load atom tracing dictionary\nD_C = import_atom_tracing_dictionary(D_C_loc)\n\n# Load mapped reaction smiles strings\nms = vec(CSV.read(#\n ms_loc, Tables.matrix, delim = ';', ignoreemptyrows = false, header = false\n))\ng(x) = ismissing(x) ? \"\" : x\nms = g.(ms)\n\n# Load reactions\nrxns = String.(vec(CSV.read(rxns_loc, Tables.matrix, header = false)))\n\n## Enumerate atomic efms\n# Identify indices of all source metabolites and number of carbons/nitrogens\nsrcs = get_source_metabolites(Int16.(S))\namax_C = get_max_atoms(smiles, :C)\n\nstart_time = Dates.now()\nfor k in eachindex(srcs)\n res_dir = \"$k-\" * mets[srcs[k]]\n isdir(res_dir) || mkdir(res_dir)\n for l in 1:amax_C[srcs[k]]\n I = (srcs[k], l, :C)\n res = enumerate_atomic_efms(S, ms, I, D_C; verbose = verbose)\n end\nend\nend_time = Dates.now()\nttime = end_time - start_time\n\n@info \"It took $ttime to enumerate all carbon AEFMs.\"","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Computing-AEFM-weights-across-all-source-metabolite-carbons","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Computing AEFM weights across all source metabolite carbons","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"Decomposing fluxes onto AEFMs uses the function steady_state_efm_distribution() requires the steady state fluxes v:","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"for k in eachindex(srcs)\n res_dir = \"$k-\" * mets[srcs[k]]\n isdir(res_dir) || mkdir(res_dir)\n for l in 1:amax_C[srcs[k]]\n I = (srcs[k], l, :C)\n res = steady_state_efm_distribution(S, v, ms, I, D_C; verbose = verbose)\n end\nend","category":"page"},{"location":"#MarkovWeightedEFMs.jl","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"MarkovWeightedEFMs.jl is a package to decompose steady state metabolic fluxes onto elementary flux mode (EFM) weights and atomic elementary flux mode (AEFM) weights. EFM flux decomposition works only for closed-loop networks of unimolecular reactions. AEFM flux decomposition works on metabolic flux networks with known metabolite structures.","category":"page"},{"location":"#Usage","page":"MarkovWeightedEFMs.jl","title":"Usage","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"See Getting started for package installation and Python dependencies (RXNMapper) for AEFM enumeration and flux decomposition. Once installed, the package is loaded in a julia session by typing:","category":"page"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"julia> using MarkovWeightedEFMs","category":"page"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"See the tutorial sections for EFM or AEFM enumeration and flux decomposition.","category":"page"},{"location":"#Citing-MarkovWeightedEFMs.jl","page":"MarkovWeightedEFMs.jl","title":"Citing MarkovWeightedEFMs.jl","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"Please cite the following papers if you use our method for (A)EFM enumeration and flux decomposition.","category":"page"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"Justin G. Chitpin and Theodore J. Perkins, Atomic elementary flux modes explain the steady state flow of metabolites in flux networks. biorXiv preprint doi: XX.XXXX/XXXX.XX.XX.XXXXXX","category":"page"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"Justin G. Chitpin and Theodore J. Perkins, A Markov constraint to uniquely identify elementary flux mode weights in unimolecular metabolic networks. J Theor Biol. 2023 Nov 7;575:111632. doi: 10.1016/j.jtbi.2023.111632","category":"page"},{"location":"#License","page":"MarkovWeightedEFMs.jl","title":"License","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"This software is released under the MIT license.","category":"page"},{"location":"#Contact-information","page":"MarkovWeightedEFMs.jl","title":"Contact information","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"Justin G. Chitpin at jchit069@uottawa.ca for questions.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#ACHMC-(for-AEFMs)","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"This section shows how to use the functions in MarkovWeightedEFMs.jl to enumerate and assign AEFMs weights in a simple multispecies reaction network.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"(Image: Toy multispecies network)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Inputs","page":"ACHMC (for AEFMs)","title":"Inputs","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"using MarkovWeightedEFMs\nS = [#\n 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # Glc\n 0 -1 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 # ATP\n 0 1 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 # G6P\n 0 1 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 # ADP\n 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 # 6PG\n 0 0 0 0 1 -1 1 0 0 0 0 0 0 0 0 0 # F6P\n 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 # Pi\n 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 # H2O\n 0 0 0 0 0 1 -1 -1 0 0 0 0 0 0 0 0 # FDP\n 0 0 0 0 0 0 0 1 -1 1 -1 0 0 0 0 0 # G3P\n 0 0 0 0 0 0 0 1 1 -1 0 -1 0 0 0 0 # DHAP\n]\n\nv = [10, 10, 3, 3, 7, 8, 1, 7, 1, 1, 7, 7, 18, 18, 1, 1]\n\nmets = [#\n \"Glc\",\n \"ATP\",\n \"G6P\",\n \"ADP\",\n \"6PG\",\n \"F6P\",\n \"Pi\",\n \"H2O\",\n \"FDP\",\n \"G3P\",\n \"DHAP\"\n]\n\nrxns = [#\n \"Source Glc\",\n \"Hexokinase\",\n \"G6P dehydrogenase\",\n \"Sink 6PG\",\n \"Phosphoglucose isomerase\",\n \"6-phosphofructo-1-kinase\",\n \"Fructose 1,6-bisphosphatase\",\n \"Fructose-bisphosphate aldolase\",\n \"Triose phosphate isomerase\",\n \"Triose phosphate isomerase\",\n \"Sink G3P\",\n \"Sink DHAP\",\n \"Source ATP\",\n \"Sink ADP\",\n \"Sink Pi\",\n \"Source H2O\"\n]\n\nsmiles = [#\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)OP(=O)(O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O\",\n \"C([C@H]([C@H]([C@@H](C(=O)CO)O)O)O)OP(=O)(O)O\",\n \"[O-]P(=O)([O-])[O-]\",\n \"O\",\n \"C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O\",\n \"C([C@H](C=O)O)OP(=O)(O)O\",\n \"C(C(=O)COP(=O)(O)O)O\"\n]","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"We can check that the flux vector satisfies the steady state requirements.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"all(S * v .== 0) # should evaluate as true","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Pre-processing-data","page":"ACHMC (for AEFMs)","title":"Pre-processing data","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"The following functions check for issues with the inputs. The first function find_atomic_chmc_input_errors identifies possible problems with the stoichiometry matrix and flux vector. These problems, except for the steady state flux requirement, can be addressed via correct_atomic_chmc_input_errors. Finally, the last function correct_atomic_chmc_input_smiles checks and fixes problems relating to the SMILES strings.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"# Confirm there are no issues with stoichiometry matrix \nerrors = find_atomic_chmc_input_errors(S, v)\nprint(errors) # summary of errors associated with S/v\n\n# S and v have no errors so the inputs are returned\ncorrect_atomic_chmc_input_errors(errors, S, mets, rxns)\n# S, mets, rxns = correct_atomic_chmc_input_errors(errors, S, mets, rxns) # otherwise\n\n# Correct issues associated with RXNMapper character limit and pseudometabolites\nS, v, mets, rxns, smiles, logs = correct_atomic_chmc_input_smiles(S, v, mets, rxns, smiles)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"At this point, the SMILES strings (matching the updated mets if there were errors in the initial inputs) should be canonicalized. S is also converted to a Matrix{Int16} which is a requirement for subsequent functions.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"smiles = canonicalize_smiles(smiles)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Atom-mapping-reactions","page":"ACHMC (for AEFMs)","title":"Atom mapping reactions","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"The reaction SMILES strings are next constructed from the metabolite SMILES and the atom mapping is performed via RXNMapper. In this tutorial, we will be constructing an atomic CHMC rooted on a particular source metabolite carbon. We precompute an atom tracing dictionary mapping the (carbon) atom in the stoichiometric copy of a substrate to its product across each reaction.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"# Construct atom traced SMILES strings\nrs, ms = map_reaction_strings(S, smiles, rxns, false)\n\n# Precompute atom tracing dictionary\natom = :C # carbon\natom_max = get_max_atoms(smiles, atom)\nD_C = precompute_atom_tracing_dictionary(S, ms, atom_max, atom) # S must be Matrix{Int16}\n\n# Identify source metabolites\nsrc_mets = get_source_metabolites(S)\nmax_src_met_carbons = atom_max[src_mets]\nnothing # hide","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Computing-ACHMC-for-a-given-metabolite/carbon-atom-state","page":"ACHMC (for AEFMs)","title":"Computing ACHMC for a given metabolite/carbon atom state","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"The following atomic CHMC is rooted on the first carbon atom of the first source metabolite in the stoichiometry matrix 6-phospho-D-gluconate.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"I = (src_mets[1], 1, atom) # initial state is 1st carbon of canonicalized glucose\nres = steady_state_efm_distribution(S, v, ms, I, D_C; verbose = false) # S must be Matrix{Int16}","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"If we only wanted to enumerate the AEFMs, we would run:","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"enumerate_atomic_efms(S, ms, I, D_C, verbose = false)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"Both functions produce the same output structure res, except that the AEFM flux decomposition field will be a vector of zeros.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Output","page":"ACHMC (for AEFMs)","title":"Output","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"The output res is an immutable struct with 8 fields:","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"res.i is a tuple storing (i) the source metabolite index, (ii) source metabolite atom index (based on canonicalized SMILES string), and (iii) the atom type.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"res.e is an array of AEFMs with all corresponding simple cycle closures.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"res.p is an array of AEFM probabilities normalized to one.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"res.w is an array of AEFM weights normalized by the (unimolecular) reaction flux of the source metabolite.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"res.dchmc is a dictionary storing the ACHMC. The keys are the ACHMC states (composed of Markov chain states in res.dmc). The values are the ACHMC state and the Markov chain state children.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"res.dmc is a dictionary converting Markov chain states to metabolite-atom positions. The value (0, 0) always corresponds to the external environment sink node (which connects back to the source metabolite-atom state).","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"res.T is a sparse array storing the ACHMC transition probability matrix.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"res.R is an array of tuples storing the reaction index/indices mapped to each ACHMC transition matrix element.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Converting-AEFM-to-sequence-of-metabolites","page":"ACHMC (for AEFMs)","title":"Converting AEFM to sequence of metabolites","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"The corresponding AEFMs correspond to the movement of metabolite/atom states through the reaction network. We can convert these states into metabolites using get_efm_metabolite_atom_indices. Note that there is one fewer metabolite name than AEFM metabolite indices because the pseudometabolite (0, 0) linking sink and source reactions is omitted.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"# First AEFM\nmets[first.(get_efm_metabolite_atom_indices(res, 1))]","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"# Second AEFM\nmets[first.(get_efm_metabolite_atom_indices(res, 2))]","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Visualizing-the-CHMC-and-mapped-reactions","page":"ACHMC (for AEFMs)","title":"Visualizing the CHMC and mapped reactions","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"The following plotting function visualizes the ACHMC rooted on state I. This is only recommended for exploring ACHMCs of small networks.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"using GLMakie # Makie backend\nGLMakie.activate!()\n\nplot_atomic_chmc(res, S, mets, rs)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"Each node in the main panel corresponds to a CHMC state (metabolite and atomic index).","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"(Image: ACHMC main panel)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"Clicking on a CHMC transition will highlight that transition and display the corresponding metabolic reaction on the upper panel. The pair of purple highlighted atoms correspond to the movement of the same atom from the LHS to RHS of the reaction.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"(Image: ACHMC main and upper panel)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"Finally, the reaction and mapped reaction SMILES strings can also be plotted as an SVG and previewed using a package like ElectronDisplay. If fname != \"\", the SVG is also saved to file. By default, fname == \"\" and the SVG is not saved. The default canvas width and height are 1420 by 580 (pixels) but these can be changed. If using ElectronDisplay and the image is cut off, try resizing the plotting window or reducing the canvas dimensions.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"using ElectronDisplay\n\n# Reaction string\nplot_mapped_reaction(rs[2], view=true)\n#plot_mapped_reaction(rs[2], \"\\path\\to\\save\\name.svg\", view=true)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"(Image: Reaction SMILES string)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"# Mapped reaction string\nplot_mapped_reaction(ms[2], view = true, canvas_width = 1420, canvas_height = 580)\n#plot_mapped_reaction(ms[2], \"\\path\\to\\save\\name.svg\", view = true,)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs)","title":"ACHMC (for AEFMs)","text":"(Image: Mapped reaction SMILES string)","category":"page"},{"location":"installation/python-dependencies/#Exact-Python-dependencies-for-RXNMapper","page":"Exact Python dependencies for RXNMapper","title":"Exact Python dependencies for RXNMapper","text":"","category":"section"},{"location":"installation/python-dependencies/#Python-version","page":"Exact Python dependencies for RXNMapper","title":"Python version","text":"","category":"section"},{"location":"installation/python-dependencies/","page":"Exact Python dependencies for RXNMapper","title":"Exact Python dependencies for RXNMapper","text":"(rxnmapper-virtual-environment)\n$ python\nPython 3.10.14 (main, Jul 31 2024, 21:14:36) [GCC 14.1.1 20240720] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import sys\n>>> print(sys.version)\n3.10.14 (main, Jul 31 2024, 21:14:36) [GCC 14.1.1 20240720]","category":"page"},{"location":"installation/python-dependencies/#Dependencies-list","page":"Exact Python dependencies for RXNMapper","title":"Dependencies list","text":"","category":"section"},{"location":"installation/python-dependencies/","page":"Exact Python dependencies for RXNMapper","title":"Exact Python dependencies for RXNMapper","text":"(rxnmapper-virtual-environment)\n$ pip list --local\n\nPackage Version\n------------------------ -----------\nannotated-types 0.7.0\nattrs 24.2.0\nbeautifulsoup4 4.12.3\nbs4 0.0.2\ncertifi 2024.7.4\ncharset-normalizer 3.3.2\nclick 8.1.7\nCTSgetPy 0.0.2\ndiskcache 5.6.3\ndnspython 2.6.1\nfilelock 3.15.4\nfsspec 2024.6.1\nhuggingface-hub 0.24.6\nidna 3.8\nJinja2 3.1.4\nMarkupSafe 2.1.5\nmpmath 1.3.0\nnetworkx 3.3\nnumpy 2.1.0\nnvidia-cublas-cu12 12.1.3.1\nnvidia-cuda-cupti-cu12 12.1.105\nnvidia-cuda-nvrtc-cu12 12.1.105\nnvidia-cuda-runtime-cu12 12.1.105\nnvidia-cudnn-cu12 9.1.0.70\nnvidia-cufft-cu12 11.0.2.54\nnvidia-curand-cu12 10.3.2.106\nnvidia-cusolver-cu12 11.4.5.107\nnvidia-cusparse-cu12 12.1.0.106\nnvidia-nccl-cu12 2.20.5\nnvidia-nvjitlink-cu12 12.6.68\nnvidia-nvtx-cu12 12.1.105\npackaging 24.1\npandas 2.2.2\npillow 10.4.0\npip 24.2\npydantic 2.8.2\npydantic_core 2.20.1\npydantic-settings 2.4.0\npymongo 4.8.0\npython-dateutil 2.9.0.post0\npython-dotenv 1.0.1\npytz 2024.1\nPyYAML 6.0.2\nrdkit 2024.3.5\nregex 2024.7.24\nrequests 2.32.3\nrxn-chem-utils 1.6.0\nrxn-utils 2.0.0\nrxnmapper 0.3.1\nsafetensors 0.4.4\nscipy 1.14.1\nsetuptools 72.1.0\nsix 1.16.0\nsoupsieve 2.6\nsympy 1.13.2\ntdqm 0.0.1\ntokenizers 0.19.1\ntorch 2.4.0\ntqdm 4.66.5\ntransformers 4.44.2\ntriton 3.0.0\ntyping_extensions 4.12.2\ntzdata 2024.1\nurllib3 2.2.2\nwheel 0.43.0","category":"page"}] +[{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#ACHMC-(for-AEFMs;-under-the-hood)","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"This section explains the pre-processing steps under the hood of preprocess_all_for_atomic_chmc() using the same multispecies reaction network from the previous tutorial.","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"(Image: Toy multispecies network)","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"# Bodge until I figure out how to install Python and RXMapper on Git workflows\nusing MarkovWeightedEFMs\nusing SparseArrays\n\nS = [#\n 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # Glc\n 0 -1 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 # ATP\n 0 1 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 # G6P\n 0 1 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 # ADP\n 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 # 6PG\n 0 0 0 0 1 -1 1 0 0 0 0 0 0 0 0 0 # F6P\n 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 # Pi\n 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 # H2O\n 0 0 0 0 0 1 -1 -1 0 0 0 0 0 0 0 0 # FDP\n 0 0 0 0 0 0 0 1 -1 1 -1 0 0 0 0 0 # G3P\n 0 0 0 0 0 0 0 1 1 -1 0 -1 0 0 0 0 # DHAP\n]\n\nv = [10, 10, 3, 3, 7, 8, 1, 7, 1, 1, 7, 7, 18, 18, 1, 1]\n\nmets = [#\n \"Glc\",\n \"ATP\",\n \"G6P\",\n \"ADP\",\n \"6PG\",\n \"F6P\",\n \"Pi\",\n \"H2O\",\n \"FDP\",\n \"G3P\",\n \"DHAP\"\n]\n\nrxns = [#\n \"Source Glc\",\n \"Hexokinase\",\n \"G6P dehydrogenase\",\n \"Sink 6PG\",\n \"Phosphoglucose isomerase\",\n \"6-phosphofructo-1-kinase\",\n \"Fructose 1,6-bisphosphatase\",\n \"Fructose-bisphosphate aldolase\",\n \"Triose phosphate isomerase\",\n \"Triose phosphate isomerase\",\n \"Sink G3P\",\n \"Sink DHAP\",\n \"Source ATP\",\n \"Sink ADP\",\n \"Sink Pi\",\n \"Source H2O\"\n]\n\nsmiles = [#\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)OP(=O)(O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O\",\n \"C([C@H]([C@H]([C@@H](C(=O)CO)O)O)O)OP(=O)(O)O\",\n \"[O-]P(=O)([O-])[O-]\",\n \"O\",\n \"C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O\",\n \"C([C@H](C=O)O)OP(=O)(O)O\",\n \"C(C(=O)COP(=O)(O)O)O\"\n]\n\natom = :C # carbon atom type for AEFMs\n\nmdl, atom_info, logs = preprocess_all_for_atomic_chmc(S, v, mets, rxns, smiles, atom)\n\nerrors = CHMCAtomicErrorSummary(#\n 0.0, #absolute_flux_error\n Vector{Int64}(), #reactions_duplicated\n Vector{Int64}(), #reactions_with_zero_flux\n Vector{Int64}(), #reactions_with_negative_flux\n Vector{Int64}(), #reactions_with_non_integer_stoichiometries\n Vector{Int64}([1, 13, 16]), #reactions_unimolecular_source_stoichiometry_one\n Vector{Int64}(), #reactions_unimolecular_source_stoichiometry_not_one\n Vector{Int64}(), #reactions_multimolecular_source_stoichiometry_one\n Vector{Int64}(), #reactions_multimolecular_source_stoichiometry_not_one\n Vector{Int64}([4, 11, 12, 14, 15]), #reactions_unimolecular_sink_stoichiometry_one\n Vector{Int64}(), #reactions_unimolecular_sink_stoichiometry_not_one\n Vector{Int64}(), #reactions_multimolecular_sink_stoichiometry_one\n Vector{Int64}(), #reactions_multimolecular_sink_stoichiometry_not_one\n Vector{Int64}(), #reactions_empty\n Vector{Int64}() #unused_metabolites\n)\n\nlogs = (#\n dropped_row_pseudometabolites = Int64[],\n dropped_cols_pseudometabolites = Int64[],\n dropped_cols_rxnmapper_limit = Int64[]\n)\nsmiles = [\n \"OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O\"\n \"Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O\"\n \"O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O\"\n \"Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O\"\n \"O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O\"\n \"O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O\"\n \"O=P([O-])([O-])[O-]\"\n \"O\"\n \"O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)C(O)C1O\"\n \"O=C[C@H](O)COP(=O)(O)O\"\n \"O=C(CO)COP(=O)(O)O\"\n]\n\nrs = [#\n \">>OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O\",\n \"OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O.Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O>>O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O.Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O\",\n \"O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O>>O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O\",\n \"O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O>>\",\n \"O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O>>O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O\",\n \"Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O.O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O>>Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O.O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)C(O)C1O\",\n \"O.O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)C(O)C1O>>O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O.O=P([O-])([O-])[O-]\",\n \"O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)C(O)C1O>>O=C[C@H](O)COP(=O)(O)O.O=C(CO)COP(=O)(O)O\",\n \"O=C[C@H](O)COP(=O)(O)O>>O=C(CO)COP(=O)(O)O\",\n \"O=C(CO)COP(=O)(O)O>>O=C[C@H](O)COP(=O)(O)O\",\n \"O=C[C@H](O)COP(=O)(O)O>>\",\n \"O=C(CO)COP(=O)(O)O>>\",\n \">>Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O\",\n \"Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O>>\",\n \"O=P([O-])([O-])[O-]>>\",\n \">>O\"\n]\n\nms = [#\n \"\",\n \"[OH:5][CH2:6][C@H:7]1[O:8][CH:9]([OH:10])[C@H:11]([OH:12])[C@@H:13]([OH:14])[C@@H:15]1[OH:16].[NH2:17][c:18]1[n:19][cH:20][n:21][c:22]2[c:23]1[n:24][cH:25][n:26]2[C@@H:27]1[O:28][C@H:29]([CH2:30][O:31][P:32](=[O:33])([OH:34])[O:35][P:36](=[O:37])([OH:38])[O:39][P:2](=[O:1])([OH:3])[OH:4])[C@@H:40]([OH:41])[C@H:42]1[OH:43]>>[O:1]=[P:2]([OH:3])([OH:4])[O:5][CH2:6][C@H:7]1[O:8][CH:9]([OH:10])[C@H:11]([OH:12])[C@@H:13]([OH:14])[C@@H:15]1[OH:16].[NH2:17][c:18]1[n:19][cH:20][n:21][c:22]2[c:23]1[n:24][cH:25][n:26]2[C@@H:27]1[O:28][C@H:29]([CH2:30][O:31][P:32](=[O:33])([OH:34])[O:35][P:36](=[O:37])([OH:38])[OH:39])[C@@H:40]([OH:41])[C@H:42]1[OH:43]\",\n \"[O:8]=[P:7]([OH:9])([OH:10])[O:6][CH2:5][C@H:4]1[O:3][CH:2]([OH:1])[C@H:15]([OH:16])[C@@H:13]([OH:14])[C@@H:11]1[OH:12]>>[O:1]=[C:2]1[O:3][C@H:4]([CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10])[C@@H:11]([OH:12])[C@H:13]([OH:14])[C@H:15]1[OH:16]\",\n \"\",\n \"[O:14]=[P:13]([OH:15])([OH:16])[O:12][CH2:11][C@H:9]1[O:10][CH:3]([OH:4])[C@H:2]([OH:1])[C@@H:5]([OH:6])[C@@H:7]1[OH:8]>>[O:1]=[C:2]([CH2:3][OH:4])[C@@H:5]([OH:6])[C@H:7]([OH:8])[C@H:9]([OH:10])[CH2:11][O:12][P:13](=[O:14])([OH:15])[OH:16]\",\n \"[NH2:1][c:2]1[n:3][cH:4][n:5][c:6]2[c:7]1[n:8][cH:9][n:10]2[C@@H:11]1[O:12][C@H:13]([CH2:14][O:15][P:16](=[O:17])([OH:18])[O:19][P:20](=[O:21])([OH:22])[O:23][P:29](=[O:28])([OH:30])[OH:31])[C@@H:24]([OH:25])[C@H:26]1[OH:27].[O:35]=[C:34]([CH2:33][OH:32])[C@@H:46]([OH:47])[C@H:44]([OH:45])[C@H:36]([OH:37])[CH2:38][O:39][P:40](=[O:41])([OH:42])[OH:43]>>[NH2:1][c:2]1[n:3][cH:4][n:5][c:6]2[c:7]1[n:8][cH:9][n:10]2[C@@H:11]1[O:12][C@H:13]([CH2:14][O:15][P:16](=[O:17])([OH:18])[O:19][P:20](=[O:21])([OH:22])[OH:23])[C@@H:24]([OH:25])[C@H:26]1[OH:27].[O:28]=[P:29]([OH:30])([OH:31])[O:32][CH2:33][CH:34]1[O:35][C:36]([OH:37])([CH2:38][O:39][P:40](=[O:41])([OH:42])[OH:43])[CH:44]([OH:45])[CH:46]1[OH:47]\",\n \"[OH2:20].[O:17]=[P:18]([OH:19])([OH:21])[O:4][CH2:3][CH:2]1[O:1][C:9]([OH:10])([CH2:11][O:12][P:13](=[O:14])([OH:15])[OH:16])[CH:7]([OH:8])[CH:5]1[OH:6]>>[O:1]=[C:2]([CH2:3][OH:4])[C@@H:5]([OH:6])[C@H:7]([OH:8])[C@H:9]([OH:10])[CH2:11][O:12][P:13](=[O:14])([OH:15])[OH:16].[O:17]=[P:18]([O-:19])([O-:20])[O-:21]\",\n \"[O:18]=[P:17]([OH:19])([OH:20])[O:1][CH2:2][CH:3]1[O:4][C:12]([OH:11])([CH2:13][O:14][P:7](=[O:8])([OH:9])[OH:10])[CH:15]([OH:16])[CH:5]1[OH:6]>>[O:1]=[CH:2][C@H:3]([OH:4])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10].[O:11]=[C:12]([CH2:13][OH:14])[CH2:15][O:16][P:17](=[O:18])([OH:19])[OH:20]\",\n \"[O:4]=[CH:3][C@H:2]([OH:1])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10]>>[O:1]=[C:2]([CH2:3][OH:4])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10]\",\n \"[O:1]=[C:2]([CH2:3][OH:4])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10]>>[O:4]=[CH:3][C@H:2]([OH:1])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10]\",\n \"\",\n \"\",\n \"\",\n \"\",\n \"\",\n \"\"\n]\n\natom_max = [6, 10, 6, 10, 6, 6, 0, 0, 6, 3, 3]\n\nks = [#\n (3, 2, 1, 3),\n (2, 2, 1, 6),\n (1, 2, 1, 2),\n (2, 5, 1, 2),\n (3, 3, 1, 5),\n (3, 4, 1, 5),\n (3, 6, 1, 3),\n (2, 6, 1, 6),\n (1, 6, 1, 2),\n (2, 7, 1, 6),\n (11, 3, 1, 10),\n (2, 9, 1, 2),\n (3, 1, 1, 5),\n (3, 2, 1, 5),\n (3, 5, 1, 3),\n (2, 5, 1, 6),\n (9, 3, 1, 7),\n (1, 5, 1, 2),\n (9, 4, 1, 7),\n (11, 1, 1, 10),\n (6, 3, 1, 6),\n (9, 3, 1, 8),\n (6, 4, 1, 6),\n (9, 4, 1, 8),\n (2, 3, 1, 2),\n (11, 2, 1, 10),\n (2, 4, 1, 2),\n (3, 6, 1, 5),\n (9, 1, 1, 7),\n (6, 1, 1, 6),\n (9, 1, 1, 8),\n (2, 9, 1, 6),\n (9, 2, 1, 7),\n (2, 1, 1, 2),\n (6, 2, 1, 6),\n (9, 2, 1, 8),\n (2, 8, 1, 2),\n (2, 10, 1, 2),\n (2, 2, 1, 2),\n (3, 5, 1, 5),\n (9, 6, 1, 7),\n (10, 3, 1, 9),\n (6, 6, 1, 6),\n (3, 3, 1, 3),\n (2, 3, 1, 6),\n (9, 6, 1, 8),\n (1, 3, 1, 2),\n (3, 4, 1, 3),\n (2, 4, 1, 6),\n (1, 4, 1, 2),\n (2, 6, 1, 2),\n (2, 7, 1, 2),\n (10, 1, 1, 9),\n (3, 1, 1, 3),\n (2, 1, 1, 6),\n (9, 5, 1, 7),\n (1, 1, 1, 2),\n (6, 5, 1, 6),\n (2, 8, 1, 6),\n (9, 5, 1, 8),\n (2, 10, 1, 6),\n (10, 2, 1, 9)\n]\n\nvs = [#\n (5, 2),\n (4, 2),\n (3, 2),\n (4, 5),\n (6, 2),\n (6, 1),\n (5, 4),\n (4, 6),\n (3, 6),\n (4, 7),\n (10, 3),\n (4, 9),\n (6, 6),\n (6, 5),\n (5, 5),\n (4, 5),\n (6, 5),\n (3, 5),\n (6, 6),\n (10, 2),\n (9, 6),\n (11, 1),\n (9, 5),\n (11, 2),\n (4, 3),\n (10, 1),\n (4, 4),\n (6, 4),\n (6, 2),\n (9, 2),\n (10, 1),\n (4, 9),\n (6, 1),\n (4, 1),\n (9, 1),\n (10, 2),\n (4, 8),\n (4, 10),\n (4, 2),\n (6, 3),\n (6, 3),\n (11, 3),\n (9, 4),\n (5, 1),\n (4, 3),\n (10, 3),\n (3, 3),\n (5, 6),\n (4, 4),\n (3, 4),\n (4, 6),\n (4, 7),\n (11, 2),\n (5, 3),\n (4, 1),\n (6, 4),\n (3, 1),\n (9, 3),\n (4, 8),\n (11, 3),\n (4, 10),\n (11, 1)\n]\n\nD_C = Dict(zip(ks, vs))\n\nsrc_mets = [1, 2, 8]\nmax_src_mets_carbon = [6, 10, 0]\n\nI = (src_mets[1], 1, atom)\n\nks = Int16.([5, 4, 6, 7, 2, 8, 3, 1])\nvs = [(Int16(6), Int16(6)), (Int16(0), Int16(0)), (Int16(9), Int16(4)), (Int16(11), Int16(2)), (Int16(3), Int16(1)), (Int16(10), Int16(1)), (Int16(5), Int16(3)), (Int16(1), Int16(1))]\ndmc = Dict(zip(ks, vs))\n\nks = [#\n Int16.([1, 2, 5, 6, 7]),\n Int16.([1, 2, 5, 6]),\n Int16.([1, 2, 5, 6, 7, 4]),\n Int16.([1]),\n Int16.([1, 2, 3]),\n Int16.([1, 2, 3, 4]),\n Int16.([1, 2]),\n Int16.([1, 2, 5]),\n Int16.([1, 2, 5, 6, 7, 8]),\n Int16.([1, 2, 5, 6, 7, 8, 4])\n]\nvs = [#\n (id = 7, children = Int16.([8])),\n (id = 6, children = Int16.([7])),\n (id = 8, children = Int16.([])),\n (id = 1, children = Int16.([2])),\n (id = 3, children = Int16.([])),\n (id = 4, children = Int16.([])),\n (id = 2, children = Int16.([3, 5])),\n (id = 5, children = Int16.([6])),\n (id = 9, children = Int16.([])),\n (id = 10, children = Int16.([]))\n]\ndchmc = Dict(zip(ks, vs))\n\nT = SparseMatrixCSC([\n 0 1.0 0 0 0 0 0 0 0 0\n 0 0 0.3 0 0.7 0 0 0 0 0\n 0 0 0 1.0 0 0 0 0 0 0\n 1.0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 1.0 0 0 0 0\n 0 0 0 0 0.125 0 0.875 0 0 0\n 0 0 0 0 0 0 0 0.875 0.125 0\n 1.0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0.125 0 0 0.875\n 1.0 0 0 0 0 0 0 0 0 0\n])\n\nR = [#\n (i = 1, j = 2, k = Int16(2)),\n (i = 2, j = 3, k = Int16(3)),\n (i = 2, j = 5, k = Int16(5)),\n (i = 3, j = 4, k = Int16(4)),\n (i = 4, j = 1, k = Int16(4)),\n (i = 5, j = 6, k = Int16(6)),\n (i = 6, j = 5, k = Int16(7)),\n (i = 6, j = 7, k = Int16(8)),\n (i = 7, j = 8, k = Int16(12)),\n (i = 8, j = 1, k = Int16(12)),\n (i = 7, j = 9, k = Int16(10)),\n (i = 9, j = 10, k = Int16(11)),\n (i = 10, j = 1, k = Int16(11)),\n (i = 9, j = 7, k = Int16(9))\n]\n\nres = CHMCAtomicSummary(#\n (1, 1, :C),\n [#\n (EFM = [6, 5, 6], Closures = [(6, 5)]),\n (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)]),\n (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)]),\n (EFM = [8, 7, 8], Closures = [(9, 7)]),\n (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)])\n ],\n [0.09000000000000001, 0.56, 0.27, 0.01, 0.07],\n [1.0, 6.222222222222222, 3.0, 0.11111111111111112, 0.7777777777777778],\n dmc,\n dchmc,\n T,\n R\n)\n\nT = SparseMatrixCSC([\n 0 1.0 0 0 0 0 0 0 0 0\n 0 0 0.5 0 0.5 0 0 0 0 0\n 0 0 0 1.0 0 0 0 0 0 0\n 1.0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 1.0 0 0 0 0\n 0 0 0 0 0.5 0 0.5 0 0 0\n 0 0 0 0 0 0 0 0.5 0.5 0\n 1.0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0.5 0 0 0.5\n 1.0 0 0 0 0 0 0 0 0 0\n])\n\nres_enum = CHMCAtomicSummary(#\n (1, 1, :C),\n [#\n (EFM = [6, 5, 6], Closures = [(6, 5)]),\n (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)]),\n (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)]),\n (EFM = [8, 7, 8], Closures = [(9, 7)]),\n (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)])\n ],\n nothing,\n nothing,\n dmc,\n dchmc,\n T,\n R\n)\n\nefm_seq_1 = [\"FDP\", \"F6P\", \"FDP\"]\nefm_seq_2 = [\"Glc\", \"G6P\", \"F6P\", \"FDP\", \"DHAP\"]\n","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#Inputs","page":"ACHMC (for AEFMs; under the hood)","title":"Inputs","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"using MarkovWeightedEFMs\nS = [#\n 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # Glc\n 0 -1 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 # ATP\n 0 1 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 # G6P\n 0 1 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 # ADP\n 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 # 6PG\n 0 0 0 0 1 -1 1 0 0 0 0 0 0 0 0 0 # F6P\n 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 # Pi\n 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 # H2O\n 0 0 0 0 0 1 -1 -1 0 0 0 0 0 0 0 0 # FDP\n 0 0 0 0 0 0 0 1 -1 1 -1 0 0 0 0 0 # G3P\n 0 0 0 0 0 0 0 1 1 -1 0 -1 0 0 0 0 # DHAP\n]\n\nv = [10, 10, 3, 3, 7, 8, 1, 7, 1, 1, 7, 7, 18, 18, 1, 1]\n\nmets = [#\n \"Glc\",\n \"ATP\",\n \"G6P\",\n \"ADP\",\n \"6PG\",\n \"F6P\",\n \"Pi\",\n \"H2O\",\n \"FDP\",\n \"G3P\",\n \"DHAP\"\n]\n\nrxns = [#\n \"Source Glc\",\n \"Hexokinase\",\n \"G6P dehydrogenase\",\n \"Sink 6PG\",\n \"Phosphoglucose isomerase\",\n \"6-phosphofructo-1-kinase\",\n \"Fructose 1,6-bisphosphatase\",\n \"Fructose-bisphosphate aldolase\",\n \"Triose phosphate isomerase\",\n \"Triose phosphate isomerase\",\n \"Sink G3P\",\n \"Sink DHAP\",\n \"Source ATP\",\n \"Sink ADP\",\n \"Sink Pi\",\n \"Source H2O\"\n]\n\nsmiles = [#\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)OP(=O)(O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O\",\n \"C([C@H]([C@H]([C@@H](C(=O)CO)O)O)O)OP(=O)(O)O\",\n \"[O-]P(=O)([O-])[O-]\",\n \"O\",\n \"C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O\",\n \"C([C@H](C=O)O)OP(=O)(O)O\",\n \"C(C(=O)COP(=O)(O)O)O\"\n]\n\natom = :C # carbon atom type for AEFMs","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"We can check that the flux vector satisfies the steady state requirements.","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"all(S * v .== 0) # should evaluate as true","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#Pre-processing-steps","page":"ACHMC (for AEFMs; under the hood)","title":"Pre-processing steps","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#Checking-network-structure","page":"ACHMC (for AEFMs; under the hood)","title":"Checking network structure","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"The following functions check for issues with the inputs. The first function find_atomic_chmc_input_errors identifies possible problems with the stoichiometry matrix and flux vector.","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"# Confirm there are no issues with stoichiometry matrix\nerrors = find_atomic_chmc_input_errors(S, v)","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"print(errors) # summary of errors associated with S/v","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#Correcting-problems-in-network-structure","page":"ACHMC (for AEFMs; under the hood)","title":"Correcting problems in network structure","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"Any problems, except for the steady state flux requirement, can be addressed via correct_atomic_chmc_input_errors. ","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"# S and v have no errors so the inputs are returned\ncorrect_atomic_chmc_input_errors(errors, S, mets, rxns)\n# S, mets, rxns = correct_atomic_chmc_input_errors(errors, S, mets, rxns) # otherwise","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#Identifying-unmappable-reactions","page":"ACHMC (for AEFMs; under the hood)","title":"Identifying unmappable reactions","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"The next function correct_atomic_chmc_input_smiles checks and fixes problems relating to the SMILES strings. These problems are caused by RXNMapper being unable to map atoms in reactions with pseudometabolites or pseudoreactions with non-integer stoichiometries (e.g. biomass reaction). RXNMapper also has a character limit on reaction SMILES strings. These unmappable reactions are removed and the flux is balanced with unimolecular flux entering/exiting the associated reaction substrates/products.","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"# Correct issues associated with RXNMapper character limit,\n# pseudometabolites and pseudoreactions\nS, v, mets, rxns, smiles, logs = correct_atomic_chmc_input_smiles(S, v, mets, rxns, smiles)","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"At this point, the SMILES strings (matching the updated mets if there were errors in the initial inputs) should be canonicalized. S is also converted to a Matrix{Int16} which is a requirement for subsequent functions.","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"smiles = canonicalize_smiles(smiles)","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"smiles","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#Atom-mapping-reactions","page":"ACHMC (for AEFMs; under the hood)","title":"Atom mapping reactions","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"The reaction SMILES strings rs are next constructed from the metabolite SMILES and the atom mapping is performed via RXNMapper and stored in ms.","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"# Construct atom traced SMILES strings\nrs, ms = map_reaction_strings(S, smiles, rxns, false)","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"rs","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"ms","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#Identifying-all-source-metabolite-atom-positions","page":"ACHMC (for AEFMs; under the hood)","title":"Identifying all source metabolite-atom positions","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"The following code extracts the source metabolite indices in mets and computes the total number of carbon atoms of interest.","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"# Total number of atom type across all metabolites\natom_max = get_max_atoms(smiles, atom)\n\n# Identify source metabolite indices and copies of atom\nsrc_mets = get_source_metabolites(S)\n\n# Number of carbon atoms in each source metabolite\nmax_src_mets_carbon = atom_max[src_mets]","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"# Source metabolites\nmets[src_mets]","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"# Carbons in each source metabolite\nmax_src_mets_carbon","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#Enumerating-metabolite-atom-mappings-across-reactions","page":"ACHMC (for AEFMs; under the hood)","title":"Enumerating metabolite-atom mappings across reactions","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"We then precompute an atom tracing dictionary mapping the (carbon) atom in the stoichiometric copy of a substrate to its product atom position across each reaction.","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"# Precompute atom tracing dictionary\nD_C = precompute_atom_tracing_dictionary(S, ms, atom_max, atom) # S must be Matrix{Int16}","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"D_C","category":"page"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/#Conclusion","page":"ACHMC (for AEFMs; under the hood)","title":"Conclusion","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose-under-the-hood/","page":"ACHMC (for AEFMs; under the hood)","title":"ACHMC (for AEFMs; under the hood)","text":"All of the code/functions described above are wrapped into preprocess_all_for_atomic_chmc(). If this wrapper function fails, you may need to step through these individual pre-processing functions to identify the error.","category":"page"},{"location":"library/chmc-plots-standard/#Plotting-(CHMC)","page":"Plotting (CHMC)","title":"Plotting (CHMC)","text":"","category":"section"},{"location":"library/chmc-plots-standard/#CHMC","page":"Plotting (CHMC)","title":"CHMC","text":"","category":"section"},{"location":"library/chmc-plots-standard/","page":"Plotting (CHMC)","title":"Plotting (CHMC)","text":"plot_chmc","category":"page"},{"location":"library/chmc-plots-standard/#MarkovWeightedEFMs.Plots.plot_chmc","page":"Plotting (CHMC)","title":"MarkovWeightedEFMs.Plots.plot_chmc","text":"function plot_chmc(#\n T::Matrix{<:Real},\n I::Int64=1;\n node_label_textsize::Real=15,\n edge_label_textsize::Real=12,\n arrow_shift::Real=0.85,\n x_pad::Real=0.75,\n y_pad::Real=0.75,\n tfactor::Real=0.15,\n tangents::Tuple{#\n Tuple{<:Real, <:Real},\n Tuple{<:Real, <:Real}\n } = ((1,0),(0,1)),\n show_all::Bool=false\n\n)\n\nPlot cycle-history Markov chain from transition probability matrix T rooted on state/node I.\n\nT is a right stochastic transition probability matrix with rows summing to one.\n\nI is a state in 1:size(T,1).\n\nnode_label_textsize is the text size of the node labels indexed from T.\n\nedge_label_textsize is the text size of the edge labels taken from T.\n\narrow_shift is the percentage shift of the arrow head from src to dst.\n\nx_pad is the left/right x coordinate padding of the plotting box.\n\ny_pad is the up/down y coordinate padding of the plotting box.\n\ntfactor scales the distance of the bezier control point relative to the distance of the src and dst nodes.\n\ntangents is the tangent of the src vertex and dst vertex.\n\nshow_all=true explicitly plots the upstream transition from all EFMs that pass through the initial state/node I. By default, these arrows stemming from the green nodes are omitted for visual clarity.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-plots-standard/#Index","page":"Plotting (CHMC)","title":"Index","text":"","category":"section"},{"location":"library/chmc-plots-standard/","page":"Plotting (CHMC)","title":"Plotting (CHMC)","text":"Pages = [\"chmc-plots.md\"]","category":"page"},{"location":"installation/installation/#Getting-started","page":"Getting started","title":"Getting started","text":"","category":"section"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"To install this package, open a julia session and enter:","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"julia> ]\n(@v1.10) pkg> add https://github.com/jchitpin/MarkovWeightedEFMs.jl.git","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"Alternatively, you can load Pkg and install by:","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"julia> using Pkg\njulia> Pkg.add(\"https://github.com/jchitpin/MarkovWeightedEFMs.jl.git\")","category":"page"},{"location":"installation/installation/#Python-dependencies-for-AEFM-analysis","page":"Getting started","title":"Python dependencies for AEFM analysis","text":"","category":"section"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"AEFM-specific analyses depend on the atom mapping program RXNMapper. This package must be installed and built with PyCall.jl after installing MarkovWeightedEFMs.jl. Tested to work with python version 3.10 and 3.11","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"This can be done by creating a python virtual environment, installing RXNMapper, and setting the PYTHON environment variable to the python executable in the virtual environment.","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"$ pip install virtualenv\n$ virtualenv --python=\"/usr/bin/python3.10\" \"virtualenv\" # name of virtual environment\n$ source virtualenv/bin/activate\n(virtualenv) $ pip install rxnmapper\n(virtualenv) $ pip install rdkit\n(virtualenv) $ pip install requests\n(virtualenv) $ pip install tdqm\n(virtualenv) $ pip install bs4\n(virtualenv) $ pip install CTSgetPy\n(virtualenv) $ julia","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"julia> using Pkg, PyCall\njulia> ENV[\"PYTHON\"] = joinpath(ENV[\"VIRTUAL_ENV\"], \"bin\", \"python\")\njulia> Pkg.build(\"PyCall\")","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"Note PyCall.jl will need to be rebuilt whenever you update your Julia version. See PyCall.jl documentation for more options on setting up Python in Julia.","category":"page"},{"location":"installation/installation/","page":"Getting started","title":"Getting started","text":"See Exact Python dependencies for RXNMapper for more information.","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#CHMC-(ion-channels)","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"This section demonstrates how to use the functions in MarkovWeightedEFMs.jl to analyze the steady state dynamics of the following ion channel with three possible binding sites reproduced from (Bicknell and Goodhill)[https://doi.org/10.1073/pnas.1604090113].","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"(Image: Markov chain model of IP3 receptor from Bicknell and Goodhill (https://doi.org/10.1073/pnas.1604090113))","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"using MarkovWeightedEFMs","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#Markov-state-model-of-IP3-channel-activity","page":"CHMC (ion channels)","title":"Markov state model of IP3 channel activity","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/#Rate-constants","page":"CHMC (ion channels)","title":"Rate constants","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"using MarkovWeightedEFMs\n\n# Parameters\nc = 0.1 # Ca2+ (uM)\nI = 0.1 # IP3 (uM)\na1 = 50\na2 = 0.035\na4 = 3.5\na5 = 65\na6 = 25\na7 = 10\na8 = 0.035\na9 = 0.15\na10 = 1.25\na11 = 110\nb1 = 2.5\nb2 = 1.25\nb3 = 0.25\nb4 = 12.5\nb5 = 10\nb7 = 0.25\nb9 = 0.2\nb10 = 2.5\nb11 = 20\nK1 = b1 / a1\nK2 = b2 / a2\nK4 = b4 / a4\nK5 = b5 / a5\nK7 = b7 / a7\nK9 = b9 / a9\nK10 = b10 / a10\na3 = (b3 * K4) / (K1 * K2)\nb6 = (a6 * K5 * K7) / K1\nb8 = (a8 * K2 * K10) / K9\nnothing # hide","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#Generator-and-transition-matrix","page":"CHMC (ion channels)","title":"Generator and transition matrix","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"# Markov transition rate matrix\nQ = [#\n 0 c*a6 0 I*a7 0 0 0 0 0 0\n b6 0 c*a4 0 I*a1 0 0 0 0 0\n 0 b4 0 0 0 I*a3 0 0 0 0\n b7 0 0 0 c*a5 0 a9 0 0 0\n 0 b1 0 b5 0 c*a2 0 a9 0 a11\n 0 0 b3 0 b2 0 0 0 a10 0\n 0 0 0 b9 0 0 0 c*a5 0 0\n 0 0 0 0 b9 0 b5 0 c*a8 0\n 0 0 0 0 0 b10 0 b8 0 0\n 0 0 0 0 b11 0 0 0 0 0\n];\n\n# Markov transition probability matrix\nT = Q ./ sum(Q, dims=2)","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#Enumerating-EFMs-and-computing-their-probabilities","page":"CHMC (ion channels)","title":"Enumerating EFMs and computing their probabilities","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"The Markov state model contains 39 EFMs. If one were to simulate trajectories from this model for an infinite period of time and decompose these trajectories into simple cycles, the resulting frequencies would converge on the following EFM probabilities. For example, the active-inactive-active transition involving states 10-5-10 occurs ~83.8% of the time on average in this model.","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"res = steady_state_efm_distribution(T);\n\n# EFMs/simple cycles and their corresponding probabilities\nreduce(hcat, [res.e, res.p])","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/#Visualizing-the-CHMC","page":"CHMC (ion channels)","title":"Visualizing the CHMC","text":"","category":"section"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"The blue node represents state 1 and is the root of the tree. All green nodes return back to the blue node but these arrows are hidden to limit visual clutter.","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"using GLMakie\nGLMakie.activate!()\nplot_chmc(T, 1) # arbitrarily rooted on state 1","category":"page"},{"location":"tutorials/chmc-standard-ion-channels/","page":"CHMC (ion channels)","title":"CHMC (ion channels)","text":"(Image: )","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#CHMC-(metabolic-networks)","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"This section demonstrates how to use the functions in MarkovWeightedEFMs.jl to analyze the following unimolecular reaction network.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"(Image: Example unimolecular reaction network)","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"using MarkovWeightedEFMs","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#Problem-statement","page":"CHMC (metabolic networks)","title":"Problem statement","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"Given the metabolic network above, its steady state fluxes, and its elementary flux modes (EFMs), what is the set of EFM weights that reconstructs the observed network fluxes?","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#Inputs","page":"CHMC (metabolic networks)","title":"Inputs","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"For this type of problem, we require the following:","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"Stoichiometry matrix of unimolecular reactions (must be unimolecular and strongly-connected; either open or closed loop)\nSteady state fluxes along each reaction.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The network metabolites and reactions are typically encoded in an m by r stoichiometry matrix S. The steady state flux vector is stored as a separate vector.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"using MarkovWeightedEFMs # load package\n\n# Stoichiometry matrix and flux vector for the example network\nS = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 -1 1 0\n 0 0 0 0 0 0 0 1 0 0 -1\n 0 0 0 0 0 0 0 0 1 -1 0\n]\nv = [3, 2, 1, 2, 3, 2, 2, 3, 1, 1, 3]\nnothing # hide","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"We can check that the flux vector satisfies the steady state requirements.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"all(S * v .== 0) # should evaluate as true","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#Solving-for-EFM-sequences,-probabilities,-and-weights","page":"CHMC (metabolic networks)","title":"Solving for EFM sequences, probabilities, and weights","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The following function applies our (discrete-time) cycle-history Markov chain (CHMC) method to compute the network EFMs, their steady state EFM probabilities, and weights. By default, the last parameter is 1 and can be omitted from the function. This parameter is the (arbitrary) initial state to root the CHMC. The choice of root state does not change the EFM probabilities or weights and is explained further in the section below.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"res = steady_state_efm_distribution(S, v, 1)","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The enumerated EFM sequences are","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"res.e","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The corresponding EFM probabilities are","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"res.p","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The corresponding EFM weights are","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"res.w","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"We can check that the EFM weights reconstruct the observed network fluxes","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"E = reshape_efm_vector(res.e, S) # matrix of EFM weights\nE * res.w ≈ v # passes","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"A binary EFM matrix with rows = # reactions and columns = # EFMs can be converted back to the array of EFM sequences by","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"reshape_efm_matrix(E, S)","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/#Visualizing-the-CHMC","page":"CHMC (metabolic networks)","title":"Visualizing the CHMC","text":"","category":"section"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The following plotting function visualizes the CHMC rooted on a metabolite state (1 by default).","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"using GLMakie # Makie backend\nGLMakie.activate!()\nT = stoichiometry_to_transition_matrix(S, v)\nplot_chmc(T, 1) # the last parameter is the rooted metabolite index","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"(Image: )","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"If using the GLMakie backend, ensure OpenGL is installed on your machine and accessible by Julia. The GLMakie plot is interactive and allows users to drag nodes and zoom in/out. Otherwise, you could choose another backend such as CairoMakie to generate and save a static plot. A prettier, hand-coded version of the transformed network is shown below.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"The blue node is the root of the tree and the green nodes indicate that there is an edge back up to the root. By default, these arrows are omitted to avoid cluttering the plot.","category":"page"},{"location":"tutorials/chmc-standard-metabolic-networks/","page":"CHMC (metabolic networks)","title":"CHMC (metabolic networks)","text":"(Image: )","category":"page"},{"location":"library/chmc-atomic/#Atomic-CHMC","page":"Atomic CHMC","title":"Atomic CHMC","text":"","category":"section"},{"location":"library/chmc-atomic/#Public-functions","page":"Atomic CHMC","title":"Public functions","text":"","category":"section"},{"location":"library/chmc-atomic/","page":"Atomic CHMC","title":"Atomic CHMC","text":"canonicalize_smiles\nfind_atomic_chmc_input_errors\ncorrect_atomic_chmc_input_errors\nprint(res::CHMCAtomicErrorSummary)\ncorrect_atomic_chmc_input_smiles\nexchange_atomic_chmc_input_metabolites\nget_source_metabolites\nget_max_atoms\nmap_reaction_strings\nprecompute_atom_tracing_dictionary\nMarkovWeightedEFMs.CHMC.Atomic.steady_state_efm_distribution(#\n S::Matrix{<:Integer},\n v::Vector{<:Real},\n ms::Vector{String},\n I::Tuple{Int64,Int64,Symbol};\n D::Dict{#\n NTuple{4,Int64},\n Tuple{Int64,Int64}\n }=Dict{NTuple{4,Int64}, Tuple{Int64,Int64}}(),\n tmp_dir::String=\"\"\n)\nget_efm_metabolite_atom_indices\nget_efm_reaction_atom_indices\nchmc_to_mc_matrix\nexport_atom_tracing_dictionary\nimport_atom_tracing_dictionary\npreprocess_all_for_atomic_chmc","category":"page"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.canonicalize_smiles","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.canonicalize_smiles","text":"canonicalize_smiles(m::Vector{String})\n\nCanonicalize input SMILES string m for RXNMapper mapping.\n\n\n\n\n\ncanonicalize_smiles(m::String)\n\nCanonicalize input SMILES string m for RXNMapper mapping.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.find_atomic_chmc_input_errors","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.find_atomic_chmc_input_errors","text":"find_atomic_chmc_input_errors(S::Matrix{<:Real}, v::Vector{<:Real})\n\nPerforms a series of checks on stoichiometry matrix S and steady state flux vector v to determine whether they meet the atomic CHMC requirements. Returns an CHMCAtomicErrorSummary structure that can be printed via print(res::CHMCAtomicErrorSummary).\n\n\n\n\n\nfind_atomic_chmc_input_errors(S::Matrix{<:Real})\n\nPerforms a series of checks on stoichiometry matrix S to determine whether they meet the atomic CHMC requirements for atomic EFM enumeration. Returns an CHMCAtomicErrorSummary structure that can be printed via print(res::CHMCAtomicErrorSummary).\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_errors","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_errors","text":"correct_atomic_chmc_input_errors(#\n res::CHMCAtomicErrorSummary,\n S::Matrix{<:Real},\n v::Vector{<:Real},\n mets::Vector{String},\n rxns::Vector{String}\n)\n\nCorrects all errors identified by find_atomic_chmc_input_errors except for the steady state flux requirement. Returns a corrected version of each input.\n\nS is the m by n stoichiometry matrix. v is the steady state flux vector of length n. mets is the vector of metabolite names of length m. rxns is the vector of reaction names of length n.\n\n\n\n\n\ncorrect_atomic_chmc_input_errors(#\n res::CHMCAtomicErrorSummary,\n S::Matrix{<:Real},\n mets::Vector{String},\n rxns::Vector{String}\n)\n\nCorrects all errors identified by find_atomic_chmc_input_errors except for the steady state flux requirement. Returns a corrected version of each input.\n\nS is the m by n stoichiometry matrix. mets is the vector of metabolite names of length m. rxns is the vector of reaction names of length n.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#Base.print-Tuple{CHMCAtomicErrorSummary}","page":"Atomic CHMC","title":"Base.print","text":"print(res::CHMCAtomicErrorSummary)\n\nWrite CHMCAtomicErrorSummary to stdout.\n\n\n\n\n\n","category":"method"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_smiles","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.correct_atomic_chmc_input_smiles","text":"correct_atomic_chmc_input_smiles(#\n S::Matrix{<:Real},\n v::Vector{<:Real},\n mets::Vector{String},\n rxns::Vector{String},\n smiles::Vector{String},\n H::Bool=false\n)\n\nUpdates the inputs by (1) removing pseudometabolites and (2) reactions whose reaction strings exceed the RXNMapper character limit. Pseudometabolites are defined as either metabolites with no defined chemical structure/SMILES representation, or metabolites whose SMILES strings contain symbols absent from the periodic table (including metabolites with an R-group). Reactions that exceed the RXNMapper character limit are converted into unimolecular sources and sinks to maintain steady state flux. Returns the corrected inputs with a list of removed metabolites/reactions.\n\nS is the m by n stoichiometry matrix.\n\nv is the steady state flux vector of length n.\n\nmets is the vector of metabolite names of length m.\n\nrxns is the vector of reaction names of length n.\n\nsmiles is the vector of metabolite smiles matching mets.\n\nH = false will not check for hydrogen conservation in each reaction.\n\n\n\n\n\ncorrect_atomic_chmc_input_smiles(#\n S::Matrix{<:Real},\n mets::Vector{String},\n rxns::Vector{String},\n smiles::Vector{String},\n H::Bool=false\n)\n\nUpdates the inputs by (1) removing pseudometabolites and (2) reactions whose reaction strings exceed the RXNMapper character limit. Pseudometabolites are defined as either metabolites with no defined chemical structure/SMILES representation, or metabolites whose SMILES strings contain symbols absent from the periodic table (including metabolites with an R-group). Reactions that exceed the RXNMapper character limit are converted into unimolecular sources and sinks to maintain steady state flux. Returns the corrected inputs with a list of removed metabolites/reactions.\n\nS is the m by n stoichiometry matrix.\n\nmets is the vector of metabolite names of length m.\n\nrxns is the vector of reaction names of length n.\n\nsmiles is the vector of metabolite smiles matching mets.\n\nH = false will not check for hydrogen conservation in each reaction.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.exchange_atomic_chmc_input_metabolites","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.exchange_atomic_chmc_input_metabolites","text":"exchange_atomic_chmc_input_metabolites(#\n S::Matrix{<:Real},\n v::Vector{<:Real},\n mets::Vector{String},\n rxns::Vector{String},\n smiles::Vector{String},\n ii::Vector{Int64}\n)\n\nRemoves internal metabolites ii from the remaining inputs by converting each metabolite i ∈ ii into a pair of sink and source metabolites. Returns an updated copy of inputs S, v, mets, rxns, and smiles.\n\nS is the m by n stoichiometry matrix.\n\nv is the steady state flux vector of length n.\n\nmets is the vector of metabolite names of length m.\n\nrxns is the vector of reaction names of length n.\n\nsmiles is the vector of metabolite smiles matching mets.\n\nii is the vector of metabolite indices to exchange for pairs of sinks/sources.\n\n\n\n\n\nexchange_atomic_chmc_input_metabolites(#\n S::Matrix{<:Real},\n mets::Vector{String},\n rxns::Vector{String},\n smiles::Vector{String},\n ii::Vector{Int64}\n)\n\nRemoves internal metabolites ii from the remaining inputs by converting each metabolite i ∈ ii into a pair of sink and source metabolites. Returns an updated copy of inputs S, mets, rxns, and smiles.\n\nS is the m by n stoichiometry matrix.\n\nmets is the vector of metabolite names of length m.\n\nrxns is the vector of reaction names of length n.\n\nsmiles is the vector of metabolite smiles matching mets.\n\nii is the vector of metabolite indices to exchange for pairs of sinks/sources.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.get_source_metabolites","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.get_source_metabolites","text":"get_source_metabolites(S::Matrix{Int16})\n\nReturns a vector of all source metabolites in stoichiometry matrix S.\n\nS is the m by n stoichiometry matrix.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.get_max_atoms","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.get_max_atoms","text":"get_max_atoms(s::Vector{String}, a::Symbol)\n\nReturns the maximum number of atoms of type a for each SMILES string in s. Returns a vector of all source metabolites in stoichiometry matrix S.\n\ns is the vector of metabolite SMILES strings.\n\na is a periodic table element symbol.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.map_reaction_strings","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.map_reaction_strings","text":"map_reaction_strings(#\n S::Matrix{<:Real},\n smiles::Vector{String},\n rxns::Vector{String},\n H::Bool=false\n)\n\nConstructs reaction strings from the smiles and then returns the atom-mapped reaction strings via RXNMapper.\n\nS is the stoichiometry matrix.\n\nsmiles is the vector of SMILES strings for metabolites in S.\n\nrxns is the vector of reaction names in S.\n\nH = false will not check for hydrogen conservation in each reaction.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.precompute_atom_tracing_dictionary","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.precompute_atom_tracing_dictionary","text":"precompute_atom_tracing_dictionary(#\n S::Matrix{Int16},\n ms::Vector{String},\n amax::Vector{Int64},\n a::Symbol\n)\n\nPrecomputes a dictionary mapping each atom in a given substrate stoichiometric copy to its product atom across every reaction. The dictionary is used in steady_state_efm_distribution.\n\nS is the stoichiometry matrix.\n\nms is the vector of mapped reaction SMILES strings.\n\namax is the total number of atom a in each metabolite row of S.\n\na is a periodic table element symbol.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution-Tuple{Matrix{<:Integer}, Vector{<:Real}, Vector{String}, Tuple{Int64, Int64, Symbol}}","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution","text":"steady_state_efm_distribution(#\n S::Matrix{<:Integer},\n v::Vector{<:Real},\n ms::Vector{String},\n I::Tuple{Int64,Int64,Symbol},\n D::Dict{#\n NTuple{4,Int64},\n Tuple{Int64,Int64}\n } = Dict{NTuple{4,Int64}, Tuple{Int64,Int64}}();\n solver = nothing,\n verbose::Bool = true\n)\n\nEnumerates the atomic EFMs from stoichiometry matrix S and compute the steady state probabilities of each EFM according to the discrete-time, cycle-history Markov chain.\n\nS is a fully-connected, unimolecular, m by n stoichiometry matrix with m metabolites and n reactions.\n\nv is the n-length steady state flux vector associated with S.\n\nms is the vector of mapped reaction SMILES strings.\n\nI is a triplet of the metabolite row index in S, the atom index, and the atom index type. It is the initial starting state for rooting the cycle-history Markov chain.\n\nD is the precomputed dictionary from precompute_atom_tracing_dictionary.\n\nsolver is the type used for eigenvector calculations. Default is nothing and LinearSolve will pick the best solver. Consult LinearSolve.jl for specifying other solvers.\n\n\n\n\n\n","category":"method"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.get_efm_metabolite_atom_indices","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.get_efm_metabolite_atom_indices","text":"get_efm_metabolite_atom_indices(res::CHMCAtomicSummary, i::Int64)\n\nConverts the sequence of metabolite indices for atomic EFM index i into metabolite names. The length of the vector of metabolite names is one element shorter than res.e[i] because the pseudometabolite connecting sink and source reactions is omitted.\n\nres are the results from steady_state_efm_distribution.\n\ni is the index for a given EFM.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.get_efm_reaction_atom_indices","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.get_efm_reaction_atom_indices","text":"get_efm_reaction_indices(res::CHMCAtomicSummary, i::Int64)\n\nConverts the sequence of metabolite indices for atomic EFM index i into reaction names. \n\nres are the results from steady_state_efm_distribution.\n\ni is the index for a given EFM.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.chmc_to_mc_matrix","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.chmc_to_mc_matrix","text":"chmc_to_mc_matrix(res::CHMCAtomicSummary, v::Vector{<:Real})\n\nConverts CHMC transition matrix res.T to a Markov chain with probabilities taken from steady state flux vector v.\n\nres are the results from steady_state_efm_distribution.\n\nv is the steady state flux vector used as input from steady_state_efm_distribution.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.export_atom_tracing_dictionary","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.export_atom_tracing_dictionary","text":"export_atom_tracing_dictionary(#\n fname::String,\n D::Dict{NTuple{4, Int64}, Tuple{Int64, Int64}}\n)\n\nExport atom tracing dictionary D to text file fname.\n\nfname is the filename to write the atom tracing dictionary results.\n\nD is the dictionary from precompute_atom_tracing_dictionary.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.import_atom_tracing_dictionary","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.import_atom_tracing_dictionary","text":"import_atom_tracing_dictionary(fname::String)\n\nImport atomic tracing dictionary from text file fname.\n\nfname is the filename containing the atom tracing dictionary results.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#MarkovWeightedEFMs.CHMC.Atomic.preprocess_all_for_atomic_chmc","page":"Atomic CHMC","title":"MarkovWeightedEFMs.CHMC.Atomic.preprocess_all_for_atomic_chmc","text":"preprocess_all_for_atomic_chmc(#\n S::Matrix{<:Real},\n v::Vector{<:Real},\n mets::Vector{String},\n rxns::Vector{String},\n smiles::Vector{String},\n atom::Symbol\n)\n\nWrapper function to run pre-processing functions and return the updated model, atomic info, and error/warning logs.\n\nS is the m by n stoichiometry matrix. v is the steady state flux vector of length n. mets is the vector of metabolite names of length m. rxns is the vector of reaction names of length n. smiles is the vector of metabolite SMILES strings of length m. a is a periodic table element symbol.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-atomic/#Index","page":"Atomic CHMC","title":"Index","text":"","category":"section"},{"location":"library/chmc-atomic/","page":"Atomic CHMC","title":"Atomic CHMC","text":"Pages = [\"chmc-atomic.md\"]","category":"page"},{"location":"library/chmc-plots-atomic/#Plotting-(ACHMC)","page":"Plotting (ACHMC)","title":"Plotting (ACHMC)","text":"","category":"section"},{"location":"library/chmc-plots-atomic/#Atomic-CHMC","page":"Plotting (ACHMC)","title":"Atomic CHMC","text":"","category":"section"},{"location":"library/chmc-plots-atomic/","page":"Plotting (ACHMC)","title":"Plotting (ACHMC)","text":"plot_mapped_reaction\nplot_atomic_chmc","category":"page"},{"location":"library/chmc-plots-atomic/#MarkovWeightedEFMs.Plots.plot_mapped_reaction","page":"Plotting (ACHMC)","title":"MarkovWeightedEFMs.Plots.plot_mapped_reaction","text":"function plot_mapped_reaction(#\n s::String,\n fname::String = \"\";\n view::Bool = false,\n canvas_width::Int64 = 3000,\n canvas_height::Int64 = 1000\n\n)\n\nPlot mapped reaction SMILES string s as an SVG and save to fname if specified.\n\ncanvas_width is the width of the SVG.\n\ncanvas_height is the height of the SVG.\n\nview = true will plot the SVG assuming a plotting backend is specified. For example, loading the ElectronDisplay package will plot the SVG to an Electron window.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-plots-atomic/#MarkovWeightedEFMs.Plots.plot_atomic_chmc","page":"Plotting (ACHMC)","title":"MarkovWeightedEFMs.Plots.plot_atomic_chmc","text":"function plot_atomic_chmc(#\n res::CHMCAtomicSummary,\n S::Matrix{Int16},\n mets::Vector{String},\n rs::Vector{String};\n node_label_textsize::Real=15,\n edge_label_textsize::Real=12,\n arrow_shift::Real=0.85,\n x_pad::Real=0.75,\n y_pad::Real=0.75,\n tfactor::Real=0.15,\n tangents::Tuple{#\n Tuple{<:Real, <:Real},\n Tuple{<:Real, <:Real}\n } = ((1,0),(0,1)),\n show_all::Bool=false,\n width::Int64=620,\n height::Int64=310\n\n)\n\nPlot atomic cycle-history Markov chain.\n\nS is the m by n stoichiometry matrix.\n\nmets is the vector of metabolite names of length m.\n\nrs is the vector of reaction SMILES strings of length n.\n\nnode_label_textsize is the text size of the node labels indexed from T.\n\nedge_label_textsize is the text size of the edge labels taken from T.\n\narrow_shift is the percentage shift of the arrow head from src to dst.\n\nx_pad is the left/right x coordinate padding of the plotting box.\n\ny_pad is the up/down y coordinate padding of the plotting box.\n\ntfactor scales the distance of the bezier control point relative to the distance of the src and dst nodes.\n\ntangents is the tangent of the src vertex and dst vertex.\n\nshow_all=true explicitly plots the upstream transition from all EFMs that pass through the initial state/node I. By default, these arrows stemming from the green nodes are omitted for visual clarity.\n\nwidth and height specify the plotting window dimensions in pixel units.\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-plots-atomic/#Index","page":"Plotting (ACHMC)","title":"Index","text":"","category":"section"},{"location":"library/chmc-plots-atomic/","page":"Plotting (ACHMC)","title":"Plotting (ACHMC)","text":"Pages = [\"chmc-plots.md\"]","category":"page"},{"location":"library/chmc-standard/#CHMC","page":"CHMC","title":"CHMC","text":"","category":"section"},{"location":"library/chmc-standard/#Public-functions","page":"CHMC","title":"Public functions","text":"","category":"section"},{"location":"library/chmc-standard/","page":"CHMC","title":"CHMC","text":"MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution(S::Matrix{<:Integer}, v::Vector{<:Real}, I::Int64=1)\nMarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution(T::Matrix{<:Real}, I::Int64=1)\nstoichiometry_to_transition_matrix\nreshape_efm_matrix\nreshape_efm_vector","category":"page"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution","text":"steady_state_efm_distribution(#\n S::Matrix{<:Integer},\n v::Vector{<:Real},\n I::Int64 = 1;\n solver = nothing,\n issparse::Bool = false\n)\n\nEnumerate the EFMs from stoichiometry matrix S and compute the steady state probabilities of each EFM according to the discrete-time, cycle-history Markov chain.\n\nS is a fully-connected, unimolecular, m by n stoichiometry matrix with m metabolites and n reactions.\n\nv is the n-length steady state flux vector associated with S.\n\nI is the initial starting state for rooting the cycle-history Markov chain. The choice of initial starting state does not affect the steady state EFM probabilities. The default is 1 and must be a whole number between 1:m.\n\nsolver is the type used for eigenvector calculations. Default is nothing and LinearSolve will pick the best solver. Consult LinearSolve.jl for specifying other solvers.\n\nissparse is true will use a sparse transition probability for the CHMC to save memory.\n\nExample\n\njulia> S = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 1 -1 0\n 0 0 0 0 0 0 0 0 0 1 -1\n 0 0 0 0 0 0 0 1 -1 0 0\n];\njulia> v = [3, 2, 1, 2, 3, 2, 2, 1, 1, 3, 3];\njulia> res = steady_state_efm_distribution(S, v);\njulia> res.e # EFM state sequences\n6-element Vector{Vector{Int64}}:\n [3, 2, 3]\n [3, 2, 4, 5, 3]\n [3, 5, 3]\n [6, 1, 2, 4, 5, 6]\n [7, 5, 7]\n [6, 1, 2, 3, 5, 6]\n\njulia> res.p # EFM probabilities\n6-element Vector{Float64}:\n 0.10638297872340426\n 0.0425531914893617\n 0.25531914893617025\n 0.1914893617021277\n 0.14893617021276595\n 0.25531914893617025\n\njulia> res.w # EFM weights\n6-element Vector{Float64}:\n 0.7142857142857142\n 0.2857142857142857\n 1.7142857142857144\n 1.2857142857142858\n 0.9999999999999999\n 1.7142857142857144\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution-2","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.steady_state_efm_distribution","text":"steady_state_efm_distribution(#\n T::Union{Matrix{<:Real}, SparseMatrixCSC{Float64, Int64}},\n I::Int64 = 1;\n solver = nothing,\n verbose::Bool = true\n)\n\nEnumerate the EFMs from (right) transition probability matrix T whose rows sum to one, and compute the steady state probabilities of each EFM according to the discrete-time, cycle-history Markov chain.\n\nT is the discrete-time transition probability matrix with probabilities proportional to the outgoing fluxes.\n\nI is the initial starting state for rooting the cycle-history Markov chain. The choice of initial starting state does not affect the steady state EFM probabilities. The default is 1 and must be a whole number between 1:m.\n\nsolver is the type used for eigenvector calculations. Default is nothing and LinearSolve will pick the best solver. Consult LinearSolve.jl for specifying other solvers.\n\nExample\n\njulia> T = [#\n 0.0 1.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.5 0.5 0.0 0.0 0.0\n 0.0 0.25 0.0 0.0 0.75 0.0 0.0\n 0.0 0.0 0.0 0.0 1.0 0.0 0.0\n 0.0 0.0 0.333333 0.0 0.0 0.5 0.166667\n 1.0 0.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.0 0.0 1.0 0.0 0.0\n];\njulia> res = steady_state_efm_distribution(T);\njulia> res.e # EFM state sequences\n6-element Vector{Vector{Int64}}:\n [3, 2, 3]\n [3, 2, 4, 5, 3]\n [3, 5, 3]\n [6, 1, 2, 3, 5, 6]\n [7, 5, 7]\n [6, 1, 2, 4, 5, 6]\n\njulia> res.p # EFM probabilities\n6-element Vector{Float64}:\n 0.13723110896294213\n 0.035797649943428565\n 0.26989203316869914\n 0.20302350628312624\n 0.13926980198123254\n 0.2147858996605714\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.stoichiometry_to_transition_matrix","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.stoichiometry_to_transition_matrix","text":"stoichiometry_to_transition_matrix(S::Matrix{<:Integer}, v::Vector{<:Real})\n\nConvert stoichiometry matrix S with vector of steady state fluxes to a right stochastic transition probability matrix with rows summing to one.\n\nS is the m by n stoichiometry matrix with m metabolites and n reactions.\n\nv is the steady state flux vector with length n.\n\nExamples\n\njulia> S = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 -1 1 0\n 0 0 0 0 0 0 0 1 0 0 -1\n 0 0 0 0 0 0 0 0 1 -1 0\n]\njulia> v = [2, 2, 2, 2, 2, 2, 2, 2, 4]\njulia> stoich_to_transition(S, v)\n7x7 Matrix{Float64}:\n 0.0 1.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.5 0.5 0.0 0.0 0.0\n 0.0 0.25 0.0 0.0 0.75 0.0 0.0\n 0.0 0.0 0.0 0.0 1.0 0.0 0.0\n 0.0 0.0 0.333333 0.0 0.0 0.5 0.166667\n 1.0 0.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.0 0.0 1.0 0.0 0.0\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.reshape_efm_matrix","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.reshape_efm_matrix","text":"reshape_efm_matrix(ϕ::Matrix{Int64}, S::Matrix{<:Real})\n\nConvert a matrix of EFMs ϕ to a nested vector of EFMs from a stoichiometry matrix S. Stoichiometry matrix may only contain unimolecular reactions.\n\nϕ is the n by k EFM matrix with n reactions (rows) and k EFMs (cols).\n\nS is the m by n stoichiometry matrix with m metabolites (rows) and n reactions (cols).\n\nExamples\n\njulia> ϕ = [#\n 1 1 0 0 0 0\n 1 0 1 0 0 0\n 0 0 1 0 0 1\n 0 1 0 0 0 1\n 1 0 0 1 0 0\n 0 0 0 1 0 1\n 0 1 0 0 0 1\n 1 1 0 0 0 0\n 0 0 0 0 1 0\n 0 0 0 0 1 0\n 1 1 0 0 0 0\n]\njulia> S = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 -1 1 0\n 0 0 0 0 0 0 0 1 0 0 -1\n 0 0 0 0 0 0 0 0 1 -1 0\n]\njulia> efm_vector = reshape_efm_matrix(ϕ, S)\n6-element Vector{Vector{Int64}}:\n [1, 2, 3, 5, 6, 1]\n [1, 2, 4, 5, 6, 1]\n [2, 3, 2]\n [3, 5, 3]\n [5, 7, 5]\n [3, 2, 4, 5, 3]\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#MarkovWeightedEFMs.CHMC.Standard.reshape_efm_vector","page":"CHMC","title":"MarkovWeightedEFMs.CHMC.Standard.reshape_efm_vector","text":"reshape_efm_vector(ϕ::Vector{Vector{Int64}}, S::Matrix{<:Real})\n\nConvert nested vector of EFM indices ϕ with length k to an n by k matrix of EFMs based on m by n stoichiometry matrix S. Stoichiometry matrix may only contain unimolecular reactions.\n\nϕ is the nested vector of EFMs with length k and elements corresponding to EFM metabolite indices in S.\n\nS is the m by n stoichiometry matrix with m metabolites (rows) and n reactions (cols).\n\nExamples\n\njulia> ϕ = [#\n [1, 2, 3, 5, 6, 1],\n [1, 2, 4, 5, 6, 1],\n [2, 3, 2], [3, 5, 3], [5, 7, 5], [2, 4, 5, 3, 2]\n]\njulia> S = [#\n -1 0 0 0 0 0 0 0 0 0 1\n 1 -1 1 -1 0 0 0 0 0 0 0\n 0 1 -1 0 -1 1 0 0 0 0 0\n 0 0 0 1 0 0 -1 0 0 0 0\n 0 0 0 0 1 -1 1 -1 -1 1 0\n 0 0 0 0 0 0 0 1 0 0 -1\n 0 0 0 0 0 0 0 0 1 -1 0\n]\njulia> efm_matrix = reshape_efm_vector(ϕ, S)\n11x6 Matrix{Int64}:\n 1 1 0 0 0 0\n 1 0 1 0 0 0\n 0 0 1 0 0 1\n 0 1 0 0 0 1\n 1 0 0 1 0 0\n 0 0 0 1 0 1\n 0 1 0 0 0 1\n 1 1 0 0 0 0\n 0 0 0 0 1 0\n 0 0 0 0 1 0\n 1 1 0 0 0 0\n\n\n\n\n\n","category":"function"},{"location":"library/chmc-standard/#Index","page":"CHMC","title":"Index","text":"","category":"section"},{"location":"library/chmc-standard/","page":"CHMC","title":"CHMC","text":"Pages = [\"chmc-standard.md\"]","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Boilerplate-code-for-ACHMC-analysis-of-BiGG-models","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"The following code is provided to construct ACHMC models of BiGG metabolic models (and others) stored in the SBML file format. Each code block is designed to be standalone with calculations saved to file and re-loaded in a subsequent code block. Since metabolic models can be quite complex, individual pre-processesing functions are used rather than the wrapper function preprocess_all_for_atomic_chmc. Unfortunately, BiGG does not store SMILES strings so these will need to be manually compiled by the user.","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"Note we recommend starting with relatively small networks (<500 metabolites and reactions in the original metabolic model) for computational feasibility before scaling to larger ones.","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Inputs-(from-BiGG)","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Inputs (from BiGG)","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"This section shows how to extract relevant information from a BiGG metabolic model called e_coli_core.xml","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"# Import file names\nim_sbml = \"e_coli_core.xml\"\n\n# Export file names\nex_stoich = \"stoich.csv\"\nex_metabolites_compartments = \"metabolites-compartments.csv\"\nex_reactions = \"reactions.csv\"\nex_formulas = \"metabolite-formulas.csv\"\n\n# Packages\nusing SBML, CSV, Tables\n\n# Load SBML model\nmdl = readSBML(im_sbml)\nmetabolites, reactions, S = stoichiometry_matrix(mdl)\n\n# Dense stoichiometry matrix\nS = Array(S)\n\n# Metabolite names\nmets = [mdl.species[m].name for m in metabolites]\nmets = replace.(mets, \" \" => \"_\")\n\n# Metabolite names concatenated with compartment\nmetsc = [#\n join([mdl.species[m].name, mdl.species[m].compartment], \"_\")\n for m in metabolites\n]\nmetsc = replace.(metsc, \" \" => \"_\")\n\n# Metabolite formulas\nformulas = [mdl.species[m].formula for m in metabolites]\nformulas[isnothing.(formulas)] .= \"\"\n\n# Reaction names\nrxns = [mdl.reactions[r].name for r in reactions]\n\n# Export to text file\nCSV.write(ex_stoich, Tables.table(S), header = false)\nCSV.write(ex_metabolites, Tables.table(mets), header = false)\nCSV.write(ex_metabolites_compartments, Tables.table(metsc), header = false)\nCSV.write(ex_reactions, Tables.table(rxns), header = false)\nCSV.write(ex_formulas, Tables.table(formulas), header = false)","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Pre-processing-inputs-(for-AEFM-enumeration)","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Pre-processing inputs (for AEFM enumeration)","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"This section pre-processes the BiGG inputs to meet the ACHMC requirements.","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"# Import file names\nim_stoich = \"stoich.csv\"\nim_mets = \"metabolites-compartments.csv\"\nim_rxns = \"reactions.csv\"\nim_smiles = \"smiles-isomeric.csv\"\n\n# Export file names\nex_stoich = \"stoichiometry-matrix-processed.csv\"\nex_mets = \"metabolites-processed.csv\"\nex_rxns = \"reactions-processed.csv\"\nex_smiles = \"smiles-isomeric-processed.csv\"\nex_reaction_smiles = \"reaction-smiles-processed.csv\"\nex_mapped_reaction_smiles = \"mapped-reaction-smiles-strings-processed.csv\"\nex_dict_carbon = \"dictionary-atom-tracing-carbon.csv\"\n\n# Packages\nusing CSV, Tables, MarkovWeightedEFMs, BenchmarkTools\n\n## Load previous inputs\n# Stoichiometry matrix\nS = CSV.read(im_stoich, Tables.matrix, header = false)\n\n# Metabolites\nmets = vec(CSV.read(im_mets, Tables.matrix, header = false))\n\n# Reactions\nrxns = String.(vec(CSV.read(im_rxns, Tables.matrix, header = false)))\n\n## Pre-processing\n# (1) Identify problems with S/v inputs\nerrors = find_atomic_chmc_input_errors(S)\nprint(errors) # summary of errors associated with S\n\n# (2) Clean S inputs\nS2, mets2, rxns2 = correct_atomic_chmc_input_errors(errors, S, mets, rxns)\nprint(find_atomic_chmc_input_errors(S2)) # confirm errors have been fixed\n\n# (3) Construct vector of smiles corresponding to the remaining metabolites in S\n# The SMILES strings for pseudometabolites with no defined chemical structure\n# are given an arbitrary SMILES of 'R' (or character that does not represent\n# a periodic table element)\n# SMILES strings matching S2\nsmiles3 = vec(CSV.read(im_smiles, Tables.matrix, header = false))\n\n# (4) Remove pseudometabolites and reactions exceeding RXNMapper character limit\nS4, mets4, rxns4, smiles4, i4 = correct_atomic_chmc_input_smiles(#\n S2, mets2, rxns2, smiles3\n)\ni4.dropped_rows_pseudometabolites # pseudometabolite rows removed from S2\ni4.dropped_cols_pseudometabolites # pseudometabolite reactions removed from S2\ni4.dropped_cols_rxnmapper_limit # reactions in S2 removed bc of RXNMapper limit\nprint(find_atomic_chmc_input_errors(S4)) # confirm no errors\n\n# (5) Construct the reaction strings and map atoms via RXNMAPPER\nsmiles5 = canonicalize_smiles(smiles4) # smiles strings must be canonicalized!\nrs5, ms5 = map_reaction_strings(S4, smiles5, rxns4, false)\n\n# (6) Precompute atom tracing dictionary (for carbons)\namax = get_max_atoms(smiles5, :C)\nD_C = precompute_atom_tracing_dictionary(S4, ms5, amax, :C)\n\n# Export to text file\nCSV.write(ex_stoich, Tables.table(S4), header = false)\nCSV.write(ex_mets, Tables.table(mets4), header = false)\nCSV.write(ex_rxns, Tables.table(rxns4), header = false, quotestrings = true)\nCSV.write(ex_smiles, Tables.table(smiles5), header = false)\nCSV.write(ex_reaction_smiles, Tables.table(rs5), header = false)\nCSV.write(ex_mapped_reaction_smiles, Tables.table(ms5), header = false)\nCSV.write(ex_dict_carbon, D_C, header = false)","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Pre-processing-inputs-(for-AEFM-weight-assignment)","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Pre-processing inputs (for AEFM weight assignment)","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"Assuming there is a steady state flux vector v, the pre-processing steps are slightly different:","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"## Pre-processing\n# (1) Identify problems with S/v inputs\nerrors = find_atomic_chmc_input_errors(S, v)\nprint(errors) # summary of errors associated with S/v\n\n# (2) Clean S/v inputs\nS2, v2, mets2, rxns2 = correct_atomic_chmc_input_errors(errors, S, v, mets, rxns)\nprint(find_atomic_chmc_input_errors(S2, v2)) # confirm errors have been fixed\n\n# (3) Construct vector of smiles corresponding to the remaining metabolites in S\nsmiles3 = vec(CSV.read(im_smiles, Tables.matrix, header = false))\n\n# (4) Remove pseudometabolites and reactions exceeding RXNMapper character limit\nS4, v4, mets4, rxns4, smiles4, i4 = correct_atomic_chmc_input_smiles(#\n S2, v2, mets2, rxns2, smiles3\n)\ni4.dropped_rows_pseudometabolites # 33 pseudometabolite rows removed from S2\ni4.dropped_cols_pseudometabolites # 46 pseudometabolite reactions removed from S2\ni4.dropped_cols_rxnmapper_limit # 3 reactions in S2 removed bc of RXNMapper limit\nprint(find_atomic_chmc_input_errors(S4, v4)) # confirm no errors\n\n# (5) Construct the reaction strings and map atoms via RXNMAPPER\nsmiles5 = canonicalize_smiles(smiles4) # smiles strings must be canonicalized!\nrs5, ms5 = map_reaction_strings(S4, smiles5, rxns, false)\n\n# (6) Precompute atom tracing dictionary (for carbons)\namax = get_max_atoms(smiles5, :C)\nD_C = precompute_atom_tracing_dictionary(S4, ms5, amax, :C)","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Enumerating-AEFMs-across-all-source-metabolite-carbons","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Enumerating AEFMs across all source metabolite carbons","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"# Verbosity of AEFM enumeration function (provides a progress meter)\nverbose = true\n\n# File names\nstoich_loc = \"stoichiometry-matrix-processed.csv\"\nsmiles_loc = \"smiles-isomeric-processed.csv\"\nmets_loc = \"metabolites-processed.csv\"\nD_C_loc = \"dictionary-atom-tracing-carbon.csv\"\nD_N_loc = \"dictionary-atom-tracing-nitrogen.csv\"\nms_loc = \"mapped-reaction-smiles-strings-processed.csv\"\nrxns_loc = \"reactions-processed.csv\"\n\n# Packages\nusing CSV, Tables, MarkovWeightedEFMs, JLD2, Dates\n\n## Load final data\n# Load stoichiometry matrix\nS = Int16.(CSV.read(stoich_loc, Tables.matrix, header = false))\n\n# Load SMILES strings matching the stoichiometry rows\nsmiles = vec(CSV.read(smiles_loc, Tables.matrix, header = false))\n\n# Load metabolites\nmets = vec(CSV.read(mets_loc, Tables.matrix, header = false))\n\n# Load atom tracing dictionary\nD_C = import_atom_tracing_dictionary(D_C_loc)\n\n# Load mapped reaction smiles strings\nms = vec(CSV.read(#\n ms_loc, Tables.matrix, delim = ';', ignoreemptyrows = false, header = false\n))\ng(x) = ismissing(x) ? \"\" : x\nms = g.(ms)\n\n# Load reactions\nrxns = String.(vec(CSV.read(rxns_loc, Tables.matrix, header = false)))\n\n## Enumerate atomic efms\n# Identify indices of all source metabolites and number of carbons/nitrogens\nsrcs = get_source_metabolites(Int16.(S))\namax_C = get_max_atoms(smiles, :C)\n\nstart_time = Dates.now()\nfor k in eachindex(srcs)\n res_dir = \"$k-\" * mets[srcs[k]]\n isdir(res_dir) || mkdir(res_dir)\n for l in 1:amax_C[srcs[k]]\n I = (srcs[k], l, :C)\n res = enumerate_atomic_efms(S, ms, I, D_C; verbose = verbose)\n end\nend\nend_time = Dates.now()\nttime = end_time - start_time\n\n@info \"It took $ttime to enumerate all carbon AEFMs.\"","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/#Computing-AEFM-weights-across-all-source-metabolite-carbons","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Computing AEFM weights across all source metabolite carbons","text":"","category":"section"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"Decomposing fluxes onto AEFMs uses the function steady_state_efm_distribution() requires the steady state fluxes v:","category":"page"},{"location":"tutorials/boilerplate-for-bigg-gems/","page":"Boilerplate code for ACHMC analysis of BiGG models","title":"Boilerplate code for ACHMC analysis of BiGG models","text":"for k in eachindex(srcs)\n res_dir = \"$k-\" * mets[srcs[k]]\n isdir(res_dir) || mkdir(res_dir)\n for l in 1:amax_C[srcs[k]]\n I = (srcs[k], l, :C)\n res = steady_state_efm_distribution(S, v, ms, I, D_C; verbose = verbose)\n end\nend","category":"page"},{"location":"#MarkovWeightedEFMs.jl","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"MarkovWeightedEFMs.jl is a package to decompose steady state metabolic fluxes onto elementary flux mode (EFM) weights and atomic elementary flux mode (AEFM) weights. EFM flux decomposition works only for closed-loop networks of unimolecular reactions. AEFM flux decomposition works on metabolic flux networks with known metabolite structures.","category":"page"},{"location":"#Usage","page":"MarkovWeightedEFMs.jl","title":"Usage","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"See Getting started for package installation and Python dependencies (RXNMapper) for AEFM enumeration and flux decomposition. Once installed, the package is loaded in a julia session by typing:","category":"page"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"julia> using MarkovWeightedEFMs","category":"page"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"See the tutorial sections for EFM or AEFM enumeration and flux decomposition.","category":"page"},{"location":"#Citing-MarkovWeightedEFMs.jl","page":"MarkovWeightedEFMs.jl","title":"Citing MarkovWeightedEFMs.jl","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"Please cite the following papers if you use our method for (A)EFM enumeration and flux decomposition.","category":"page"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"Justin G. Chitpin and Theodore J. Perkins, Atomic elementary flux modes explain the steady state flow of metabolites in flux networks. biorXiv preprint doi: XX.XXXX/XXXX.XX.XX.XXXXXX","category":"page"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"Justin G. Chitpin and Theodore J. Perkins, A Markov constraint to uniquely identify elementary flux mode weights in unimolecular metabolic networks. J Theor Biol. 2023 Nov 7;575:111632. doi: 10.1016/j.jtbi.2023.111632","category":"page"},{"location":"#License","page":"MarkovWeightedEFMs.jl","title":"License","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"This software is released under the MIT license.","category":"page"},{"location":"#Contact-information","page":"MarkovWeightedEFMs.jl","title":"Contact information","text":"","category":"section"},{"location":"","page":"MarkovWeightedEFMs.jl","title":"MarkovWeightedEFMs.jl","text":"Justin G. Chitpin at jchit069@uottawa.ca for questions.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#ACHMC-(for-AEFMs;-quickstart)","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"This section shows how to use the wrapper function in MarkovWeightedEFMs.jl to enumerate and assign AEFMs weights in a simple, multispecies reaction network.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"(Image: Toy multispecies network)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"# Bodge until I figure out how to install Python and RXMapper on Git workflows\nusing MarkovWeightedEFMs\nusing SparseArrays\n\nS = [#\n 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # Glc\n 0 -1 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 # ATP\n 0 1 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 # G6P\n 0 1 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 # ADP\n 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 # 6PG\n 0 0 0 0 1 -1 1 0 0 0 0 0 0 0 0 0 # F6P\n 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 # Pi\n 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 # H2O\n 0 0 0 0 0 1 -1 -1 0 0 0 0 0 0 0 0 # FDP\n 0 0 0 0 0 0 0 1 -1 1 -1 0 0 0 0 0 # G3P\n 0 0 0 0 0 0 0 1 1 -1 0 -1 0 0 0 0 # DHAP\n]\n\nv = [10, 10, 3, 3, 7, 8, 1, 7, 1, 1, 7, 7, 18, 18, 1, 1]\n\nmets = [#\n \"Glc\",\n \"ATP\",\n \"G6P\",\n \"ADP\",\n \"6PG\",\n \"F6P\",\n \"Pi\",\n \"H2O\",\n \"FDP\",\n \"G3P\",\n \"DHAP\"\n]\n\nrxns = [#\n \"Source Glc\",\n \"Hexokinase\",\n \"G6P dehydrogenase\",\n \"Sink 6PG\",\n \"Phosphoglucose isomerase\",\n \"6-phosphofructo-1-kinase\",\n \"Fructose 1,6-bisphosphatase\",\n \"Fructose-bisphosphate aldolase\",\n \"Triose phosphate isomerase\",\n \"Triose phosphate isomerase\",\n \"Sink G3P\",\n \"Sink DHAP\",\n \"Source ATP\",\n \"Sink ADP\",\n \"Sink Pi\",\n \"Source H2O\"\n]\n\nsmiles = [#\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)OP(=O)(O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O\",\n \"C([C@H]([C@H]([C@@H](C(=O)CO)O)O)O)OP(=O)(O)O\",\n \"[O-]P(=O)([O-])[O-]\",\n \"O\",\n \"C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O\",\n \"C([C@H](C=O)O)OP(=O)(O)O\",\n \"C(C(=O)COP(=O)(O)O)O\"\n]\n\natom = :C # carbon atom type for AEFMs\n\nmdl, atom_info, logs = preprocess_all_for_atomic_chmc(S, v, mets, rxns, smiles, atom)\n\nI = (1, 1, atom)\nks = Int16.([5, 4, 6, 7, 2, 8, 3, 1])\nvs = [(Int16(6), Int16(6)), (Int16(0), Int16(0)), (Int16(9), Int16(4)), (Int16(11), Int16(2)), (Int16(3), Int16(1)), (Int16(10), Int16(1)), (Int16(5), Int16(3)), (Int16(1), Int16(1))]\ndmc = Dict(zip(ks, vs))\n\nks = [#\n Int16.([1, 2, 5, 6, 7]),\n Int16.([1, 2, 5, 6]),\n Int16.([1, 2, 5, 6, 7, 4]),\n Int16.([1]),\n Int16.([1, 2, 3]),\n Int16.([1, 2, 3, 4]),\n Int16.([1, 2]),\n Int16.([1, 2, 5]),\n Int16.([1, 2, 5, 6, 7, 8]),\n Int16.([1, 2, 5, 6, 7, 8, 4])\n]\nvs = [#\n (id = 7, children = Int16.([8])),\n (id = 6, children = Int16.([7])),\n (id = 8, children = Int16.([])),\n (id = 1, children = Int16.([2])),\n (id = 3, children = Int16.([])),\n (id = 4, children = Int16.([])),\n (id = 2, children = Int16.([3, 5])),\n (id = 5, children = Int16.([6])),\n (id = 9, children = Int16.([])),\n (id = 10, children = Int16.([]))\n]\ndchmc = Dict(zip(ks, vs))\n\nT = SparseMatrixCSC([\n 0 1.0 0 0 0 0 0 0 0 0\n 0 0 0.3 0 0.7 0 0 0 0 0\n 0 0 0 1.0 0 0 0 0 0 0\n 1.0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 1.0 0 0 0 0\n 0 0 0 0 0.125 0 0.875 0 0 0\n 0 0 0 0 0 0 0 0.875 0.125 0\n 1.0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0.125 0 0 0.875\n 1.0 0 0 0 0 0 0 0 0 0\n])\n\nR = [#\n (i = 1, j = 2, k = Int16(2)),\n (i = 2, j = 3, k = Int16(3)),\n (i = 2, j = 5, k = Int16(5)),\n (i = 3, j = 4, k = Int16(4)),\n (i = 4, j = 1, k = Int16(4)),\n (i = 5, j = 6, k = Int16(6)),\n (i = 6, j = 5, k = Int16(7)),\n (i = 6, j = 7, k = Int16(8)),\n (i = 7, j = 8, k = Int16(12)),\n (i = 8, j = 1, k = Int16(12)),\n (i = 7, j = 9, k = Int16(10)),\n (i = 9, j = 10, k = Int16(11)),\n (i = 10, j = 1, k = Int16(11)),\n (i = 9, j = 7, k = Int16(9))\n]\n\nres = CHMCAtomicSummary(#\n (1, 1, :C),\n [#\n (EFM = [6, 5, 6], Closures = [(6, 5)]),\n (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)]),\n (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)]),\n (EFM = [8, 7, 8], Closures = [(9, 7)]),\n (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)])\n ],\n [0.09000000000000001, 0.56, 0.27, 0.01, 0.07],\n [1.0, 6.222222222222222, 3.0, 0.11111111111111112, 0.7777777777777778],\n dmc,\n dchmc,\n T,\n R\n)\n\nres_enum = CHMCAtomicSummary(#\n (1, 1, :C),\n [#\n (EFM = [6, 5, 6], Closures = [(6, 5)]),\n (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)]),\n (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)]),\n (EFM = [8, 7, 8], Closures = [(9, 7)]),\n (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)])\n ],\n nothing,\n nothing,\n dmc,\n dchmc,\n T,\n R\n)\n\nefm_seq_1 = [\"FDP\", \"F6P\", \"FDP\"]\nefm_seq_2 = [\"Glc\", \"G6P\", \"F6P\", \"FDP\", \"DHAP\"]","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Inputs","page":"ACHMC (for AEFMs; quickstart)","title":"Inputs","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"using MarkovWeightedEFMs\nS = [#\n 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # Glc\n 0 -1 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 # ATP\n 0 1 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 # G6P\n 0 1 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 # ADP\n 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 # 6PG\n 0 0 0 0 1 -1 1 0 0 0 0 0 0 0 0 0 # F6P\n 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 # Pi\n 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 # H2O\n 0 0 0 0 0 1 -1 -1 0 0 0 0 0 0 0 0 # FDP\n 0 0 0 0 0 0 0 1 -1 1 -1 0 0 0 0 0 # G3P\n 0 0 0 0 0 0 0 1 1 -1 0 -1 0 0 0 0 # DHAP\n]\n\nv = [10, 10, 3, 3, 7, 8, 1, 7, 1, 1, 7, 7, 18, 18, 1, 1]\n\nmets = [#\n \"Glc\",\n \"ATP\",\n \"G6P\",\n \"ADP\",\n \"6PG\",\n \"F6P\",\n \"Pi\",\n \"H2O\",\n \"FDP\",\n \"G3P\",\n \"DHAP\"\n]\n\nrxns = [#\n \"Source Glc\",\n \"Hexokinase\",\n \"G6P dehydrogenase\",\n \"Sink 6PG\",\n \"Phosphoglucose isomerase\",\n \"6-phosphofructo-1-kinase\",\n \"Fructose 1,6-bisphosphatase\",\n \"Fructose-bisphosphate aldolase\",\n \"Triose phosphate isomerase\",\n \"Triose phosphate isomerase\",\n \"Sink G3P\",\n \"Sink DHAP\",\n \"Source ATP\",\n \"Sink ADP\",\n \"Sink Pi\",\n \"Source H2O\"\n]\n\nsmiles = [#\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)OP(=O)(O)O\",\n \"C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N\",\n \"O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O\",\n \"C([C@H]([C@H]([C@@H](C(=O)CO)O)O)O)OP(=O)(O)O\",\n \"[O-]P(=O)([O-])[O-]\",\n \"O\",\n \"C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O\",\n \"C([C@H](C=O)O)OP(=O)(O)O\",\n \"C(C(=O)COP(=O)(O)O)O\"\n]\n\natom = :C # carbon atom type for AEFMs","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"We can check that the flux vector satisfies the steady state requirements.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"all(S * v .== 0) # should evaluate as true","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Pre-processing-data-(wrapper)","page":"ACHMC (for AEFMs; quickstart)","title":"Pre-processing data (wrapper)","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"The following function pre-processes the input metabolic network for computing the AEFM weights for the specified atom type.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"mdl, atom_info, logs = preprocess_all_for_atomic_chmc(S, v, mets, rxns, smiles, atom)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"The variable mdl is a NamedTuple containing the updated stoichiometry matrix, flux vector, metabolite/reaction names, metabolite SMILES strings, reaction SMILES strings, and mapped reaction SMILES strings.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"keys(mdl)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"The variable logs contains details about input metabolic network in addition to listing the pseudometabolites and pseudoreactions dropped from the network based on the input SMILES strings.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"keys(logs)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"print(logs.model_errors)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"logs.smiles_warnings","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"The variable atom_info contains the indices of all source metabolites in the updated network and the number of occurrences for the input atom of interest. It also contains an atom-mapping dictionary relating substrate-atom positions to product-atom positions in each reaction. These are useful for programmatically computing AEFMs across all source metabolite-atom combinations of interest.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"keys(atom_info)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"atom_info.src_mets # source metabolite indices","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"atom_info.max_src_met_atoms # counts of specified atom in each source metabolite","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"atom_info.D # atom-mapping dictionary","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Computing-ACHMC-for-a-given-metabolite/carbon-atom-state","page":"ACHMC (for AEFMs; quickstart)","title":"Computing ACHMC for a given metabolite/carbon atom state","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"The following atomic CHMC is rooted on the first carbon atom of the first source metabolite in the stoichiometry.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"I = (atom_info.src_mets[1], 1, atom) # initial state is 1st carbon of canonicalized glucose\nres = steady_state_efm_distribution(mdl.S, mdl.v, mdl.ms, I, atom_info.D; verbose = false) # S must be Matrix{Int16}","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"If we only wanted to enumerate the AEFMs, we would run:","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res_enum = enumerate_atomic_efms(mdl.S, mdl.ms, I, atom_info.D, verbose = false)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"Both functions produce the same output structure res, except that the AEFM flux decomposition fields will be empty. The transition matrix will also default to uniformly distributed probabilities along each row.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Output","page":"ACHMC (for AEFMs; quickstart)","title":"Output","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"The output res is an immutable struct with 8 fields:","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.i is a tuple storing (i) the source metabolite index, (ii) source metabolite atom index (based on canonicalized SMILES string), and (iii) the atom type. This is a copy of the variable I.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.i","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.e is an array of AEFMs with all corresponding simple cycle closures.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.e","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.p is an array of AEFM probabilities normalized to one.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.p","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.w is an array of AEFM weights normalized by the (unimolecular) reaction flux of the source metabolite.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.w","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.dchmc is a dictionary storing the ACHMC. The keys are the ACHMC states (composed of Markov chain states in res.dmc). The values are the ACHMC state and the Markov chain state children.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.dchmc","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.dmc is a dictionary converting Markov chain states to metabolite-atom positions. The value (0, 0) always corresponds to the external environment sink node (which connects back to the source metabolite-atom state).","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.dmc","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.T is a sparse array storing the ACHMC transition probability matrix.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.T","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.R is an array of tuples storing the reaction index/indices mapped to each ACHMC transition matrix element.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"res.R","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Converting-AEFM-to-sequence-of-metabolites","page":"ACHMC (for AEFMs; quickstart)","title":"Converting AEFM to sequence of metabolites","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"The corresponding AEFMs correspond to the movement of metabolite/atom states through the reaction network. We can convert these states into metabolites using get_efm_metabolite_atom_indices. Note that there is one fewer metabolite name than AEFM metabolite indices because the pseudometabolite (0, 0) linking sink and source reactions is omitted.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"# First AEFM\nefm_seq_1 = mets[first.(get_efm_metabolite_atom_indices(res, 1))]","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"efm_seq_1","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"# Second AEFM\nefm_seq_2 = mets[first.(get_efm_metabolite_atom_indices(res, 2))]","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"efm_seq_2","category":"page"},{"location":"tutorials/chmc-atomic-glucose/#Visualizing-the-CHMC-and-mapped-reactions","page":"ACHMC (for AEFMs; quickstart)","title":"Visualizing the CHMC and mapped reactions","text":"","category":"section"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"The following plotting function visualizes the ACHMC rooted on state I. This is only recommended for exploring ACHMCs of small networks.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"using GLMakie # Makie backend\nGLMakie.activate!()\n\nplot_atomic_chmc(res, S, mets, rs)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"Each node in the main panel corresponds to a CHMC state (metabolite and atomic index).","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"(Image: ACHMC main panel)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"Clicking on a CHMC transition will highlight that transition and display the corresponding metabolic reaction on the upper panel. The pair of purple highlighted atoms correspond to the movement of the same atom from the LHS to RHS of the reaction.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"(Image: ACHMC main and upper panel)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"Finally, the reaction and mapped reaction SMILES strings can also be plotted as an SVG and previewed using a package like ElectronDisplay. If fname != \"\", the SVG is also saved to file. By default, fname == \"\" and the SVG is not saved. The default canvas width and height are 1420 by 580 (pixels) but these can be changed. If using ElectronDisplay and the image is cut off, try resizing the plotting window or reducing the canvas dimensions.","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"using ElectronDisplay\n\n# Reaction string\nplot_mapped_reaction(rs[2], view=true, canvas_width = 1420, canvas_height = 580)\n#plot_mapped_reaction(rs[2], \"\\path\\to\\save\\name.svg\", view=true)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"(Image: Reaction SMILES string)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"# Mapped reaction string\nplot_mapped_reaction(ms[2], view = true, canvas_width = 1420, canvas_height = 580)\n#plot_mapped_reaction(ms[2], \"\\path\\to\\save\\name.svg\", view = true)","category":"page"},{"location":"tutorials/chmc-atomic-glucose/","page":"ACHMC (for AEFMs; quickstart)","title":"ACHMC (for AEFMs; quickstart)","text":"(Image: Mapped reaction SMILES string)","category":"page"},{"location":"installation/python-dependencies/#Exact-Python-dependencies-for-RXNMapper","page":"Exact Python dependencies for RXNMapper","title":"Exact Python dependencies for RXNMapper","text":"","category":"section"},{"location":"installation/python-dependencies/#Python-version","page":"Exact Python dependencies for RXNMapper","title":"Python version","text":"","category":"section"},{"location":"installation/python-dependencies/","page":"Exact Python dependencies for RXNMapper","title":"Exact Python dependencies for RXNMapper","text":"(rxnmapper-virtual-environment)\n$ python\nPython 3.10.14 (main, Jul 31 2024, 21:14:36) [GCC 14.1.1 20240720] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import sys\n>>> print(sys.version)\n3.10.14 (main, Jul 31 2024, 21:14:36) [GCC 14.1.1 20240720]","category":"page"},{"location":"installation/python-dependencies/#Dependencies-list","page":"Exact Python dependencies for RXNMapper","title":"Dependencies list","text":"","category":"section"},{"location":"installation/python-dependencies/","page":"Exact Python dependencies for RXNMapper","title":"Exact Python dependencies for RXNMapper","text":"(rxnmapper-virtual-environment)\n$ pip list --local\n\nPackage Version\n------------------------ -----------\nannotated-types 0.7.0\nattrs 24.2.0\nbeautifulsoup4 4.12.3\nbs4 0.0.2\ncertifi 2024.7.4\ncharset-normalizer 3.3.2\nclick 8.1.7\nCTSgetPy 0.0.2\ndiskcache 5.6.3\ndnspython 2.6.1\nfilelock 3.15.4\nfsspec 2024.6.1\nhuggingface-hub 0.24.6\nidna 3.8\nJinja2 3.1.4\nMarkupSafe 2.1.5\nmpmath 1.3.0\nnetworkx 3.3\nnumpy 2.1.0\nnvidia-cublas-cu12 12.1.3.1\nnvidia-cuda-cupti-cu12 12.1.105\nnvidia-cuda-nvrtc-cu12 12.1.105\nnvidia-cuda-runtime-cu12 12.1.105\nnvidia-cudnn-cu12 9.1.0.70\nnvidia-cufft-cu12 11.0.2.54\nnvidia-curand-cu12 10.3.2.106\nnvidia-cusolver-cu12 11.4.5.107\nnvidia-cusparse-cu12 12.1.0.106\nnvidia-nccl-cu12 2.20.5\nnvidia-nvjitlink-cu12 12.6.68\nnvidia-nvtx-cu12 12.1.105\npackaging 24.1\npandas 2.2.2\npillow 10.4.0\npip 24.2\npydantic 2.8.2\npydantic_core 2.20.1\npydantic-settings 2.4.0\npymongo 4.8.0\npython-dateutil 2.9.0.post0\npython-dotenv 1.0.1\npytz 2024.1\nPyYAML 6.0.2\nrdkit 2024.3.5\nregex 2024.7.24\nrequests 2.32.3\nrxn-chem-utils 1.6.0\nrxn-utils 2.0.0\nrxnmapper 0.3.1\nsafetensors 0.4.4\nscipy 1.14.1\nsetuptools 72.1.0\nsix 1.16.0\nsoupsieve 2.6\nsympy 1.13.2\ntdqm 0.0.1\ntokenizers 0.19.1\ntorch 2.4.0\ntqdm 4.66.5\ntransformers 4.44.2\ntriton 3.0.0\ntyping_extensions 4.12.2\ntzdata 2024.1\nurllib3 2.2.2\nwheel 0.43.0","category":"page"}] } diff --git a/docs/build/tutorials/boilerplate-for-bigg-gems/index.html b/docs/build/tutorials/boilerplate-for-bigg-gems/index.html index ae0d4c1..65b1942 100644 --- a/docs/build/tutorials/boilerplate-for-bigg-gems/index.html +++ b/docs/build/tutorials/boilerplate-for-bigg-gems/index.html @@ -1,5 +1,5 @@ -Boilerplate code for ACHMC analysis of BiGG models · MarkovWeightedEFMs.jl

          Boilerplate code for ACHMC analysis of BiGG models

          The following code is provided to quickly construct ACHMC models of BiGG metabolic models and others stored in the SBML file format. Each code block is designed to be standalone with calculations saved to file and re-loaded in a subsequent code block. Unfortunately, BiGG does not store SMILES strings so these will need to be manually compiled by the user.

          Note we recommend starting with relatively small networks (<500 metabolites and reactions in the original metabolic model) for computational feasibility.

          Inputs (from BiGG)

          This section shows how to extract relevant information from a BiGG metabolic model called e_coli_core.xml

          # Import file names
          +Boilerplate code for ACHMC analysis of BiGG models · MarkovWeightedEFMs.jl

          Boilerplate code for ACHMC analysis of BiGG models

          The following code is provided to construct ACHMC models of BiGG metabolic models (and others) stored in the SBML file format. Each code block is designed to be standalone with calculations saved to file and re-loaded in a subsequent code block. Since metabolic models can be quite complex, individual pre-processesing functions are used rather than the wrapper function preprocess_all_for_atomic_chmc. Unfortunately, BiGG does not store SMILES strings so these will need to be manually compiled by the user.

          Note we recommend starting with relatively small networks (<500 metabolites and reactions in the original metabolic model) for computational feasibility before scaling to larger ones.

          Inputs (from BiGG)

          This section shows how to extract relevant information from a BiGG metabolic model called e_coli_core.xml

          # Import file names
           im_sbml = "e_coli_core.xml"
           
           # Export file names
          @@ -198,4 +198,4 @@
                   I = (srcs[k], l, :C)
                   res = steady_state_efm_distribution(S, v, ms, I, D_C; verbose = verbose)
               end
          -end
          +end
          diff --git a/docs/build/tutorials/chmc-atomic-glucose-under-the-hood/index.html b/docs/build/tutorials/chmc-atomic-glucose-under-the-hood/index.html new file mode 100644 index 0000000..5550fcc --- /dev/null +++ b/docs/build/tutorials/chmc-atomic-glucose-under-the-hood/index.html @@ -0,0 +1,200 @@ + +ACHMC (for AEFMs; under the hood) · MarkovWeightedEFMs.jl

          ACHMC (for AEFMs; under the hood)

          This section explains the pre-processing steps under the hood of preprocess_all_for_atomic_chmc() using the same multispecies reaction network from the previous tutorial.

          Toy multispecies network

          Inputs

          using MarkovWeightedEFMs
          +S = [#
          +  1 -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0 # Glc
          +  0 -1  0  0  0 -1  0  0  0  0  0  0  1  0  0  0 # ATP
          +  0  1 -1  0 -1  0  0  0  0  0  0  0  0  0  0  0 # G6P
          +  0  1  0  0  0  1  0  0  0  0  0  0  0 -1  0  0 # ADP
          +  0  0  1 -1  0  0  0  0  0  0  0  0  0  0  0  0 # 6PG
          +  0  0  0  0  1 -1  1  0  0  0  0  0  0  0  0  0 # F6P
          +  0  0  0  0  0  0  1  0  0  0  0  0  0  0 -1  0 # Pi
          +  0  0  0  0  0  0 -1  0  0  0  0  0  0  0  0  1 # H2O
          +  0  0  0  0  0  1 -1 -1  0  0  0  0  0  0  0  0 # FDP
          +  0  0  0  0  0  0  0  1 -1  1 -1  0  0  0  0  0 # G3P
          +  0  0  0  0  0  0  0  1  1 -1  0 -1  0  0  0  0 # DHAP
          +]
          +
          +v = [10, 10, 3, 3, 7, 8, 1, 7, 1, 1, 7, 7, 18, 18, 1, 1]
          +
          +mets = [#
          +  "Glc",
          +  "ATP",
          +  "G6P",
          +  "ADP",
          +  "6PG",
          +  "F6P",
          +  "Pi",
          +  "H2O",
          +  "FDP",
          +  "G3P",
          +  "DHAP"
          +]
          +
          +rxns = [#
          +  "Source Glc",
          +  "Hexokinase",
          +  "G6P dehydrogenase",
          +  "Sink 6PG",
          +  "Phosphoglucose isomerase",
          +  "6-phosphofructo-1-kinase",
          +  "Fructose 1,6-bisphosphatase",
          +  "Fructose-bisphosphate aldolase",
          +  "Triose phosphate isomerase",
          +  "Triose phosphate isomerase",
          +  "Sink G3P",
          +  "Sink DHAP",
          +  "Source ATP",
          +  "Sink ADP",
          +  "Sink Pi",
          +  "Source H2O"
          +]
          +
          +smiles = [#
          +  "C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O",
          +  "C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)OP(=O)(O)O)O)O)N",
          +  "C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)OP(=O)(O)O",
          +  "C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N",
          +  "O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O",
          +  "C([C@H]([C@H]([C@@H](C(=O)CO)O)O)O)OP(=O)(O)O",
          +  "[O-]P(=O)([O-])[O-]",
          +  "O",
          +  "C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O",
          +  "C([C@H](C=O)O)OP(=O)(O)O",
          +  "C(C(=O)COP(=O)(O)O)O"
          +]
          +
          +atom = :C # carbon atom type for AEFMs

          We can check that the flux vector satisfies the steady state requirements.

          all(S * v .== 0) # should evaluate as true
          true

          Pre-processing steps

          Checking network structure

          The following functions check for issues with the inputs. The first function find_atomic_chmc_input_errors identifies possible problems with the stoichiometry matrix and flux vector.

          # Confirm there are no issues with stoichiometry matrix
          +errors = find_atomic_chmc_input_errors(S, v)
          print(errors) # summary of errors associated with S/v
          ############################################################
          +## ERROR CHECKING STOICHIOMETRY MATRIX AND FLUX VECTOR #####
          +# (1)  SUM OF ABSOLUTE FLUX RECONSTRUCTION ERROR:
          +#      0.0
          +#      PASSED.
          +# (2)  REACTIONS THAT ARE DUPLICATES:
          +#      NONE.
          +#      PASSED.
          +# (3)  REACTIONS WTIH ZERO FLUX:
          +#      NONE.
          +#      PASSED.
          +# (4)  REACTIONS WTIH NEGATIVE FLUX:
          +#      NONE.
          +#      PASSED.
          +# (5)  INTERNAL REACTIONS W/ NON-INTEGER STOICHIOMETRIES:
          +#      NONE.
          +#      PASSED.
          +# (6)  UNIMOLECULAR SOURCE REACTIONS W/ STOICH == 1:
          +#      1, 13, 16
          +#      PASSED.
          +# (7)  UNIMOLECULAR SOURCE REACTIONS W/ STOICH != 1:
          +#      NONE.
          +#      PASSED.
          +# (8)  MULTIMOLECULAR SOURCE REACTIONS W/ STOICH == 1:
          +#      NONE.
          +#      PASSED.
          +# (9)  MULTIMOLECULAR SOURCE REACTIONS W/ STOICH != 1:
          +#      NONE.
          +#      PASSED.
          +# (10) UNIMOLECULAR SINK REACTIONS W/ STOICH == 1:
          +#      4, 11, 12, 14, 15
          +#      PASSED.
          +# (11) UNIMOLECULAR SINK REACTIONS W/ STOICH != 1:
          +#      NONE.
          +#      PASSED.
          +# (12) MULTIMOLECULAR SINK REACTIONS W/ STOICH == 1:
          +#      NONE.
          +#      PASSED.
          +# (13) MULTIMOLECULAR SINK REACTIONS W/ STOICH != 1:
          +#      NONE.
          +#      PASSED.
          +# (14) REACTIONS W/ NO SUBSTRATES OR PRODUCTS:
          +#      NONE.
          +#      PASSED.
          +# (15) # METABOLITES PARTICIPATING IN NO REACTIONS:
          +#      NONE.
          +#      PASSED.
          +# STATUS:
          +#      PASSED. THESE INPUTS SATISFY ATOMIC CHMC REQUIREMENTS.
          +############################################################

          Correcting problems in network structure

          Any problems, except for the steady state flux requirement, can be addressed via correct_atomic_chmc_input_errors.

          # S and v have no errors so the inputs are returned
          +correct_atomic_chmc_input_errors(errors, S, mets, rxns)
          +# S, mets, rxns = correct_atomic_chmc_input_errors(errors, S, mets, rxns) # otherwise

          Identifying unmappable reactions

          The next function correct_atomic_chmc_input_smiles checks and fixes problems relating to the SMILES strings. These problems are caused by RXNMapper being unable to map atoms in reactions with pseudometabolites or pseudoreactions with non-integer stoichiometries (e.g. biomass reaction). RXNMapper also has a character limit on reaction SMILES strings. These unmappable reactions are removed and the flux is balanced with unimolecular flux entering/exiting the associated reaction substrates/products.

          # Correct issues associated with RXNMapper character limit,
          +# pseudometabolites and pseudoreactions
          +S, v, mets, rxns, smiles, logs = correct_atomic_chmc_input_smiles(S, v, mets, rxns, smiles)

          At this point, the SMILES strings (matching the updated mets if there were errors in the initial inputs) should be canonicalized. S is also converted to a Matrix{Int16} which is a requirement for subsequent functions.

          smiles = canonicalize_smiles(smiles)
          smiles
          11-element Vector{String}:
          + "OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O"
          + "Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O"
          + "O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O"
          + "Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O"
          + "O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O"
          + "O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O"
          + "O=P([O-])([O-])[O-]"
          + "O"
          + "O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)C(O)C1O"
          + "O=C[C@H](O)COP(=O)(O)O"
          + "O=C(CO)COP(=O)(O)O"

          Atom mapping reactions

          The reaction SMILES strings rs are next constructed from the metabolite SMILES and the atom mapping is performed via RXNMapper and stored in ms.

          # Construct atom traced SMILES strings
          +rs, ms = map_reaction_strings(S, smiles, rxns, false)
          rs
          16-element Vector{String}:
          + ">>OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O"
          + "OC[C@H]1OC(O)[C@H](O)[C@@H](O)[" ⋯ 167 bytes ⋯ "(O)OP(=O)(O)O)[C@@H](O)[C@H]1O"
          + "O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[" ⋯ 34 bytes ⋯ "O)(O)O)[C@@H](O)[C@H](O)[C@H]1O"
          + "O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O>>"
          + "O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[" ⋯ 30 bytes ⋯ "](O)[C@H](O)[C@H](O)COP(=O)(O)O"
          + "Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP" ⋯ 163 bytes ⋯ ")OCC1OC(O)(COP(=O)(O)O)C(O)C1O"
          + "O.O=P(O)(O)OCC1OC(O)(COP(=O)(O)" ⋯ 43 bytes ⋯ "COP(=O)(O)O.O=P([O-])([O-])[O-]"
          + "O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)" ⋯ 19 bytes ⋯ ")COP(=O)(O)O.O=C(CO)COP(=O)(O)O"
          + "O=C[C@H](O)COP(=O)(O)O>>O=C(CO)COP(=O)(O)O"
          + "O=C(CO)COP(=O)(O)O>>O=C[C@H](O)COP(=O)(O)O"
          + "O=C[C@H](O)COP(=O)(O)O>>"
          + "O=C(CO)COP(=O)(O)O>>"
          + ">>Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O"
          + "Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O>>"
          + "O=P([O-])([O-])[O-]>>"
          + ">>O"
          ms
          16-element Vector{String}:
          + ""
          + "[OH:5][CH2:6][C@H:7]1[O:8][CH:9" ⋯ 587 bytes ⋯ "H:40]([OH:41])[C@H:42]1[OH:43]"
          + "[O:8]=[P:7]([OH:9])([OH:10])[O:" ⋯ 177 bytes ⋯ "H:13]([OH:14])[C@H:15]1[OH:16]"
          + ""
          + "[O:14]=[P:13]([OH:15])([OH:16])" ⋯ 178 bytes ⋯ "P:13](=[O:14])([OH:15])[OH:16]"
          + "[NH2:1][c:2]1[n:3][cH:4][n:5][c" ⋯ 640 bytes ⋯ "CH:44]([OH:45])[CH:46]1[OH:47]"
          + "[OH2:20].[O:17]=[P:18]([OH:19])" ⋯ 250 bytes ⋯ "P:18]([O-:19])([O-:20])[O-:21]"
          + "[O:18]=[P:17]([OH:19])([OH:20])" ⋯ 227 bytes ⋯ "P:17](=[O:18])([OH:19])[OH:20]"
          + "[O:4]=[CH:3][C@H:2]([OH:1])[CH2" ⋯ 73 bytes ⋯ ":6][P:7](=[O:8])([OH:9])[OH:10]"
          + "[O:1]=[C:2]([CH2:3][OH:4])[CH2:" ⋯ 73 bytes ⋯ ":6][P:7](=[O:8])([OH:9])[OH:10]"
          + ""
          + ""
          + ""
          + ""
          + ""
          + ""

          Identifying all source metabolite-atom positions

          The following code extracts the source metabolite indices in mets and computes the total number of carbon atoms of interest.

          # Total number of atom type across all metabolites
          +atom_max = get_max_atoms(smiles, atom)
          +
          +# Identify source metabolite indices and copies of atom
          +src_mets = get_source_metabolites(S)
          +
          +# Number of carbon atoms in each source metabolite
          +max_src_mets_carbon = atom_max[src_mets]
          # Source metabolites
          +mets[src_mets]
          3-element Vector{String}:
          + "Glc"
          + "ATP"
          + "H2O"
          # Carbons in each source metabolite
          +max_src_mets_carbon
          3-element Vector{Int64}:
          +  6
          + 10
          +  0

          Enumerating metabolite-atom mappings across reactions

          We then precompute an atom tracing dictionary mapping the (carbon) atom in the stoichiometric copy of a substrate to its product atom position across each reaction.

          # Precompute atom tracing dictionary
          +D_C = precompute_atom_tracing_dictionary(S, ms, atom_max, atom) # S must be Matrix{Int16}
          D_C
          Dict{NTuple{4, Int64}, Tuple{Int64, Int64}} with 62 entries:
          +  (3, 2, 1, 3)  => (5, 2)
          +  (2, 2, 1, 6)  => (4, 2)
          +  (1, 2, 1, 2)  => (3, 2)
          +  (2, 5, 1, 2)  => (4, 5)
          +  (9, 1, 1, 7)  => (6, 2)
          +  (6, 1, 1, 6)  => (9, 2)
          +  (9, 1, 1, 8)  => (10, 1)
          +  (3, 3, 1, 5)  => (6, 2)
          +  (2, 9, 1, 6)  => (4, 9)
          +  (3, 4, 1, 5)  => (6, 1)
          +  (9, 2, 1, 7)  => (6, 1)
          +  (2, 1, 1, 2)  => (4, 1)
          +  (6, 2, 1, 6)  => (9, 1)
          +  (9, 2, 1, 8)  => (10, 2)
          +  (2, 8, 1, 2)  => (4, 8)
          +  (3, 6, 1, 3)  => (5, 4)
          +  (2, 6, 1, 6)  => (4, 6)
          +  (2, 10, 1, 2) => (4, 10)
          +  (1, 6, 1, 2)  => (3, 6)
          +  ⋮             => ⋮

          Conclusion

          All of the code/functions described above are wrapped into preprocess_all_for_atomic_chmc(). If this wrapper function fails, you may need to step through these individual pre-processing functions to identify the error.

          diff --git a/docs/build/tutorials/chmc-atomic-glucose/index.html b/docs/build/tutorials/chmc-atomic-glucose/index.html index e5dba9e..da91264 100644 --- a/docs/build/tutorials/chmc-atomic-glucose/index.html +++ b/docs/build/tutorials/chmc-atomic-glucose/index.html @@ -1,5 +1,5 @@ -ACHMC (for AEFMs) · MarkovWeightedEFMs.jl

          ACHMC (for AEFMs)

          This section shows how to use the functions in MarkovWeightedEFMs.jl to enumerate and assign AEFMs weights in a simple multispecies reaction network.

          Toy multispecies network

          Inputs

          using MarkovWeightedEFMs
          +ACHMC (for AEFMs; quickstart) · MarkovWeightedEFMs.jl

          ACHMC (for AEFMs; quickstart)

          This section shows how to use the wrapper function in MarkovWeightedEFMs.jl to enumerate and assign AEFMs weights in a simple, multispecies reaction network.

          Toy multispecies network

          Inputs

          using MarkovWeightedEFMs
           S = [#
             1 -1  0  0  0  0  0  0  0  0  0  0  0  0  0  0 # Glc
             0 -1  0  0  0 -1  0  0  0  0  0  0  1  0  0  0 # ATP
          @@ -61,36 +61,158 @@
             "C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O",
             "C([C@H](C=O)O)OP(=O)(O)O",
             "C(C(=O)COP(=O)(O)O)O"
          -]

          We can check that the flux vector satisfies the steady state requirements.

          all(S * v .== 0) # should evaluate as true

          Pre-processing data

          The following functions check for issues with the inputs. The first function find_atomic_chmc_input_errors identifies possible problems with the stoichiometry matrix and flux vector. These problems, except for the steady state flux requirement, can be addressed via correct_atomic_chmc_input_errors. Finally, the last function correct_atomic_chmc_input_smiles checks and fixes problems relating to the SMILES strings.

          # Confirm there are no issues with stoichiometry matrix 
          -errors = find_atomic_chmc_input_errors(S, v)
          -print(errors) # summary of errors associated with S/v
          -
          -# S and v have no errors so the inputs are returned
          -correct_atomic_chmc_input_errors(errors, S, mets, rxns)
          -# S, mets, rxns = correct_atomic_chmc_input_errors(errors, S, mets, rxns) # otherwise
          -
          -# Correct issues associated with RXNMapper character limit and pseudometabolites
          -S, v, mets, rxns, smiles, logs = correct_atomic_chmc_input_smiles(S, v, mets, rxns, smiles)

          At this point, the SMILES strings (matching the updated mets if there were errors in the initial inputs) should be canonicalized. S is also converted to a Matrix{Int16} which is a requirement for subsequent functions.

          smiles = canonicalize_smiles(smiles)

          Atom mapping reactions

          The reaction SMILES strings are next constructed from the metabolite SMILES and the atom mapping is performed via RXNMapper. In this tutorial, we will be constructing an atomic CHMC rooted on a particular source metabolite carbon. We precompute an atom tracing dictionary mapping the (carbon) atom in the stoichiometric copy of a substrate to its product across each reaction.

          # Construct atom traced SMILES strings
          -rs, ms = map_reaction_strings(S, smiles, rxns, false)
          -
          -# Precompute atom tracing dictionary
          -atom = :C # carbon
          -atom_max = get_max_atoms(smiles, atom)
          -D_C = precompute_atom_tracing_dictionary(S, ms, atom_max, atom) # S must be Matrix{Int16}
          +]
           
          -# Identify source metabolites
          -src_mets = get_source_metabolites(S)
          -max_src_met_carbons = atom_max[src_mets]
          -nothing # hide

          Computing ACHMC for a given metabolite/carbon atom state

          The following atomic CHMC is rooted on the first carbon atom of the first source metabolite in the stoichiometry matrix 6-phospho-D-gluconate.

          I = (src_mets[1], 1, atom) # initial state is 1st carbon of canonicalized glucose
          -res = steady_state_efm_distribution(S, v, ms, I, D_C; verbose = false) # S must be Matrix{Int16}

          If we only wanted to enumerate the AEFMs, we would run:

          enumerate_atomic_efms(S, ms, I, D_C, verbose = false)

          Both functions produce the same output structure res, except that the AEFM flux decomposition field will be a vector of zeros.

          Output

          The output res is an immutable struct with 8 fields:

          res.i is a tuple storing (i) the source metabolite index, (ii) source metabolite atom index (based on canonicalized SMILES string), and (iii) the atom type.

          res.e is an array of AEFMs with all corresponding simple cycle closures.

          res.p is an array of AEFM probabilities normalized to one.

          res.w is an array of AEFM weights normalized by the (unimolecular) reaction flux of the source metabolite.

          res.dchmc is a dictionary storing the ACHMC. The keys are the ACHMC states (composed of Markov chain states in res.dmc). The values are the ACHMC state and the Markov chain state children.

          res.dmc is a dictionary converting Markov chain states to metabolite-atom positions. The value (0, 0) always corresponds to the external environment sink node (which connects back to the source metabolite-atom state).

          res.T is a sparse array storing the ACHMC transition probability matrix.

          res.R is an array of tuples storing the reaction index/indices mapped to each ACHMC transition matrix element.

          Converting AEFM to sequence of metabolites

          The corresponding AEFMs correspond to the movement of metabolite/atom states through the reaction network. We can convert these states into metabolites using get_efm_metabolite_atom_indices. Note that there is one fewer metabolite name than AEFM metabolite indices because the pseudometabolite (0, 0) linking sink and source reactions is omitted.

          # First AEFM
          -mets[first.(get_efm_metabolite_atom_indices(res, 1))]
          # Second AEFM
          -mets[first.(get_efm_metabolite_atom_indices(res, 2))]

          Visualizing the CHMC and mapped reactions

          The following plotting function visualizes the ACHMC rooted on state I. This is only recommended for exploring ACHMCs of small networks.

          using GLMakie # Makie backend
          +atom = :C # carbon atom type for AEFMs

          We can check that the flux vector satisfies the steady state requirements.

          all(S * v .== 0) # should evaluate as true
          true

          Pre-processing data (wrapper)

          The following function pre-processes the input metabolic network for computing the AEFM weights for the specified atom type.

          mdl, atom_info, logs = preprocess_all_for_atomic_chmc(S, v, mets, rxns, smiles, atom)

          The variable mdl is a NamedTuple containing the updated stoichiometry matrix, flux vector, metabolite/reaction names, metabolite SMILES strings, reaction SMILES strings, and mapped reaction SMILES strings.

          keys(mdl)
          (:S, :v, :mets, :rxns, :smiles, :rs, :ms)

          The variable logs contains details about input metabolic network in addition to listing the pseudometabolites and pseudoreactions dropped from the network based on the input SMILES strings.

          keys(logs)
          (:model_errors, :smiles_warnings)
          print(logs.model_errors)
          ############################################################
          +## ERROR CHECKING STOICHIOMETRY MATRIX AND FLUX VECTOR #####
          +# (1)  SUM OF ABSOLUTE FLUX RECONSTRUCTION ERROR:
          +#      0.0
          +#      PASSED.
          +# (2)  REACTIONS THAT ARE DUPLICATES:
          +#      NONE.
          +#      PASSED.
          +# (3)  REACTIONS WTIH ZERO FLUX:
          +#      NONE.
          +#      PASSED.
          +# (4)  REACTIONS WTIH NEGATIVE FLUX:
          +#      NONE.
          +#      PASSED.
          +# (5)  INTERNAL REACTIONS W/ NON-INTEGER STOICHIOMETRIES:
          +#      NONE.
          +#      PASSED.
          +# (6)  UNIMOLECULAR SOURCE REACTIONS W/ STOICH == 1:
          +#      1, 13, 16
          +#      PASSED.
          +# (7)  UNIMOLECULAR SOURCE REACTIONS W/ STOICH != 1:
          +#      NONE.
          +#      PASSED.
          +# (8)  MULTIMOLECULAR SOURCE REACTIONS W/ STOICH == 1:
          +#      NONE.
          +#      PASSED.
          +# (9)  MULTIMOLECULAR SOURCE REACTIONS W/ STOICH != 1:
          +#      NONE.
          +#      PASSED.
          +# (10) UNIMOLECULAR SINK REACTIONS W/ STOICH == 1:
          +#      4, 11, 12, 14, 15
          +#      PASSED.
          +# (11) UNIMOLECULAR SINK REACTIONS W/ STOICH != 1:
          +#      NONE.
          +#      PASSED.
          +# (12) MULTIMOLECULAR SINK REACTIONS W/ STOICH == 1:
          +#      NONE.
          +#      PASSED.
          +# (13) MULTIMOLECULAR SINK REACTIONS W/ STOICH != 1:
          +#      NONE.
          +#      PASSED.
          +# (14) REACTIONS W/ NO SUBSTRATES OR PRODUCTS:
          +#      NONE.
          +#      PASSED.
          +# (15) # METABOLITES PARTICIPATING IN NO REACTIONS:
          +#      NONE.
          +#      PASSED.
          +# STATUS:
          +#      PASSED. THESE INPUTS SATISFY ATOMIC CHMC REQUIREMENTS.
          +############################################################
          logs.smiles_warnings
          (dropped_rows_pseudometabolites = Int64[], dropped_cols_pseudometabolites = Int64[], dropped_cols_rxnmapper_limit = Int64[])

          The variable atom_info contains the indices of all source metabolites in the updated network and the number of occurrences for the input atom of interest. It also contains an atom-mapping dictionary relating substrate-atom positions to product-atom positions in each reaction. These are useful for programmatically computing AEFMs across all source metabolite-atom combinations of interest.

          keys(atom_info)
          (:atom, :src_mets, :max_src_met_atoms, :D)
          atom_info.src_mets # source metabolite indices
          3-element Vector{Int64}:
          + 1
          + 2
          + 8
          atom_info.max_src_met_atoms # counts of specified atom in each source metabolite
          3-element Vector{Int64}:
          +  6
          + 10
          +  0
          atom_info.D # atom-mapping dictionary
          Dict{NTuple{4, Int64}, Tuple{Int64, Int64}} with 62 entries:
          +  (3, 2, 1, 3)   => (5, 2)
          +  (2, 2, 1, 6)   => (4, 2)
          +  (1, 2, 1, 2)   => (3, 2)
          +  (2, 5, 1, 2)   => (4, 5)
          +  (3, 3, 1, 5)   => (6, 2)
          +  (3, 4, 1, 5)   => (6, 1)
          +  (3, 6, 1, 3)   => (5, 4)
          +  (2, 6, 1, 6)   => (4, 6)
          +  (1, 6, 1, 2)   => (3, 6)
          +  (2, 7, 1, 6)   => (4, 7)
          +  (11, 3, 1, 10) => (10, 3)
          +  (2, 9, 1, 2)   => (4, 9)
          +  (3, 1, 1, 5)   => (6, 6)
          +  (3, 2, 1, 5)   => (6, 5)
          +  (3, 5, 1, 3)   => (5, 5)
          +  (2, 5, 1, 6)   => (4, 5)
          +  (9, 3, 1, 7)   => (6, 5)
          +  (1, 5, 1, 2)   => (3, 5)
          +  (9, 4, 1, 7)   => (6, 6)
          +  ⋮              => ⋮

          Computing ACHMC for a given metabolite/carbon atom state

          The following atomic CHMC is rooted on the first carbon atom of the first source metabolite in the stoichiometry.

          I = (atom_info.src_mets[1], 1, atom) # initial state is 1st carbon of canonicalized glucose
          +res = steady_state_efm_distribution(mdl.S, mdl.v, mdl.ms, I, atom_info.D; verbose = false) # S must be Matrix{Int16}
          res
          CHMCAtomicSummary((1, 1, :C), @NamedTuple{EFM::Vector{Int64}, Closures::Vector{Tuple{Int64, Int64}}}[(EFM = [6, 5, 6], Closures = [(6, 5)]), (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)]), (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)]), (EFM = [8, 7, 8], Closures = [(9, 7)]), (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)])], [0.09000000000000001, 0.56, 0.27, 0.01, 0.07], [1.0, 6.222222222222222, 3.0, 0.11111111111111112, 0.7777777777777778], Dict{Int64, Tuple{Int16, Int16}}(5 => (6, 6), 4 => (0, 0), 6 => (9, 4), 7 => (11, 2), 2 => (3, 1), 8 => (10, 1), 3 => (5, 3), 1 => (1, 1)), Dict{Vector{Int16}, @NamedTuple{id::Int64, children::Vector{Int16}}}([1, 2, 5, 6, 7] => (id = 7, children = [8]), [1, 2, 5, 6] => (id = 6, children = [7]), [1, 2, 5, 6, 7, 4] => (id = 8, children = []), [1] => (id = 1, children = [2]), [1, 2, 3] => (id = 3, children = []), [1, 2, 3, 4] => (id = 4, children = []), [1, 2] => (id = 2, children = [3, 5]), [1, 2, 5] => (id = 5, children = [6]), [1, 2, 5, 6, 7, 8] => (id = 9, children = []), [1, 2, 5, 6, 7, 8, 4] => (id = 10, children = [])…), sparse([4, 8, 10, 1, 2, 3, 2, 6, 5, 6, 9, 7, 7, 9], [1, 1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 9, 10], [1.0, 1.0, 1.0, 1.0, 0.3, 1.0, 0.7, 0.125, 1.0, 0.875, 0.125, 0.875, 0.125, 0.875], 10, 10), @NamedTuple{i::Int64, j::Int64, k::Int16}[(i = 1, j = 2, k = 2), (i = 2, j = 3, k = 3), (i = 2, j = 5, k = 5), (i = 3, j = 4, k = 4), (i = 4, j = 1, k = 4), (i = 5, j = 6, k = 6), (i = 6, j = 5, k = 7), (i = 6, j = 7, k = 8), (i = 7, j = 8, k = 12), (i = 8, j = 1, k = 12), (i = 7, j = 9, k = 10), (i = 9, j = 10, k = 11), (i = 10, j = 1, k = 11), (i = 9, j = 7, k = 9)])

          If we only wanted to enumerate the AEFMs, we would run:

          res_enum = enumerate_atomic_efms(mdl.S, mdl.ms, I, atom_info.D, verbose = false)

          Both functions produce the same output structure res, except that the AEFM flux decomposition fields will be empty. The transition matrix will also default to uniformly distributed probabilities along each row.

          Output

          The output res is an immutable struct with 8 fields:

          res.i is a tuple storing (i) the source metabolite index, (ii) source metabolite atom index (based on canonicalized SMILES string), and (iii) the atom type. This is a copy of the variable I.

          res.i
          (1, 1, :C)

          res.e is an array of AEFMs with all corresponding simple cycle closures.

          res.e
          5-element Vector{@NamedTuple{EFM::Vector{Int64}, Closures::Vector{Tuple{Int64, Int64}}}}:
          + (EFM = [6, 5, 6], Closures = [(6, 5)])
          + (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)])
          + (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)])
          + (EFM = [8, 7, 8], Closures = [(9, 7)])
          + (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)])

          res.p is an array of AEFM probabilities normalized to one.

          res.p
          5-element Vector{Float64}:
          + 0.09000000000000001
          + 0.56
          + 0.27
          + 0.01
          + 0.07

          res.w is an array of AEFM weights normalized by the (unimolecular) reaction flux of the source metabolite.

          res.w
          5-element Vector{Float64}:
          + 1.0
          + 6.222222222222222
          + 3.0
          + 0.11111111111111112
          + 0.7777777777777778

          res.dchmc is a dictionary storing the ACHMC. The keys are the ACHMC states (composed of Markov chain states in res.dmc). The values are the ACHMC state and the Markov chain state children.

          res.dchmc
          Dict{Vector{Int16}, @NamedTuple{id::Int64, children::Vector{Int16}}} with 10 entries:
          +  [1, 2, 5, 6, 7]       => (id = 7, children = [8])
          +  [1, 2, 5, 6]          => (id = 6, children = [7])
          +  [1, 2, 5, 6, 7, 4]    => (id = 8, children = [])
          +  [1]                   => (id = 1, children = [2])
          +  [1, 2, 3]             => (id = 3, children = [])
          +  [1, 2, 3, 4]          => (id = 4, children = [])
          +  [1, 2]                => (id = 2, children = [3, 5])
          +  [1, 2, 5]             => (id = 5, children = [6])
          +  [1, 2, 5, 6, 7, 8]    => (id = 9, children = [])
          +  [1, 2, 5, 6, 7, 8, 4] => (id = 10, children = [])

          res.dmc is a dictionary converting Markov chain states to metabolite-atom positions. The value (0, 0) always corresponds to the external environment sink node (which connects back to the source metabolite-atom state).

          res.dmc
          Dict{Int64, Tuple{Int16, Int16}} with 8 entries:
          +  5 => (6, 6)
          +  4 => (0, 0)
          +  6 => (9, 4)
          +  7 => (11, 2)
          +  2 => (3, 1)
          +  8 => (10, 1)
          +  3 => (5, 3)
          +  1 => (1, 1)

          res.T is a sparse array storing the ACHMC transition probability matrix.

          res.T
          10×10 SparseArrays.SparseMatrixCSC{Float64, Int64} with 14 stored entries:
          +  ⋅   1.0   ⋅    ⋅    ⋅      ⋅    ⋅      ⋅      ⋅      ⋅ 
          +  ⋅    ⋅   0.3   ⋅   0.7     ⋅    ⋅      ⋅      ⋅      ⋅ 
          +  ⋅    ⋅    ⋅   1.0   ⋅      ⋅    ⋅      ⋅      ⋅      ⋅ 
          + 1.0   ⋅    ⋅    ⋅    ⋅      ⋅    ⋅      ⋅      ⋅      ⋅ 
          +  ⋅    ⋅    ⋅    ⋅    ⋅     1.0   ⋅      ⋅      ⋅      ⋅ 
          +  ⋅    ⋅    ⋅    ⋅   0.125   ⋅   0.875   ⋅      ⋅      ⋅ 
          +  ⋅    ⋅    ⋅    ⋅    ⋅      ⋅    ⋅     0.875  0.125   ⋅ 
          + 1.0   ⋅    ⋅    ⋅    ⋅      ⋅    ⋅      ⋅      ⋅      ⋅ 
          +  ⋅    ⋅    ⋅    ⋅    ⋅      ⋅   0.125   ⋅      ⋅     0.875
          + 1.0   ⋅    ⋅    ⋅    ⋅      ⋅    ⋅      ⋅      ⋅      ⋅ 

          res.R is an array of tuples storing the reaction index/indices mapped to each ACHMC transition matrix element.

          res.R
          14-element Vector{@NamedTuple{i::Int64, j::Int64, k::Int16}}:
          + (i = 1, j = 2, k = 2)
          + (i = 2, j = 3, k = 3)
          + (i = 2, j = 5, k = 5)
          + (i = 3, j = 4, k = 4)
          + (i = 4, j = 1, k = 4)
          + (i = 5, j = 6, k = 6)
          + (i = 6, j = 5, k = 7)
          + (i = 6, j = 7, k = 8)
          + (i = 7, j = 8, k = 12)
          + (i = 8, j = 1, k = 12)
          + (i = 7, j = 9, k = 10)
          + (i = 9, j = 10, k = 11)
          + (i = 10, j = 1, k = 11)
          + (i = 9, j = 7, k = 9)

          Converting AEFM to sequence of metabolites

          The corresponding AEFMs correspond to the movement of metabolite/atom states through the reaction network. We can convert these states into metabolites using get_efm_metabolite_atom_indices. Note that there is one fewer metabolite name than AEFM metabolite indices because the pseudometabolite (0, 0) linking sink and source reactions is omitted.

          # First AEFM
          +efm_seq_1 = mets[first.(get_efm_metabolite_atom_indices(res, 1))]
          efm_seq_1
          3-element Vector{String}:
          + "FDP"
          + "F6P"
          + "FDP"
          # Second AEFM
          +efm_seq_2 = mets[first.(get_efm_metabolite_atom_indices(res, 2))]
          efm_seq_2
          5-element Vector{String}:
          + "Glc"
          + "G6P"
          + "F6P"
          + "FDP"
          + "DHAP"

          Visualizing the CHMC and mapped reactions

          The following plotting function visualizes the ACHMC rooted on state I. This is only recommended for exploring ACHMCs of small networks.

          using GLMakie # Makie backend
           GLMakie.activate!()
           
           plot_atomic_chmc(res, S, mets, rs)

          Each node in the main panel corresponds to a CHMC state (metabolite and atomic index).

          ACHMC main panel

          Clicking on a CHMC transition will highlight that transition and display the corresponding metabolic reaction on the upper panel. The pair of purple highlighted atoms correspond to the movement of the same atom from the LHS to RHS of the reaction.

          ACHMC main and upper panel

          Finally, the reaction and mapped reaction SMILES strings can also be plotted as an SVG and previewed using a package like ElectronDisplay. If fname != "", the SVG is also saved to file. By default, fname == "" and the SVG is not saved. The default canvas width and height are 1420 by 580 (pixels) but these can be changed. If using ElectronDisplay and the image is cut off, try resizing the plotting window or reducing the canvas dimensions.

          using ElectronDisplay
           
           # Reaction string
          -plot_mapped_reaction(rs[2], view=true)
          +plot_mapped_reaction(rs[2], view=true, canvas_width = 1420, canvas_height = 580)
           #plot_mapped_reaction(rs[2], "\path\to\save\name.svg", view=true)

          Reaction SMILES string

          # Mapped reaction string
           plot_mapped_reaction(ms[2], view = true, canvas_width = 1420, canvas_height = 580)
          -#plot_mapped_reaction(ms[2], "\path\to\save\name.svg", view = true,)

          Mapped reaction SMILES string

          +#plot_mapped_reaction(ms[2], "\path\to\save\name.svg", view = true)

          Mapped reaction SMILES string

          diff --git a/docs/build/tutorials/chmc-standard-ion-channels/index.html b/docs/build/tutorials/chmc-standard-ion-channels/index.html index cf80b96..764c2b0 100644 --- a/docs/build/tutorials/chmc-standard-ion-channels/index.html +++ b/docs/build/tutorials/chmc-standard-ion-channels/index.html @@ -1,5 +1,5 @@ -CHMC (ion channels) · MarkovWeightedEFMs.jl

          CHMC (ion channels)

          This section demonstrates how to use the functions in MarkovWeightedEFMs.jl to analyze the steady state dynamics of the following ion channel with three possible binding sites reproduced from (Bicknell and Goodhill)[https://doi.org/10.1073/pnas.1604090113].

          Markov chain model of IP3 receptor from Bicknell and Goodhill (https://doi.org/10.1073/pnas.1604090113)

          Markov state model of IP3 channel activity

          Rate constants

          using MarkovWeightedEFMs
          +CHMC (ion channels) · MarkovWeightedEFMs.jl

          CHMC (ion channels)

          This section demonstrates how to use the functions in MarkovWeightedEFMs.jl to analyze the steady state dynamics of the following ion channel with three possible binding sites reproduced from (Bicknell and Goodhill)[https://doi.org/10.1073/pnas.1604090113].

          Markov chain model of IP3 receptor from Bicknell and Goodhill (https://doi.org/10.1073/pnas.1604090113)

          Markov state model of IP3 channel activity

          Rate constants

          using MarkovWeightedEFMs
           
           # Parameters
           c   = 0.1 # Ca2+ (uM)
          @@ -82,4 +82,4 @@
            [4, 1, 2, 5, 4]              0.00182393
            [4, 1, 2, 5, 8, 7, 4]        1.63344e-5

          Visualizing the CHMC

          The blue node represents state 1 and is the root of the tree. All green nodes return back to the blue node but these arrows are hidden to limit visual clutter.

          using GLMakie
           GLMakie.activate!()
          -plot_chmc(T, 1) # arbitrarily rooted on state 1

          +plot_chmc(T, 1) # arbitrarily rooted on state 1

          diff --git a/docs/build/tutorials/chmc-standard-metabolic-networks/index.html b/docs/build/tutorials/chmc-standard-metabolic-networks/index.html index 499e70d..3406e5d 100644 --- a/docs/build/tutorials/chmc-standard-metabolic-networks/index.html +++ b/docs/build/tutorials/chmc-standard-metabolic-networks/index.html @@ -1,5 +1,5 @@ -CHMC (metabolic networks) · MarkovWeightedEFMs.jl

          CHMC (metabolic networks)

          This section demonstrates how to use the functions in MarkovWeightedEFMs.jl to analyze the following unimolecular reaction network.

          Example unimolecular reaction network

          Problem statement

          Given the metabolic network above, its steady state fluxes, and its elementary flux modes (EFMs), what is the set of EFM weights that reconstructs the observed network fluxes?

          Inputs

          For this type of problem, we require the following:

          1. Stoichiometry matrix of unimolecular reactions (must be unimolecular and strongly-connected; either open or closed loop)
          2. Steady state fluxes along each reaction.

          The network metabolites and reactions are typically encoded in an $m$ by $r$ stoichiometry matrix S. The steady state flux vector is stored as a separate vector.

          using MarkovWeightedEFMs # load package
          +CHMC (metabolic networks) · MarkovWeightedEFMs.jl

          CHMC (metabolic networks)

          This section demonstrates how to use the functions in MarkovWeightedEFMs.jl to analyze the following unimolecular reaction network.

          Example unimolecular reaction network

          Problem statement

          Given the metabolic network above, its steady state fluxes, and its elementary flux modes (EFMs), what is the set of EFM weights that reconstructs the observed network fluxes?

          Inputs

          For this type of problem, we require the following:

          1. Stoichiometry matrix of unimolecular reactions (must be unimolecular and strongly-connected; either open or closed loop)
          2. Steady state fluxes along each reaction.

          The network metabolites and reactions are typically encoded in an $m$ by $r$ stoichiometry matrix S. The steady state flux vector is stored as a separate vector.

          using MarkovWeightedEFMs # load package
           
           # Stoichiometry matrix and flux vector for the example network
           S = [#
          @@ -39,4 +39,4 @@
            [1, 2, 4, 5, 6, 1]

          Visualizing the CHMC

          The following plotting function visualizes the CHMC rooted on a metabolite state (1 by default).

          using GLMakie # Makie backend
           GLMakie.activate!()
           T = stoichiometry_to_transition_matrix(S, v)
          -plot_chmc(T, 1) # the last parameter is the rooted metabolite index

          If using the GLMakie backend, ensure OpenGL is installed on your machine and accessible by Julia. The GLMakie plot is interactive and allows users to drag nodes and zoom in/out. Otherwise, you could choose another backend such as CairoMakie to generate and save a static plot. A prettier, hand-coded version of the transformed network is shown below.

          The blue node is the root of the tree and the green nodes indicate that there is an edge back up to the root. By default, these arrows are omitted to avoid cluttering the plot.

          +plot_chmc(T, 1) # the last parameter is the rooted metabolite index

          If using the GLMakie backend, ensure OpenGL is installed on your machine and accessible by Julia. The GLMakie plot is interactive and allows users to drag nodes and zoom in/out. Otherwise, you could choose another backend such as CairoMakie to generate and save a static plot. A prettier, hand-coded version of the transformed network is shown below.

          The blue node is the root of the tree and the green nodes indicate that there is an edge back up to the root. By default, these arrows are omitted to avoid cluttering the plot.

          diff --git a/docs/make.jl b/docs/make.jl index 9e1208a..e4f0bc3 100755 --- a/docs/make.jl +++ b/docs/make.jl @@ -21,6 +21,7 @@ makedocs(# "tutorials/chmc-standard-metabolic-networks.md", "tutorials/chmc-standard-ion-channels.md", "tutorials/chmc-atomic-glucose.md", + "tutorials/chmc-atomic-glucose-under-the-hood.md", "tutorials/boilerplate-for-bigg-gems.md", ], "Library" => Any[# diff --git a/docs/src/tutorials/boilerplate-for-bigg-gems.md b/docs/src/tutorials/boilerplate-for-bigg-gems.md index 236d0da..e9bfd91 100644 --- a/docs/src/tutorials/boilerplate-for-bigg-gems.md +++ b/docs/src/tutorials/boilerplate-for-bigg-gems.md @@ -1,14 +1,17 @@ # Boilerplate code for ACHMC analysis of BiGG models -The following code is provided to quickly construct ACHMC models of BiGG -metabolic models and others stored in the SBML file format. Each code -block is designed to be standalone with calculations saved to file and -re-loaded in a subsequent code block. Unfortunately, BiGG does not store -SMILES strings so these will need to be manually compiled by the user. +The following code is provided to construct ACHMC models of BiGG metabolic +models (and others) stored in the SBML file format. Each code block is +designed to be standalone with calculations saved to file and re-loaded in +a subsequent code block. Since metabolic models can be quite complex, +individual pre-processesing functions are used rather than the wrapper +function `preprocess_all_for_atomic_chmc`. Unfortunately, BiGG does not +store SMILES strings so these will need to be manually compiled by the +user. Note we recommend starting with relatively small networks (<500 -metabolites and reactions in the original metabolic model) for -computational feasibility. +metabolites and reactions in the original metabolic model) for computational +feasibility before scaling to larger ones. ## Inputs (from BiGG) diff --git a/docs/src/tutorials/chmc-atomic-glucose-under-the-hood.md b/docs/src/tutorials/chmc-atomic-glucose-under-the-hood.md new file mode 100644 index 0000000..bcbef6c --- /dev/null +++ b/docs/src/tutorials/chmc-atomic-glucose-under-the-hood.md @@ -0,0 +1,601 @@ +# ACHMC (for AEFMs; under the hood) + +This section explains the pre-processing steps under the hood of +`preprocess_all_for_atomic_chmc()` using the same multispecies reaction +network from the previous tutorial. + +![Toy multispecies network](../assets/toy-network-1-achmc.png) + +```@setup required +# Bodge until I figure out how to install Python and RXMapper on Git workflows +using MarkovWeightedEFMs +using SparseArrays + +S = [# + 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # Glc + 0 -1 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 # ATP + 0 1 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 # G6P + 0 1 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 # ADP + 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 # 6PG + 0 0 0 0 1 -1 1 0 0 0 0 0 0 0 0 0 # F6P + 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 # Pi + 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 # H2O + 0 0 0 0 0 1 -1 -1 0 0 0 0 0 0 0 0 # FDP + 0 0 0 0 0 0 0 1 -1 1 -1 0 0 0 0 0 # G3P + 0 0 0 0 0 0 0 1 1 -1 0 -1 0 0 0 0 # DHAP +] + +v = [10, 10, 3, 3, 7, 8, 1, 7, 1, 1, 7, 7, 18, 18, 1, 1] + +mets = [# + "Glc", + "ATP", + "G6P", + "ADP", + "6PG", + "F6P", + "Pi", + "H2O", + "FDP", + "G3P", + "DHAP" +] + +rxns = [# + "Source Glc", + "Hexokinase", + "G6P dehydrogenase", + "Sink 6PG", + "Phosphoglucose isomerase", + "6-phosphofructo-1-kinase", + "Fructose 1,6-bisphosphatase", + "Fructose-bisphosphate aldolase", + "Triose phosphate isomerase", + "Triose phosphate isomerase", + "Sink G3P", + "Sink DHAP", + "Source ATP", + "Sink ADP", + "Sink Pi", + "Source H2O" +] + +smiles = [# + "C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O", + "C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)OP(=O)(O)O)O)O)N", + "C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)OP(=O)(O)O", + "C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N", + "O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O", + "C([C@H]([C@H]([C@@H](C(=O)CO)O)O)O)OP(=O)(O)O", + "[O-]P(=O)([O-])[O-]", + "O", + "C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O", + "C([C@H](C=O)O)OP(=O)(O)O", + "C(C(=O)COP(=O)(O)O)O" +] + +atom = :C # carbon atom type for AEFMs + +mdl, atom_info, logs = preprocess_all_for_atomic_chmc(S, v, mets, rxns, smiles, atom) + +errors = CHMCAtomicErrorSummary(# + 0.0, #absolute_flux_error + Vector{Int64}(), #reactions_duplicated + Vector{Int64}(), #reactions_with_zero_flux + Vector{Int64}(), #reactions_with_negative_flux + Vector{Int64}(), #reactions_with_non_integer_stoichiometries + Vector{Int64}([1, 13, 16]), #reactions_unimolecular_source_stoichiometry_one + Vector{Int64}(), #reactions_unimolecular_source_stoichiometry_not_one + Vector{Int64}(), #reactions_multimolecular_source_stoichiometry_one + Vector{Int64}(), #reactions_multimolecular_source_stoichiometry_not_one + Vector{Int64}([4, 11, 12, 14, 15]), #reactions_unimolecular_sink_stoichiometry_one + Vector{Int64}(), #reactions_unimolecular_sink_stoichiometry_not_one + Vector{Int64}(), #reactions_multimolecular_sink_stoichiometry_one + Vector{Int64}(), #reactions_multimolecular_sink_stoichiometry_not_one + Vector{Int64}(), #reactions_empty + Vector{Int64}() #unused_metabolites +) + +logs = (# + dropped_row_pseudometabolites = Int64[], + dropped_cols_pseudometabolites = Int64[], + dropped_cols_rxnmapper_limit = Int64[] +) +smiles = [ + "OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O" + "Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O" + "O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O" + "Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O" + "O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O" + "O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O" + "O=P([O-])([O-])[O-]" + "O" + "O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)C(O)C1O" + "O=C[C@H](O)COP(=O)(O)O" + "O=C(CO)COP(=O)(O)O" +] + +rs = [# + ">>OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O", + "OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O.Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O>>O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O.Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O", + "O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O>>O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O", + "O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O>>", + "O=P(O)(O)OC[C@H]1OC(O)[C@H](O)[C@@H](O)[C@@H]1O>>O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O", + "Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O.O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O>>Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O.O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)C(O)C1O", + "O.O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)C(O)C1O>>O=C(CO)[C@@H](O)[C@H](O)[C@H](O)COP(=O)(O)O.O=P([O-])([O-])[O-]", + "O=P(O)(O)OCC1OC(O)(COP(=O)(O)O)C(O)C1O>>O=C[C@H](O)COP(=O)(O)O.O=C(CO)COP(=O)(O)O", + "O=C[C@H](O)COP(=O)(O)O>>O=C(CO)COP(=O)(O)O", + "O=C(CO)COP(=O)(O)O>>O=C[C@H](O)COP(=O)(O)O", + "O=C[C@H](O)COP(=O)(O)O>>", + "O=C(CO)COP(=O)(O)O>>", + ">>Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O", + "Nc1ncnc2c1ncn2[C@@H]1O[C@H](COP(=O)(O)OP(=O)(O)O)[C@@H](O)[C@H]1O>>", + "O=P([O-])([O-])[O-]>>", + ">>O" +] + +ms = [# + "", + "[OH:5][CH2:6][C@H:7]1[O:8][CH:9]([OH:10])[C@H:11]([OH:12])[C@@H:13]([OH:14])[C@@H:15]1[OH:16].[NH2:17][c:18]1[n:19][cH:20][n:21][c:22]2[c:23]1[n:24][cH:25][n:26]2[C@@H:27]1[O:28][C@H:29]([CH2:30][O:31][P:32](=[O:33])([OH:34])[O:35][P:36](=[O:37])([OH:38])[O:39][P:2](=[O:1])([OH:3])[OH:4])[C@@H:40]([OH:41])[C@H:42]1[OH:43]>>[O:1]=[P:2]([OH:3])([OH:4])[O:5][CH2:6][C@H:7]1[O:8][CH:9]([OH:10])[C@H:11]([OH:12])[C@@H:13]([OH:14])[C@@H:15]1[OH:16].[NH2:17][c:18]1[n:19][cH:20][n:21][c:22]2[c:23]1[n:24][cH:25][n:26]2[C@@H:27]1[O:28][C@H:29]([CH2:30][O:31][P:32](=[O:33])([OH:34])[O:35][P:36](=[O:37])([OH:38])[OH:39])[C@@H:40]([OH:41])[C@H:42]1[OH:43]", + "[O:8]=[P:7]([OH:9])([OH:10])[O:6][CH2:5][C@H:4]1[O:3][CH:2]([OH:1])[C@H:15]([OH:16])[C@@H:13]([OH:14])[C@@H:11]1[OH:12]>>[O:1]=[C:2]1[O:3][C@H:4]([CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10])[C@@H:11]([OH:12])[C@H:13]([OH:14])[C@H:15]1[OH:16]", + "", + "[O:14]=[P:13]([OH:15])([OH:16])[O:12][CH2:11][C@H:9]1[O:10][CH:3]([OH:4])[C@H:2]([OH:1])[C@@H:5]([OH:6])[C@@H:7]1[OH:8]>>[O:1]=[C:2]([CH2:3][OH:4])[C@@H:5]([OH:6])[C@H:7]([OH:8])[C@H:9]([OH:10])[CH2:11][O:12][P:13](=[O:14])([OH:15])[OH:16]", + "[NH2:1][c:2]1[n:3][cH:4][n:5][c:6]2[c:7]1[n:8][cH:9][n:10]2[C@@H:11]1[O:12][C@H:13]([CH2:14][O:15][P:16](=[O:17])([OH:18])[O:19][P:20](=[O:21])([OH:22])[O:23][P:29](=[O:28])([OH:30])[OH:31])[C@@H:24]([OH:25])[C@H:26]1[OH:27].[O:35]=[C:34]([CH2:33][OH:32])[C@@H:46]([OH:47])[C@H:44]([OH:45])[C@H:36]([OH:37])[CH2:38][O:39][P:40](=[O:41])([OH:42])[OH:43]>>[NH2:1][c:2]1[n:3][cH:4][n:5][c:6]2[c:7]1[n:8][cH:9][n:10]2[C@@H:11]1[O:12][C@H:13]([CH2:14][O:15][P:16](=[O:17])([OH:18])[O:19][P:20](=[O:21])([OH:22])[OH:23])[C@@H:24]([OH:25])[C@H:26]1[OH:27].[O:28]=[P:29]([OH:30])([OH:31])[O:32][CH2:33][CH:34]1[O:35][C:36]([OH:37])([CH2:38][O:39][P:40](=[O:41])([OH:42])[OH:43])[CH:44]([OH:45])[CH:46]1[OH:47]", + "[OH2:20].[O:17]=[P:18]([OH:19])([OH:21])[O:4][CH2:3][CH:2]1[O:1][C:9]([OH:10])([CH2:11][O:12][P:13](=[O:14])([OH:15])[OH:16])[CH:7]([OH:8])[CH:5]1[OH:6]>>[O:1]=[C:2]([CH2:3][OH:4])[C@@H:5]([OH:6])[C@H:7]([OH:8])[C@H:9]([OH:10])[CH2:11][O:12][P:13](=[O:14])([OH:15])[OH:16].[O:17]=[P:18]([O-:19])([O-:20])[O-:21]", + "[O:18]=[P:17]([OH:19])([OH:20])[O:1][CH2:2][CH:3]1[O:4][C:12]([OH:11])([CH2:13][O:14][P:7](=[O:8])([OH:9])[OH:10])[CH:15]([OH:16])[CH:5]1[OH:6]>>[O:1]=[CH:2][C@H:3]([OH:4])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10].[O:11]=[C:12]([CH2:13][OH:14])[CH2:15][O:16][P:17](=[O:18])([OH:19])[OH:20]", + "[O:4]=[CH:3][C@H:2]([OH:1])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10]>>[O:1]=[C:2]([CH2:3][OH:4])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10]", + "[O:1]=[C:2]([CH2:3][OH:4])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10]>>[O:4]=[CH:3][C@H:2]([OH:1])[CH2:5][O:6][P:7](=[O:8])([OH:9])[OH:10]", + "", + "", + "", + "", + "", + "" +] + +atom_max = [6, 10, 6, 10, 6, 6, 0, 0, 6, 3, 3] + +ks = [# + (3, 2, 1, 3), + (2, 2, 1, 6), + (1, 2, 1, 2), + (2, 5, 1, 2), + (3, 3, 1, 5), + (3, 4, 1, 5), + (3, 6, 1, 3), + (2, 6, 1, 6), + (1, 6, 1, 2), + (2, 7, 1, 6), + (11, 3, 1, 10), + (2, 9, 1, 2), + (3, 1, 1, 5), + (3, 2, 1, 5), + (3, 5, 1, 3), + (2, 5, 1, 6), + (9, 3, 1, 7), + (1, 5, 1, 2), + (9, 4, 1, 7), + (11, 1, 1, 10), + (6, 3, 1, 6), + (9, 3, 1, 8), + (6, 4, 1, 6), + (9, 4, 1, 8), + (2, 3, 1, 2), + (11, 2, 1, 10), + (2, 4, 1, 2), + (3, 6, 1, 5), + (9, 1, 1, 7), + (6, 1, 1, 6), + (9, 1, 1, 8), + (2, 9, 1, 6), + (9, 2, 1, 7), + (2, 1, 1, 2), + (6, 2, 1, 6), + (9, 2, 1, 8), + (2, 8, 1, 2), + (2, 10, 1, 2), + (2, 2, 1, 2), + (3, 5, 1, 5), + (9, 6, 1, 7), + (10, 3, 1, 9), + (6, 6, 1, 6), + (3, 3, 1, 3), + (2, 3, 1, 6), + (9, 6, 1, 8), + (1, 3, 1, 2), + (3, 4, 1, 3), + (2, 4, 1, 6), + (1, 4, 1, 2), + (2, 6, 1, 2), + (2, 7, 1, 2), + (10, 1, 1, 9), + (3, 1, 1, 3), + (2, 1, 1, 6), + (9, 5, 1, 7), + (1, 1, 1, 2), + (6, 5, 1, 6), + (2, 8, 1, 6), + (9, 5, 1, 8), + (2, 10, 1, 6), + (10, 2, 1, 9) +] + +vs = [# + (5, 2), + (4, 2), + (3, 2), + (4, 5), + (6, 2), + (6, 1), + (5, 4), + (4, 6), + (3, 6), + (4, 7), + (10, 3), + (4, 9), + (6, 6), + (6, 5), + (5, 5), + (4, 5), + (6, 5), + (3, 5), + (6, 6), + (10, 2), + (9, 6), + (11, 1), + (9, 5), + (11, 2), + (4, 3), + (10, 1), + (4, 4), + (6, 4), + (6, 2), + (9, 2), + (10, 1), + (4, 9), + (6, 1), + (4, 1), + (9, 1), + (10, 2), + (4, 8), + (4, 10), + (4, 2), + (6, 3), + (6, 3), + (11, 3), + (9, 4), + (5, 1), + (4, 3), + (10, 3), + (3, 3), + (5, 6), + (4, 4), + (3, 4), + (4, 6), + (4, 7), + (11, 2), + (5, 3), + (4, 1), + (6, 4), + (3, 1), + (9, 3), + (4, 8), + (11, 3), + (4, 10), + (11, 1) +] + +D_C = Dict(zip(ks, vs)) + +src_mets = [1, 2, 8] +max_src_mets_carbon = [6, 10, 0] + +I = (src_mets[1], 1, atom) + +ks = Int16.([5, 4, 6, 7, 2, 8, 3, 1]) +vs = [(Int16(6), Int16(6)), (Int16(0), Int16(0)), (Int16(9), Int16(4)), (Int16(11), Int16(2)), (Int16(3), Int16(1)), (Int16(10), Int16(1)), (Int16(5), Int16(3)), (Int16(1), Int16(1))] +dmc = Dict(zip(ks, vs)) + +ks = [# + Int16.([1, 2, 5, 6, 7]), + Int16.([1, 2, 5, 6]), + Int16.([1, 2, 5, 6, 7, 4]), + Int16.([1]), + Int16.([1, 2, 3]), + Int16.([1, 2, 3, 4]), + Int16.([1, 2]), + Int16.([1, 2, 5]), + Int16.([1, 2, 5, 6, 7, 8]), + Int16.([1, 2, 5, 6, 7, 8, 4]) +] +vs = [# + (id = 7, children = Int16.([8])), + (id = 6, children = Int16.([7])), + (id = 8, children = Int16.([])), + (id = 1, children = Int16.([2])), + (id = 3, children = Int16.([])), + (id = 4, children = Int16.([])), + (id = 2, children = Int16.([3, 5])), + (id = 5, children = Int16.([6])), + (id = 9, children = Int16.([])), + (id = 10, children = Int16.([])) +] +dchmc = Dict(zip(ks, vs)) + +T = SparseMatrixCSC([ + 0 1.0 0 0 0 0 0 0 0 0 + 0 0 0.3 0 0.7 0 0 0 0 0 + 0 0 0 1.0 0 0 0 0 0 0 + 1.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.125 0 0.875 0 0 0 + 0 0 0 0 0 0 0 0.875 0.125 0 + 1.0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0.125 0 0 0.875 + 1.0 0 0 0 0 0 0 0 0 0 +]) + +R = [# + (i = 1, j = 2, k = Int16(2)), + (i = 2, j = 3, k = Int16(3)), + (i = 2, j = 5, k = Int16(5)), + (i = 3, j = 4, k = Int16(4)), + (i = 4, j = 1, k = Int16(4)), + (i = 5, j = 6, k = Int16(6)), + (i = 6, j = 5, k = Int16(7)), + (i = 6, j = 7, k = Int16(8)), + (i = 7, j = 8, k = Int16(12)), + (i = 8, j = 1, k = Int16(12)), + (i = 7, j = 9, k = Int16(10)), + (i = 9, j = 10, k = Int16(11)), + (i = 10, j = 1, k = Int16(11)), + (i = 9, j = 7, k = Int16(9)) +] + +res = CHMCAtomicSummary(# + (1, 1, :C), + [# + (EFM = [6, 5, 6], Closures = [(6, 5)]), + (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)]), + (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)]), + (EFM = [8, 7, 8], Closures = [(9, 7)]), + (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)]) + ], + [0.09000000000000001, 0.56, 0.27, 0.01, 0.07], + [1.0, 6.222222222222222, 3.0, 0.11111111111111112, 0.7777777777777778], + dmc, + dchmc, + T, + R +) + +T = SparseMatrixCSC([ + 0 1.0 0 0 0 0 0 0 0 0 + 0 0 0.5 0 0.5 0 0 0 0 0 + 0 0 0 1.0 0 0 0 0 0 0 + 1.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.5 0 0.5 0 0 0 + 0 0 0 0 0 0 0 0.5 0.5 0 + 1.0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0.5 0 0 0.5 + 1.0 0 0 0 0 0 0 0 0 0 +]) + +res_enum = CHMCAtomicSummary(# + (1, 1, :C), + [# + (EFM = [6, 5, 6], Closures = [(6, 5)]), + (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)]), + (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)]), + (EFM = [8, 7, 8], Closures = [(9, 7)]), + (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)]) + ], + nothing, + nothing, + dmc, + dchmc, + T, + R +) + +efm_seq_1 = ["FDP", "F6P", "FDP"] +efm_seq_2 = ["Glc", "G6P", "F6P", "FDP", "DHAP"] + +``` + +## Inputs + +```julia +using MarkovWeightedEFMs +S = [# + 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # Glc + 0 -1 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 # ATP + 0 1 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 # G6P + 0 1 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 # ADP + 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 # 6PG + 0 0 0 0 1 -1 1 0 0 0 0 0 0 0 0 0 # F6P + 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 # Pi + 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 # H2O + 0 0 0 0 0 1 -1 -1 0 0 0 0 0 0 0 0 # FDP + 0 0 0 0 0 0 0 1 -1 1 -1 0 0 0 0 0 # G3P + 0 0 0 0 0 0 0 1 1 -1 0 -1 0 0 0 0 # DHAP +] + +v = [10, 10, 3, 3, 7, 8, 1, 7, 1, 1, 7, 7, 18, 18, 1, 1] + +mets = [# + "Glc", + "ATP", + "G6P", + "ADP", + "6PG", + "F6P", + "Pi", + "H2O", + "FDP", + "G3P", + "DHAP" +] + +rxns = [# + "Source Glc", + "Hexokinase", + "G6P dehydrogenase", + "Sink 6PG", + "Phosphoglucose isomerase", + "6-phosphofructo-1-kinase", + "Fructose 1,6-bisphosphatase", + "Fructose-bisphosphate aldolase", + "Triose phosphate isomerase", + "Triose phosphate isomerase", + "Sink G3P", + "Sink DHAP", + "Source ATP", + "Sink ADP", + "Sink Pi", + "Source H2O" +] + +smiles = [# + "C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O", + "C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)OP(=O)(O)O)O)O)N", + "C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)OP(=O)(O)O", + "C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N", + "O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O", + "C([C@H]([C@H]([C@@H](C(=O)CO)O)O)O)OP(=O)(O)O", + "[O-]P(=O)([O-])[O-]", + "O", + "C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O", + "C([C@H](C=O)O)OP(=O)(O)O", + "C(C(=O)COP(=O)(O)O)O" +] + +atom = :C # carbon atom type for AEFMs +``` + +We can check that the flux vector satisfies the steady state requirements. + +```@example required +all(S * v .== 0) # should evaluate as true +``` + +## Pre-processing steps + +### Checking network structure + +The following functions check for issues with the inputs. The first function +`find_atomic_chmc_input_errors` identifies possible problems with the +stoichiometry matrix and flux vector. + +```julia +# Confirm there are no issues with stoichiometry matrix +errors = find_atomic_chmc_input_errors(S, v) +``` + +```@example required +print(errors) # summary of errors associated with S/v +``` + +### Correcting problems in network structure + +Any problems, except for the steady state flux requirement, can be +addressed via `correct_atomic_chmc_input_errors`. + +```julia +# S and v have no errors so the inputs are returned +correct_atomic_chmc_input_errors(errors, S, mets, rxns) +# S, mets, rxns = correct_atomic_chmc_input_errors(errors, S, mets, rxns) # otherwise +``` + +### Identifying unmappable reactions + +The next function `correct_atomic_chmc_input_smiles` checks and fixes problems +relating to the SMILES strings. These problems are caused by RXNMapper being +unable to map atoms in reactions with pseudometabolites or pseudoreactions with +non-integer stoichiometries (e.g. biomass reaction). RXNMapper also has +a character limit on reaction SMILES strings. These unmappable reactions are +removed and the flux is balanced with unimolecular flux entering/exiting the +associated reaction substrates/products. + +```julia +# Correct issues associated with RXNMapper character limit, +# pseudometabolites and pseudoreactions +S, v, mets, rxns, smiles, logs = correct_atomic_chmc_input_smiles(S, v, mets, rxns, smiles) +``` + +At this point, the SMILES strings (matching the updated `mets` if there were +errors in the initial inputs) should be canonicalized. `S` is also converted +to a `Matrix{Int16}` which is a requirement for subsequent functions. + +```julia +smiles = canonicalize_smiles(smiles) +``` +```@example required +smiles +``` + +### Atom mapping reactions + +The reaction SMILES strings `rs` are next constructed from the metabolite +SMILES and the atom mapping is performed via RXNMapper and stored in `ms`. + +```julia +# Construct atom traced SMILES strings +rs, ms = map_reaction_strings(S, smiles, rxns, false) +``` +```@example required +rs +``` +```@example required +ms +``` + +### Identifying all source metabolite-atom positions + +The following code extracts the source metabolite indices in `mets` and +computes the total number of carbon atoms of interest. + +```julia +# Total number of atom type across all metabolites +atom_max = get_max_atoms(smiles, atom) + +# Identify source metabolite indices and copies of atom +src_mets = get_source_metabolites(S) + +# Number of carbon atoms in each source metabolite +max_src_mets_carbon = atom_max[src_mets] +``` + +```@example required +# Source metabolites +mets[src_mets] +``` + +```@example required +# Carbons in each source metabolite +max_src_mets_carbon +``` + +### Enumerating metabolite-atom mappings across reactions + +We then precompute an atom tracing dictionary mapping the (carbon) atom in +the stoichiometric copy of a substrate to its product atom position across +each reaction. + +```julia +# Precompute atom tracing dictionary +D_C = precompute_atom_tracing_dictionary(S, ms, atom_max, atom) # S must be Matrix{Int16} +``` +```@example required +D_C +``` + +## Conclusion + +All of the code/functions described above are wrapped into +`preprocess_all_for_atomic_chmc()`. If this wrapper function fails, you +may need to step through these individual pre-processing functions to +identify the error. + + diff --git a/docs/src/tutorials/chmc-atomic-glucose.md b/docs/src/tutorials/chmc-atomic-glucose.md index 4970329..8d9c4bf 100644 --- a/docs/src/tutorials/chmc-atomic-glucose.md +++ b/docs/src/tutorials/chmc-atomic-glucose.md @@ -1,11 +1,182 @@ -# ACHMC (for AEFMs) +# ACHMC (for AEFMs; quickstart) -This section shows how to use the functions in MarkovWeightedEFMs.jl to -enumerate and assign AEFMs weights in a simple multispecies reaction -network. +This section shows how to use the wrapper function in +MarkovWeightedEFMs.jl to enumerate and assign AEFMs weights in a simple, +multispecies reaction network. ![Toy multispecies network](../assets/toy-network-1-achmc.png) +```@setup required +# Bodge until I figure out how to install Python and RXMapper on Git workflows +using MarkovWeightedEFMs +using SparseArrays + +S = [# + 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 # Glc + 0 -1 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 # ATP + 0 1 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 # G6P + 0 1 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 # ADP + 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 # 6PG + 0 0 0 0 1 -1 1 0 0 0 0 0 0 0 0 0 # F6P + 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 # Pi + 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 1 # H2O + 0 0 0 0 0 1 -1 -1 0 0 0 0 0 0 0 0 # FDP + 0 0 0 0 0 0 0 1 -1 1 -1 0 0 0 0 0 # G3P + 0 0 0 0 0 0 0 1 1 -1 0 -1 0 0 0 0 # DHAP +] + +v = [10, 10, 3, 3, 7, 8, 1, 7, 1, 1, 7, 7, 18, 18, 1, 1] + +mets = [# + "Glc", + "ATP", + "G6P", + "ADP", + "6PG", + "F6P", + "Pi", + "H2O", + "FDP", + "G3P", + "DHAP" +] + +rxns = [# + "Source Glc", + "Hexokinase", + "G6P dehydrogenase", + "Sink 6PG", + "Phosphoglucose isomerase", + "6-phosphofructo-1-kinase", + "Fructose 1,6-bisphosphatase", + "Fructose-bisphosphate aldolase", + "Triose phosphate isomerase", + "Triose phosphate isomerase", + "Sink G3P", + "Sink DHAP", + "Source ATP", + "Sink ADP", + "Sink Pi", + "Source H2O" +] + +smiles = [# + "C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)O", + "C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)OP(=O)(O)O)O)O)N", + "C([C@@H]1[C@H]([C@@H]([C@H](C(O1)O)O)O)O)OP(=O)(O)O", + "C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)OP(=O)(O)O)O)O)N", + "O=C1O[C@H](COP(=O)(O)O)[C@@H](O)[C@H](O)[C@H]1O", + "C([C@H]([C@H]([C@@H](C(=O)CO)O)O)O)OP(=O)(O)O", + "[O-]P(=O)([O-])[O-]", + "O", + "C(C1C(C(C(O1)(COP(=O)(O)O)O)O)O)OP(=O)(O)O", + "C([C@H](C=O)O)OP(=O)(O)O", + "C(C(=O)COP(=O)(O)O)O" +] + +atom = :C # carbon atom type for AEFMs + +mdl, atom_info, logs = preprocess_all_for_atomic_chmc(S, v, mets, rxns, smiles, atom) + +I = (1, 1, atom) +ks = Int16.([5, 4, 6, 7, 2, 8, 3, 1]) +vs = [(Int16(6), Int16(6)), (Int16(0), Int16(0)), (Int16(9), Int16(4)), (Int16(11), Int16(2)), (Int16(3), Int16(1)), (Int16(10), Int16(1)), (Int16(5), Int16(3)), (Int16(1), Int16(1))] +dmc = Dict(zip(ks, vs)) + +ks = [# + Int16.([1, 2, 5, 6, 7]), + Int16.([1, 2, 5, 6]), + Int16.([1, 2, 5, 6, 7, 4]), + Int16.([1]), + Int16.([1, 2, 3]), + Int16.([1, 2, 3, 4]), + Int16.([1, 2]), + Int16.([1, 2, 5]), + Int16.([1, 2, 5, 6, 7, 8]), + Int16.([1, 2, 5, 6, 7, 8, 4]) +] +vs = [# + (id = 7, children = Int16.([8])), + (id = 6, children = Int16.([7])), + (id = 8, children = Int16.([])), + (id = 1, children = Int16.([2])), + (id = 3, children = Int16.([])), + (id = 4, children = Int16.([])), + (id = 2, children = Int16.([3, 5])), + (id = 5, children = Int16.([6])), + (id = 9, children = Int16.([])), + (id = 10, children = Int16.([])) +] +dchmc = Dict(zip(ks, vs)) + +T = SparseMatrixCSC([ + 0 1.0 0 0 0 0 0 0 0 0 + 0 0 0.3 0 0.7 0 0 0 0 0 + 0 0 0 1.0 0 0 0 0 0 0 + 1.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.125 0 0.875 0 0 0 + 0 0 0 0 0 0 0 0.875 0.125 0 + 1.0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0.125 0 0 0.875 + 1.0 0 0 0 0 0 0 0 0 0 +]) + +R = [# + (i = 1, j = 2, k = Int16(2)), + (i = 2, j = 3, k = Int16(3)), + (i = 2, j = 5, k = Int16(5)), + (i = 3, j = 4, k = Int16(4)), + (i = 4, j = 1, k = Int16(4)), + (i = 5, j = 6, k = Int16(6)), + (i = 6, j = 5, k = Int16(7)), + (i = 6, j = 7, k = Int16(8)), + (i = 7, j = 8, k = Int16(12)), + (i = 8, j = 1, k = Int16(12)), + (i = 7, j = 9, k = Int16(10)), + (i = 9, j = 10, k = Int16(11)), + (i = 10, j = 1, k = Int16(11)), + (i = 9, j = 7, k = Int16(9)) +] + +res = CHMCAtomicSummary(# + (1, 1, :C), + [# + (EFM = [6, 5, 6], Closures = [(6, 5)]), + (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)]), + (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)]), + (EFM = [8, 7, 8], Closures = [(9, 7)]), + (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)]) + ], + [0.09000000000000001, 0.56, 0.27, 0.01, 0.07], + [1.0, 6.222222222222222, 3.0, 0.11111111111111112, 0.7777777777777778], + dmc, + dchmc, + T, + R +) + +res_enum = CHMCAtomicSummary(# + (1, 1, :C), + [# + (EFM = [6, 5, 6], Closures = [(6, 5)]), + (EFM = [4, 1, 2, 5, 6, 7, 4], Closures = [(8, 1)]), + (EFM = [4, 1, 2, 3, 4], Closures = [(4, 1)]), + (EFM = [8, 7, 8], Closures = [(9, 7)]), + (EFM = [4, 1, 2, 5, 6, 7, 8, 4], Closures = [(10, 1)]) + ], + nothing, + nothing, + dmc, + dchmc, + T, + R +) + +efm_seq_1 = ["FDP", "F6P", "FDP"] +efm_seq_2 = ["Glc", "G6P", "F6P", "FDP", "DHAP"] +``` + ## Inputs ```julia @@ -72,84 +243,96 @@ smiles = [# "C([C@H](C=O)O)OP(=O)(O)O", "C(C(=O)COP(=O)(O)O)O" ] + +atom = :C # carbon atom type for AEFMs ``` We can check that the flux vector satisfies the steady state requirements. -```julia +```@example required all(S * v .== 0) # should evaluate as true ``` -## Pre-processing data -The following functions check for issues with the inputs. The first function -`find_atomic_chmc_input_errors` identifies possible problems with the -stoichiometry matrix and flux vector. These problems, except for the steady -state flux requirement, can be addressed via `correct_atomic_chmc_input_errors`. -Finally, the last function `correct_atomic_chmc_input_smiles` checks and fixes -problems relating to the SMILES strings. + +## Pre-processing data (wrapper) + +The following function pre-processes the input metabolic network for +computing the AEFM weights for the specified atom type. ```julia -# Confirm there are no issues with stoichiometry matrix -errors = find_atomic_chmc_input_errors(S, v) -print(errors) # summary of errors associated with S/v +mdl, atom_info, logs = preprocess_all_for_atomic_chmc(S, v, mets, rxns, smiles, atom) +``` -# S and v have no errors so the inputs are returned -correct_atomic_chmc_input_errors(errors, S, mets, rxns) -# S, mets, rxns = correct_atomic_chmc_input_errors(errors, S, mets, rxns) # otherwise +The variable `mdl` is a NamedTuple containing the updated stoichiometry +matrix, flux vector, metabolite/reaction names, metabolite SMILES strings, +reaction SMILES strings, and mapped reaction SMILES strings. -# Correct issues associated with RXNMapper character limit and pseudometabolites -S, v, mets, rxns, smiles, logs = correct_atomic_chmc_input_smiles(S, v, mets, rxns, smiles) +```@example required +keys(mdl) ``` -At this point, the SMILES strings (matching the updated `mets` if there were -errors in the initial inputs) should be canonicalized. `S` is also converted -to a `Matrix{Int16}` which is a requirement for subsequent functions. +The variable `logs` contains details about input metabolic network in +addition to listing the pseudometabolites and pseudoreactions dropped from +the network based on the input SMILES strings. -```julia -smiles = canonicalize_smiles(smiles) +```@example required +keys(logs) +``` + +```@example required +print(logs.model_errors) ``` -## Atom mapping reactions +```@example required +logs.smiles_warnings +``` -The reaction SMILES strings are next constructed from the metabolite SMILES and -the atom mapping is performed via RXNMapper. In this tutorial, we will be -constructing an atomic CHMC rooted on a particular source metabolite carbon. -We precompute an atom tracing dictionary mapping the (carbon) atom in the -stoichiometric copy of a substrate to its product across each reaction. +The variable `atom_info` contains the indices of all source metabolites in +the updated network and the number of occurrences for the input atom of +interest. It also contains an atom-mapping dictionary relating substrate-atom +positions to product-atom positions in each reaction. These are useful +for programmatically computing AEFMs across all source metabolite-atom +combinations of interest. -```julia -# Construct atom traced SMILES strings -rs, ms = map_reaction_strings(S, smiles, rxns, false) +```@example required +keys(atom_info) +``` -# Precompute atom tracing dictionary -atom = :C # carbon -atom_max = get_max_atoms(smiles, atom) -D_C = precompute_atom_tracing_dictionary(S, ms, atom_max, atom) # S must be Matrix{Int16} +```@example required +atom_info.src_mets # source metabolite indices +``` + +```@example required +atom_info.max_src_met_atoms # counts of specified atom in each source metabolite +``` -# Identify source metabolites -src_mets = get_source_metabolites(S) -max_src_met_carbons = atom_max[src_mets] +```@example required +atom_info.D # atom-mapping dictionary ``` ## Computing ACHMC for a given metabolite/carbon atom state The following atomic CHMC is rooted on the first carbon atom of the first -source metabolite in the stoichiometry matrix 6-phospho-D-gluconate. +source metabolite in the stoichiometry. ```julia -I = (src_mets[1], 1, atom) # initial state is 1st carbon of canonicalized glucose -res = steady_state_efm_distribution(S, v, ms, I, D_C; verbose = false) # S must be Matrix{Int16} +I = (atom_info.src_mets[1], 1, atom) # initial state is 1st carbon of canonicalized glucose +res = steady_state_efm_distribution(mdl.S, mdl.v, mdl.ms, I, atom_info.D; verbose = false) # S must be Matrix{Int16} +``` +```@example required +res ``` If we only wanted to enumerate the AEFMs, we would run: ```julia -enumerate_atomic_efms(S, ms, I, D_C, verbose = false) +res_enum = enumerate_atomic_efms(mdl.S, mdl.ms, I, atom_info.D, verbose = false) ``` Both functions produce the same output structure `res`, except that the -AEFM flux decomposition field will be a vector of zeros. +AEFM flux decomposition fields will be empty. The transition matrix will +also default to uniformly distributed probabilities along each row. ### Output @@ -157,28 +340,61 @@ The output `res` is an immutable struct with 8 fields: `res.i` is a tuple storing (i) the source metabolite index, (ii) source metabolite atom index (based on canonicalized SMILES string), and (iii) -the atom type. +the atom type. This is a copy of the variable `I`. + +```@example required +res.i +``` `res.e` is an array of AEFMs with all corresponding simple cycle closures. +```@example required +res.e +``` + `res.p` is an array of AEFM probabilities normalized to one. -`res.w` is an array of AEFM weights normalized by the (unimolecular) reaction flux of the source metabolite. +```@example required +res.p +``` + +`res.w` is an array of AEFM weights normalized by the (unimolecular) +reaction flux of the source metabolite. + +```@example required +res.w +``` `res.dchmc` is a dictionary storing the ACHMC. The keys are the ACHMC states (composed of Markov chain states in `res.dmc`). The values are the ACHMC state and the Markov chain state children. +```@example required +res.dchmc +``` + `res.dmc` is a dictionary converting Markov chain states to metabolite-atom positions. The value `(0, 0)` always corresponds to the external environment sink node (which connects back to the source metabolite-atom state). +```@example required +res.dmc +``` + `res.T` is a sparse array storing the ACHMC transition probability matrix. +```@example required +res.T +``` + `res.R` is an array of tuples storing the reaction index/indices mapped to each ACHMC transition matrix element. +```@example required +res.R +``` + ## Converting AEFM to sequence of metabolites The corresponding AEFMs correspond to the movement of @@ -190,12 +406,18 @@ omitted. ```julia # First AEFM -mets[first.(get_efm_metabolite_atom_indices(res, 1))] +efm_seq_1 = mets[first.(get_efm_metabolite_atom_indices(res, 1))] +``` +```@example required +efm_seq_1 ``` ```julia # Second AEFM -mets[first.(get_efm_metabolite_atom_indices(res, 2))] +efm_seq_2 = mets[first.(get_efm_metabolite_atom_indices(res, 2))] +``` +```@example required +efm_seq_2 ``` ## Visualizing the CHMC and mapped reactions @@ -233,7 +455,7 @@ off, try resizing the plotting window or reducing the canvas dimensions. using ElectronDisplay # Reaction string -plot_mapped_reaction(rs[2], view=true) +plot_mapped_reaction(rs[2], view=true, canvas_width = 1420, canvas_height = 580) #plot_mapped_reaction(rs[2], "\path\to\save\name.svg", view=true) ``` @@ -242,7 +464,7 @@ plot_mapped_reaction(rs[2], view=true) ```julia # Mapped reaction string plot_mapped_reaction(ms[2], view = true, canvas_width = 1420, canvas_height = 580) -#plot_mapped_reaction(ms[2], "\path\to\save\name.svg", view = true,) +#plot_mapped_reaction(ms[2], "\path\to\save\name.svg", view = true) ``` ![Mapped reaction SMILES string](../assets/ms-2.svg) diff --git a/src/chmc-algorithm/atomic/chmc-atomic.jl b/src/chmc-algorithm/atomic/chmc-atomic.jl index 2ad1428..2e2a861 100755 --- a/src/chmc-algorithm/atomic/chmc-atomic.jl +++ b/src/chmc-algorithm/atomic/chmc-atomic.jl @@ -863,9 +863,8 @@ end atom::Symbol ) -Wrapper function to run -Converts CHMC transition matrix `res.T` to a Markov chain with probabilities -taken from steady state flux vector `v`. +Wrapper function to run pre-processing functions and return the updated +model, atomic info, and error/warning logs. `S` is the m by n stoichiometry matrix. `v` is the steady state flux vector of length n.