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
fbar package should install in a very straightforward manner, as follows:
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
The suggested method to get started quickly is via the
ROI.plugin.ecos library. To install and set it up, just run:
library('ROI.plugin.ecos') # This line is necessary to register the plugin with ROI the first time
ROI.plugin.ecos library does not export any functions, but running the
library statement is necessary after installation to register with
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
To look at the model, you might want to use the
select functions from
dplyr, or if you’re using Rstudio, the
- One of the reactions has an unusually long equation.
- What does this reaction represent?
- Why does it have such a long equation?
- Why is the stoichiometry of this reaction unusual?
- Some of the equations are one sided.
- What does this mean?
- Why don’t these reactions have gene sets associated with them?
- The letters in square brackets represent compartments.
- Why are these useful?
- What might [c] stand for?
- What might [e] stand for?
- This E. coli model has only two compartments. Why might a model of S. cerevisiae have more?
- The columns
uppbnd represent the limits on reaction rates.
- Why is ±1000 used in many places in these columns?
- What ways can you tell if a reaction is reversible or not?
- The column
obj_coef represents the objective coefficient.
- If we multiplied everything in this column by 5, how would that effect the model?
- If we multiplied everything in this column by -1, how would that effect the model?
geneAssociation shows which genes control the reaction.
- Which reactions would be affected if we knocked out gene b1241?
- Which reactions would be affected if we knocked out gene b0351?
- Which reactions would be affected if we knocked out gene b0356?
- Which reactions would be affected if we knocked out genes b0351 and b0356?
- Which reactions would be affected if we knocked out genes b0351 and b1241?
- 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 %>%
ecoli_core_evaluated <- ecoli_core %>%
mutate(flux = ecoli_fluxes)
- The code above performs a number of operations, using a number of packages.
- What does each line do? You’ll probably want to use R’s help function,
- what does
- A new column has been added to
- What does this represent?
- What does it mean when a value is zero?
- Why are some of the number negative?
- What would be suitable units for this column?
- How does
flux compare to
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)
- By altering
ecoli_core, and rerunning
find_fluxes_df, you can see the effects of changes to the model.
- Which reactions can you delete without changing biomass production?
- Alter the bounds of a reaction to increase biomass production.
- Find another reaction and change the bounds to reduce biomass production again, but not to 0.
- Look at the source code of
find_fluxes_df (you can see it just by typing the name in at the console).
- What does the argument
- Why is this possible?
- Why would we want to do this?
- Find the reaction
- What does it do?
- Find the maximum acetate production possible without taking biomass production below 0.5.
When you’re done with this, you might want to look at the vignette
Multi-Objective Optimization case study, to see an example of this package in a a more complicated context. Try using the code to find a good tradeoff between production of Acetate and Biomass.