\documentclass{beamer}
% Mario Latendresse.
%
% Modified on March 23, 2016. 
% Modified on October 9, 2018.
% kr:Nov-8-2021 Modified further.
% Slides for the Short FBA Tutorial (an hour and half).
% Check under ~brg/training/xxx/slides/flux-balance-analysis for
% latest version.

% Setup appearance:

\usetheme{Darmstadt}
\usefonttheme[onlylarge]{structurebold}
\setbeamerfont*{frametitle}{size=\normalsize,series=\bfseries}
\setbeamertemplate{navigation symbols}{}
\usepackage{graphicx}
\usepackage{hyperref} %% URLs

% Standard packages

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}

% Setup TikZ

\usepackage{tikz}
%\usetikzlibrary{arrows}

% The main document

\begin{document}

\tikzstyle{block}=[draw opacity=0.7,line width=1.4cm]

% Author, Title, etc.

\title[MetaFlux] 
{%
  MetaFlux in Pathway Tools: \\
  Flux Balance Analysis (FBA)\\
  (Short Tutorial)
}

\author[Krummenacker \& Latendresse]
{
  Markus Krummenacker, \\
  Mario Latendresse, \\
  Wai Kit Ong
}

\institute[SRI International]
{
 SRI International
}

\date[November 2021]{November 2021}


\begin{frame}{}
  \titlepage
\end{frame}

\begin{frame}{Outline}
  \tableofcontents
\end{frame}

%%%%%%%%%%%
\section{Introduction to Flux Balance Analysis}

\subsection{What is Flux Balance Analysis (FBA)?}

%%%

\begin{frame}{Metabolic Modeling Applications}
\begin{center}
\includegraphics[angle=0,scale=0.45]{fba_slides_2/Slide02.jpg}
\end{center}
\end{frame}


\begin{frame}{03}
\begin{center}
\includegraphics[angle=0,scale=0.40]{fba_slides_2/Slide03.jpg}
\end{center}
\end{frame}

\begin{frame}{04}
\begin{center}
\includegraphics[angle=0,scale=0.40]{fba_slides_2/Slide04.jpg}
\end{center}
\end{frame}

\begin{frame}{Simple Example of Fluxes}
\begin{center}
\includegraphics[angle=0,scale=0.40]{fba_slides_2/Slide05.jpg}
\end{center}
\end{frame}


% %%%
\begin{frame}{What is Flux Balance Analysis (FBA)?}

\begin{block}{Computing Fluxes of Reactions for Organism Growth}

Given a network of biochemical reactions, nutrients and secretions,
assign a flux (a numerical value) to every reaction to produce a set
of biomass metabolites for growth. Maximize the biomass.
{\bf The system is in a steady state (metabolite concentrations do not vary)}
\end{block}

\begin{block}{Applications}
FBA can be used to 1) analyze different growth conditions (e.g.,
nutrients), 2) effects of gene knockout, 3) do metabolic engineering,
and more
\end{block}
\end{frame}


\begin{frame}{What is a Flux of a Reaction?}

\begin{itemize}
\item The flux of a reaction is the rate of substrates consumed and
  produced, typically in steady state during growth 

 \item Fluxes are typically expressed as mmol per gram dry weight per hour, denoted mmol/gDW/hr 

\item Solving an FBA model gives the fluxes of all reactions that are
  needed to create a non-zero flux for {\bf all} biomass metabolites 
  necessary for growth

\end{itemize}
\end{frame}

%\end{frame}

\subsection{Overview of MetaFlux}

\begin{frame}{MetaFlux: The FBA Tool in Pathway Tools}

\begin{enumerate}
\item The FBA Tool, MetaFlux, was introduced in version 15.0 of Pathway Tools (Feb 2011)

\item MetaFlux has three modes: solving, development, and gene knockout

\item Solving mode: compute the fluxes of reactions to produce the biomass

\item Development mode: trying different biomass, nutrients,
  secretions, and reactions to create a model

\item Gene knockout: deactivating gene(s) from the model and
  see the effect on growth (testing a model)

\item Also, we can simulate a community of organisms in a grid space
  with multiple interacting organisms (multiple FBA models)
