Class 29 - Flux Balance Analysis

In this exercise we'll load a simplified metabolic network for the bacteria Escherichia coli and find the steady-state metabolic flux through this network that maximizes the rate of cellular growth, subject to thermodynamic constraints.

Read the stoichiometric matrix from a tab-delimited data file with M rows and N columns


In [1]:
S <- as.matrix(read.table("shared/ucsd_ecoli_stoich_matrix.txt",
                          header=TRUE,
                          row.names=1,
                          sep="\t",
                          comment.char="",
                          quote="",
                          stringsAsFactors=FALSE))
M <- nrow(S)
N <- ncol(S)
cat(sprintf("The stoichiometrix matrix has %d rows (metabolites) and %d columns (reactions)\n",
             M, N))


The stoichiometrix matrix has 72 rows (metabolites) and 95 columns (reactions)

Read the min and max flux values, and the objective function coefficients, from a tab-delimited data file with N rows and 3 columns


In [2]:
v_minmax <- as.matrix(read.table("shared/ucsd_ecoli_reaction_maxmin.txt",
                                 sep="\t",
                                 header=TRUE,
                                 comment.char="",
                                 row.names=1,
                                 quote="",
                                 stringsAsFactors=FALSE))
                      
stopifnot(all(make.names(rownames(v_minmax)) == colnames(S)))

head(v_minmax)


minmaxobjective
ACALD-10001000 0
ACALDt-10001000 0
ACKr-10001000 0
ACONTa-10001000 0
ACONTb-10001000 0
ACt2r-10001000 0

Create a constraint matrix (with C rows and N columns) and a corresponding constant vector of length C, giving the right-hand-side of the inequality


In [3]:
Svmin <- S %*% matrix(v_minmax[,"min"], ncol=1)

constraint_matrix <- rbind(S,
                           S,
                           diag(rep(1,N)),
                           diag(rep(1,N)))

constraint_rhs <- c(-Svmin,
                    -Svmin,
                    rep(0, N),
                    v_minmax[,"max"] - v_minmax[,"min"])

constraint_dir <- c(rep(">=", M),
                    rep("<=", M),
                    rep(">=", N),
                    rep("<=", N))

stopifnot(length(constraint_rhs) == nrow(constraint_matrix))
stopifnot(ncol(constraint_matrix) == N)
stopifnot(nrow(v_minmax) == N)

dim(constraint_matrix)


  1. 334
  2. 95

Find the flux value that maximizes the "biomass" reaction flux, consistent with the steady-state and thermodynamic constraints


In [5]:
library(lpSolve)
lpres <- lp("max",
   objective.in=v_minmax[,"objective"],
   const.mat=constraint_matrix,
   const.dir=constraint_dir,
   const.rhs=constraint_rhs)

print(lpres$solution + v_minmax[,"min"])


             ACALD             ACALDt               ACKr             ACONTa 
      0.000000e+00       1.136868e-13      -2.273737e-13       6.007250e+00 
            ACONTb              ACt2r               ADK1              AKGDH 
      6.007250e+00      -1.136868e-13       0.000000e+00       5.064376e+00 
            AKGt2r             ALCD2x               ATPM             ATPS4r 
     -1.136868e-13      -1.136868e-13       8.390000e+00       4.551401e+01 
Biomass_Ecoli_core               CO2t                 CS              CYTBD 
      8.739215e-01      -2.280983e+01       6.007250e+00       4.359899e+01 
           D-LACt2                ENO            ETOHt2r           EX_ac(e) 
     -1.136868e-13       1.471614e+01      -1.136868e-13       0.000000e+00 
       EX_acald(e)          EX_akg(e)          EX_co2(e)         EX_etoh(e) 
      0.000000e+00       0.000000e+00       2.280983e+01       0.000000e+00 
         EX_for(e)          EX_fru(e)          EX_fum(e)          EX_glc(e) 
      0.000000e+00       0.000000e+00       0.000000e+00      -1.000000e+01 
       EX_gln_L(e)        EX_glu_L(e)            EX_h(e)          EX_h2o(e) 
      0.000000e+00       0.000000e+00       1.753087e+01       2.917583e+01 
       EX_lac_D(e)        EX_mal_L(e)          EX_nh4(e)           EX_o2(e) 
      0.000000e+00       0.000000e+00      -4.765319e+00      -2.179949e+01 
          EX_pi(e)          EX_pyr(e)         EX_succ(e)                FBA 
     -3.214895e+00       0.000000e+00       0.000000e+00       7.477382e+00 
               FBP              FORt2              FORti               FRD7 
      0.000000e+00       0.000000e+00       0.000000e+00       0.000000e+00 
           FRUpts2                FUM            FUMt2_2            G6PDH2r 
      0.000000e+00       5.064376e+00       0.000000e+00       4.959985e+00 
              GAPD             GLCpts               GLNS             GLNabc 
      1.602353e+01       1.000000e+01       2.234617e-01       0.000000e+00 
             GLUDy               GLUN              GLUSy             GLUt2r 
     -4.541857e+00       0.000000e+00       0.000000e+00      -1.136868e-13 
               GND               H2Ot             ICDHyr                ICL 
      4.959985e+00      -2.917583e+01       6.007250e+00       0.000000e+00 
             LDH_D               MALS            MALt2_2                MDH 
      1.136868e-13       0.000000e+00       0.000000e+00       5.064376e+00 
               ME1                ME2             NADH16            NADTRHD 
      0.000000e+00       0.000000e+00       3.853461e+01       0.000000e+00 
              NH4t                O2t                PDH                PFK 
      4.765319e+00       2.179949e+01       9.282533e+00       7.477382e+00 
               PFL                PGI                PGK                PGL 
      0.000000e+00       4.860861e+00      -1.602353e+01       4.959985e+00 
               PGM              PIt2r                PPC               PPCK 
     -1.471614e+01       3.214895e+00       2.504309e+00       0.000000e+00 
               PPS               PTAr                PYK             PYRt2r 
      0.000000e+00       0.000000e+00       1.758177e+00       1.136868e-13 
               RPE                RPI           SUCCt2_2             SUCCt3 
      2.678482e+00      -2.281503e+00       0.000000e+00       0.000000e+00 
             SUCDi             SUCOAS               TALA               THD2 
      5.064376e+00      -5.064376e+00       1.496984e+00       0.000000e+00 
              TKT1               TKT2                TPI 
      1.496984e+00       1.181498e+00       7.477382e+00 

In [ ]: