Tutorial

Max Conway

2020-09-02

Introduction

While README.Rmd or the Introduction vignette provide a brief overview of the package, this vignette is intended to provide a more complete guide, with examples of usage, and exercises.

Installation and Optimizers

The fbar package should install in a very straightforward manner, as follows:

install.packages('fbar')
library(fbar)

or

devtools::install_github('maxconway/fbar')
library(fbar)

However, fbar, like all flux balance analysis packages, requires an linear programming library in order to conduct simulations. fbar can use a number of linear programming libraries via the R Optimization Infrastructure (ROI) library and its plugins, and also supports Rglpk and gurobi directly.

The suggested method to get started quickly is via the ROI.plugin.ecos library. To install and set it up, just run:

ROI::ROI_registered_solvers()
install.packages('ROI.plugin.ecos')
library('ROI.plugin.ecos') # This line is necessary to register the plugin with ROI the first time
ROI::ROI_registered_solvers()

The ROI.plugin.ecos library does not export any functions, but running the library statement is necessary after installation to register with ROI.

Installing other optimizers to work with ROI is normally similar, but you may have to install a separate package on your operating system first.

Looking at a model and understanding what it means

Download a simple model for Escherichia coli by running the following code:

library(fbar) # load fbar package
data(ecoli_core)

To look at the model, you might want to use the filter and select functions from dplyr, or if you’re using Rstudio, the View function.

Questions

  1. One of the reactions has an unusually long equation.
    1. What does this reaction represent?
    2. Why does it have such a long equation?
    3. Why is the stoichiometry of this reaction unusual?
  2. Some of the equations are one sided.
    1. What does this mean?
    2. Why don’t these reactions have gene sets associated with them?
  3. The letters in square brackets represent compartments.
    1. Why are these useful?
    2. What might [c] stand for?
    3. What might [e] stand for?
    4. This E. coli model has only two compartments. Why might a model of S. cerevisiae have more?
  4. The columns lowbnd and uppbnd represent the limits on reaction rates.
    1. Why is ±1000 used in many places in these columns?
    2. What ways can you tell if a reaction is reversible or not?
  5. The column obj_coef represents the objective coefficient.
    1. If we multiplied everything in this column by 5, how would that effect the model?
    2. If we multiplied everything in this column by -1, how would that effect the model?
  6. geneAssociation shows which genes control the reaction.
    1. Which reactions would be affected if we knocked out gene b1241?
    2. Which reactions would be affected if we knocked out gene b0351?
    3. Which reactions would be affected if we knocked out gene b0356?
    4. Which reactions would be affected if we knocked out genes b0351 and b0356?
    5. Which reactions would be affected if we knocked out genes b0351 and b1241?
    6. Which reactions would be affected if we knocked out genes b0356 and b1241?

Parsing and evaluating a model

To find the fluxes, and then compare them to the original model, do the following:

library(dplyr) # load dplyr, to explore data

ecoli_fluxes <- ecoli_core %>% 
  reactiontbl_to_expanded() %>% 
  expanded_to_ROI() %>% 
  ROI::ROI_solve() %>% 
  ROI::solution()

ecoli_core_evaluated <- ecoli_core %>%
  mutate(flux = ecoli_fluxes)

Questions

  1. The code above performs a number of operations, using a number of packages.
    1. What does each line do? You’ll probably want to use R’s help function, ?
    2. what does :: mean?
  2. A new column has been added to ecoli_core_evaluated, called flux.
    1. What does this represent?
    2. What does it mean when a value is zero?
    3. Why are some of the number negative?
    4. What would be suitable units for this column?
    5. How does flux compare to uppbnd and lowbnd?

Modifying models

The code in the previous section is explict, but we don’t necessarily want to type it all out each time we evaluate a model. The code below does (roughly) the same thing in one line, so we can explore the model faster.

evaluated <- find_fluxes_df(ecoli_core)

Questions

  1. By altering ecoli_core, and rerunning find_fluxes_df, you can see the effects of changes to the model.
    1. Which reactions can you delete without changing biomass production?
    2. Alter the bounds of a reaction to increase biomass production.
    3. Find another reaction and change the bounds to reduce biomass production again, but not to 0.
  2. Look at the source code of find_fluxes_df (you can see it just by typing the name in at the console).
    1. What does the argument do_minimization do?
    2. Why is this possible?
    3. Why would we want to do this?
  3. Find the reaction EX_ac(e).
    1. What does it do?
    2. Find the maximum acetate production possible without taking biomass production below 0.5.

mirror server hosted at Truenetwork, Russian Federation.