\end{enumerate}

\end{frame}


\begin{frame}{Assumptions}

%%%
\begin{block}{MetaFlux Main Assumptions}
\begin{itemize}
\item Regulation (of genes and enzymes) is ignored 
\item Cofactors (in enzymes) are ignored
\item That is, only metabolic reactions are used, and these
  reactions must specify all relevant metabolites to consider
\end{itemize}
\end{block}

\end{frame}

%%%
% \subsection{Standard LP Formulation}
% \begin{frame}{Standard FBA Mathematical Formulation}
% 
% \begin{block}{Main Formulation}
% \begin{align*}
%   &\mbox{Max}\, b_{\mbox{\tiny biomass}} \\ 
%   &{\bold S}_{ij}{\bold  v} = 0  \\
%   &\mbox{where} \,{\bold S}\, \mbox{is the stoichiometric matrix}
% \end{align*}
% \end{block}
% 
% $\bold S$ is a matrix where
% each row represents a metabolite and each column represents a reaction.
% 
% $ b_{\mbox{\tiny biomass}}$ is the flux for the biomass reaction.
% 
% $\mathbf v$ is a vector of variables representing the fluxes (real numbers).
% \ \\
% Reactions must be mass balanced.
% 
% \end{frame}
% 
% %%%%%%%%%%%
% \begin{frame}{An Example of an LP Formulation}
% 
% \begin{block}{The Reactions, Biomass,  Nutrients C, D, E}
% $\begin{array}{ll}
% R_1 :& A + 2 B \rightarrow Biomass \\
% R_2 :& C + D \rightarrow 2 A \\
% R_3 :& D + E \rightarrow B
% \end{array}
% $
% \end{block}
% 
% \begin{block}{The Linear Program (LP)}
% $\begin{array}{ll}
% A: & 2 R_2 - R_1 = 0 \\
% B: & R_3 - 2 R_1 = 0 \\
% C: & R_C - R_2 = 0 \\
% D: & R_D -R_2 - R_3 = 0 \\
% E: & R_E -R_3 = 0\\
% & Maximize\; R_1 \\
% &0 \le R_C, R_D, R_E \le  100
% \end{array}
% $
% \end{block}
% 
% \end{frame}
% 
% 
% %%%
% \begin{frame}{The Biomass Reaction}
% 
% It is a virtual reaction representing a set of metabolites to be produced to enable growth.
% 
% \begin{block}{}
% $$c_1 B_1 + c_2 B_2 + \cdots + c_n B_n \rightarrow Biomass$$
% \end{block}
% 
% The coefficients $c_i$ are integers (positive or negative).\\
% That reaction is in the $\mathbf S$ matrix (as any other reaction).\\
% 
% Note: {\bf all $B_i$ metabolites must be produced by some other
%   reactions in the organism to satisfy the LP formulation with a
%   non-zero biomass}.
% 
% \end{frame}


%%%
% \begin{frame}{MetaFlux Modes of Operation}
% 
% \begin{block}{Creating a Flux Balance Analysis (FBA) Model}
% Creating an FBA model consists in curating the
% description of an organism such that it represents 
% as accurately as possible the {\it in vivo} reaction fluxes 
% under certain conditions.
% \end{block}
% 
% \begin{block}{Solving an FBA Model}
% Solving an FBA model computes the reaction fluxes 
% under certain conditions. The model could be infeasible: no biomass
% produced.
% \end{block}
% 
% \begin{block}{Gene Knockout}
% A gene knockout deactivates the reactions catalyzed by a
% gene and solving such a model. We can verify an FBA model by comparing
% the results (growth/no growth) of a gene deletion with experimental data.
% \end{block}
% 
% \end{frame}

%%%%%%%%%%


\begin{frame}{MetaFlux Modes of Operation}
\begin{center}
\includegraphics[angle=0,scale=0.40]{fba_slides_2/Slide06.jpg}
\end{center}
\end{frame}

\begin{frame}{Creating an FBA Model vs Solving an FBA Model}
\begin{center}
\includegraphics[angle=0,scale=0.40]{fbaGenSolvingMode.png}
\end{center}
\end{frame}

%%%
\begin{frame}{The Linear Programming (LP) Solver}

\begin{itemize}
\item Solving a model is done by a Linear Programming (LP) solver

\item There are many open source and commercial LP solvers: CPLEX,
  GLPK, SCIP, Gurobi, and more 
  
\item Pathway Tools uses SCIP

\item Even with thousands of reactions, typical FBA/LP formulation can
  be solved in a few seconds

\item Solving in development mode could be longer (e.g., 20 seconds)
  or much longer (e.g., one hour).  Unpredictable.

\item MetaFlux is available on Mac OS X, Linux and Windows

\end{itemize}
\end{frame}


\begin{frame}{Painting Fluxes on Metabolic Map}
\begin{center}
\includegraphics[angle=0,scale=0.40]{fba_slides_2/Slide08.jpg}
\end{center}
\end{frame}

%%%kr:Nov-8-2021 What exactly does this mean ?
%%% It looks like a time series of Omics datapoints.  But how does
%%% this occur in MetaFlux ???
%%% PKarp said that this looks like the Pathway Collage...
%%% I'll comment this out for now.
%%%\begin{frame}{Series of Fluxes on Pathway Diagram}
%%%\begin{center}
%%%\includegraphics[angle=0,scale=0.40]{fba_slides_2/Slide09.jpg}
%%%\end{center}
%%%\end{frame}

\begin{frame}{Fluxes on Pathway Diagram}
\begin{center}
\includegraphics[angle=0,scale=0.40]{fba_slides_2/Slide10.jpg}
\end{center}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Submitting an FBA Input File}
% 
% \subsection{FBA Input File}
% 
% %%%
% \begin{frame}{Syntax of the MetaFlux Input File}
% 
% \begin{itemize}
% \item The input to MetaFlux is a text file (a \texttt{.fba} file)
% 
% \item See \texttt{template.fba} file (Pathway Tools distribution)
% 
% \item See \texttt{GlucoseAer.fba}, under aic-export/pgdbs/biocyc/ecocyc/19.0/data/fba/ecocyc-examples
% 
% \item Reactions are specified as frame-ids (common) or reaction equations (rare)
% 
% \item Metabolites are specified as names or frame-ids or use \texttt{all-compounds}
% 
% \item Keyword \texttt{metab-all} is all metabolic reactions in the PGDB
% 
% \item The keyword \texttt{metacyc-metab-all} is all  metabolic reactions in MetaCyc
% 
% \item Documentation in the FBA Chapter of the Pathway Tools' User Guide
% 
% \end{itemize}
% \end{frame}
% 
% %%%
% \begin{frame}{}
% \begin{itemize}
% 
% \item A graphical user interface (GUI) is used to submit an FBA input file
% 
% \item The invocation of the MetaFlux GUI is under the Tools menu 
% 
% \item The output files (e.g., {\tt .sol}) are displayed as a text file via a browser
% 
% \item The Cellular Omics Viewer can be invoked via one click to show the resulting fluxes
% 
% \item GUI demo using the {\tt GlucoseAer.fba} file for {\it E. coli}
% \end{itemize}
% \end{frame}
% 
% 
% \subsection{Output Produced}
% %%%
% \begin{frame}{Four Files Generated}
% 
% Four files are generated when submitting a model.
% 
% \begin{itemize}
% \item A {\tt .lp} file: the input to the SCIP solver
% \item A {\tt .log} file: a trace of the output of the generation of
%   the {\tt .lp} file. It contains the reactions that were filtered out (e.g. unbalanced or might be unbalanced).
% \item A {\tt .sol} file: a summary of the solution found as a text file. {\bf This is the file to look at first}. Contains
%  metabolites produced, nutrients and secretions used, added reactions, fluxes for all
%  reactions, and reactions with zero flux.
% \item A {\tt .dat} file: an omics data file for the Pathway Tools Cellular Overview. Contains
% only reactions with non-zero flux. Gap-filled reactions are not included.
% \end{itemize}
%  
% \end{frame}
% 
% \begin{frame}{The {\tt .log} File}
% \begin{itemize}
% \item Contains warnings and possibly error messages about unbalanced and instantiated reactions
% 
% \item Reactions that are unbalanced or might be unbalanced are not included in the model. These reactions are given in that file.
% 
% \item The process of instantiation of reactions is summarize in that file 
% 
% \end{itemize}
% \end{frame}
% 
% %%%
% \begin{frame}{The Solution File}
% 
% The solution files list the:
% 
% \begin{itemize}
% \item fixed- and try-biomass metabolites that could be produced
% \item fixed- and try-nutrients used
% \item fixed- and try-secretions produced
% \item added reactions from MetaCyc (reversed or not)
% \item added reversed reactions from the PGDB
% \item reactions with their non-zero flux
% \item remaining reactions that have zero flux
% \end{itemize}
% 
% \end{frame}
% 
% \begin{frame}{The {\tt .dat} File}
% \begin{itemize}
% \item  Each reaction having a flux is listed in that file
% 
% \item The file can be used by the Cellular Omics Viewer of Pathway Tools
% 
% \item The file can be used on the Web or the Desktop Omics Viewer
% 
% \item The Cellular Omics Viewer is directly accessible from the MetaFlux GUI
% 
% \end{itemize}
% \end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction to Development Mode}

%%%%%%%%%%%%
\subsection{Single and Multiple Gap-Filling}

%%%
\begin{frame}{MetaFlux Development Mode}
\begin{itemize}
\item Developing an accurate FBA model usually requires multiple
  refinements, such as:

\item including the addition of new reactions to a PGDB

\item altering the directionality of some reactions

\item fixing compartments of transport reactions

\item modifying the biomass reaction

\item adding new nutrients and secretions
\end{itemize}
\end{frame}

%%%
\begin{frame}{Single and Multiple Gap-Filling}
\begin{block}{Typically "Gap-Filling" Means "Completing the Reaction Network"}
\begin{itemize}
\item  Gap-filling suggests to add reactions from a reference database (e.g., MetaCyc)
to the FBA model to produce one or more biomass metabolites
\end{itemize}
\end{block}

\begin{block}{Multiple Gap-Filling on Important Metabolites}
 Multiple gap-filling applies gap-filling not only on reactions but
 also on nutrients, secretions, and biomass metabolites. For biomass metabolites, we
 try to include as many as possible, while still getting growth. For
 nutrients, we try to use as few as possible while still getting growth.
\end{block}   
\end{frame}

\subsection{User Input: Fixed and Try Sets, Weights}

% %%%
% \begin{frame}{Fixed Sets for Multiple Gap-filling}
% 
% The user provides fixed sets of reactions and metabolites ``at no cost or gain''.
% 
% \begin{itemize}
% \item Set of fixed reactions to use at no cost: typically all metabolic reactions of the PGDB
% are used 
% 
% \item Sets of nutrient and secreted metabolites that can be used at no cost 
% 
% \item But, it is recommended to start with an empty set of fixed biomass metabolites
% 
% \end{itemize}
% 
% \end{frame}

%%%
\begin{frame}{Try-Sets and Weights for Multiple Gap-filling}

The user provides four try-sets and weights to control the generation of the model.

\begin{itemize}
\item Set of reactions to try to add at a cost: typically all metabolic reactions of MetaCyc

\item Sets of nutrients, secretions and biomass metabolites to try to
add to the model 

\item Weights, as integers for gain and cost, for the reactions, nutrients, secretions, and biomass metabolites

\item Typically, adding a biomass metabolite is a gain, but adding a
  reaction or a nutrient is a cost. We have different weights for
  different type of reactions (e.g., spontaneous, in the taxonomic
  range, etc.)
\end{itemize}

\end{frame}

%%%
% \begin{frame}{The Weights: Costs and Gains}
% \begin{block}{Typical Weights}
% \begin{itemize}
% \item Adding a biomass metabolite to the model is a {\bf gain}. 
% 
% \item Adding any reaction, secretion, or nutrient has a {\bf cost}. 
% 
% \item That corresponds to the usual goal: generating as many biomass metabolites as possible
% with the minimum number of nutrients, secretions, and added reactions
% \end{itemize}
% \end{block}
% 
% \begin{block}{Variations}
% But other scenarios are useful: use as many nutrients and secretions as possible
% \end{block}
% 
% \begin{block}{Selecting the Right Weights for Reactions}
% There are many different weights for the reactions: taxonomic range, reversed, and more
% \end{block}
% \end{frame}


%%%
% \begin{frame}{The Reaction Weights}
% \begin{itemize}
% \item The basic weight for a reaction from MetaCyc 
%   \begin{itemize}
%   \item {\bf outside the taxonomic range} of the PGDB is given by {\tt try-reactions-weight}
%   \item {\bf in the taxonomic range} of the PGDB is given by {\tt try-reactions-in-taxa-weight}
%   \item {\bf of unknown taxonomic range} is given by {\tt try-reactions-unknown-taxa-weight}
%   \end{itemize}
% 
% \end{itemize}

%\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Knockouts of Genes and Reactions}

\begin{frame}{Testing a Model Using Knockouts of Genes}
\begin{block}{Knocking Out One Gene}
\begin{itemize}
\item Knocking out a gene means to deactivate the reactions catalyzed by
  that gene

\item Isozymes are taken into account
\end{itemize}
\end{block}

\begin{block}{Multiple Knockouts}
More than one gene might be knocked out simultaneously,
to hit isozymes or alternate pathways
\end{block}   

\begin{block}{Batch Knockouts}
Typically, MetaFlux is used to run a batch of gene knockouts (e.g., all genes)  
\end{block}   
\end{frame}


%%%%%%%%%%%%%
\begin{frame}{Examples of Knockout FBA Input Files}
\begin{itemize}

\item Examples of gene knockout run on EcoCyc for

\begin{enumerate}
\item A few genes: cysN, cysD, gltX

\item All metabolic genes with summary solution file only (takes about one minute)

\item All metabolic genes with all solution files generated (takes more than one minute)
\end{enumerate}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%
\section{Dynamic FBA of an Organism Community}

\begin{frame}{Dynamic FBA (dFBA)}
\begin{itemize}

\item Dynamic FBA (dFBA) goes beyond the steady state of FBA by solving a
  series of FBAs, which track changing conditions

\item Each solved FBA changes the growth environment by keeping track
  of nutrients used and secretions produced

\item dFBA replicates real growth with concentrations of
  metabolites in the growth environment
\end{itemize}

\end{frame}

%%%%%%%%%%%%%
\begin{frame}{Dynamic FBA of a Community of Organisms}
\begin{itemize}

\item A community of organisms can be represented by a set of FBAs
  exchanging metabolites in a compartment (e.g., extra-cellular)

\item The organisms are in a real physical space represented as a grid

\item The FBA of each organism is solved and the concentations of
  secretions and nutrients are updated in each grid box 

\item When solving a FBA, the nutrient uptakes are bounded by the
  concentrations of metabolites
\end{itemize}

\end{frame}

\begin{frame}{Dynamic FBA of {\it E. coli}}
\begin{center}
\includegraphics[angle=0,scale=0.40]{fba_slides_2/Slide11.jpg}
\end{center}
\end{frame}

\begin{frame}{Dynamic FBA Community of Organisms}
\begin{center}
\includegraphics[angle=0,scale=0.35]{fba2/Slide2.jpg}
\end{center}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Further Literature on MetaFlux}

\begin{enumerate}
\item Mario Latendresse, Markus Krummenacker, Miles Trupp, and Peter Karp, 
{\it Construction and Completion of Flux-Balance Models from Pathway
  Databases}, Bioinformatics, doi: 10.1093/bioinformatics/btr681, 
January 2012. \href{http://bioinformatics.oxfordjournals.org/content/early/2012/01/18/bioinformatics.btr681.abstract?sid=789970da-b0ee-49d7-bd1f-eaa7b559dad8}{Open access}

\item Mario Latendresse, {\it Efficiently gap-filling reaction networks},
BMC Bioinformatics, June 28, 2014, 15:225, doi:
10.1186/1471-2105-15-225.

\item {\it Pathway Tools User Guide}
\end{enumerate}

\end{frame}

\end{document}


