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.
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.
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.
lowbnd
and uppbnd
represent the limits on reaction rates.
a. Why is ±1000 used in many places in these columns?
b. What ways can you tell if a reaction is reversible or not?obj_coef
represents the objective coefficient.
a. If we multiplied everything in this column by 5, how would that effect the model?
b. If we multiplied everything in this column by -1, how would that effect the model?geneAssociation
shows which genes control the reaction.
a. Which reactions would be affected if we knocked out gene b1241?
b. Which reactions would be affected if we knocked out gene b0351?
c. Which reactions would be affected if we knocked out gene b0356?
d. Which reactions would be affected if we knocked out genes b0351 and b0356?
e. Which reactions would be affected if we knocked out genes b0351 and b1241?
f. Which reactions would be affected if we knocked out genes b0356 and b1241?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)
?
b. what does ::
mean?ecoli_core_evaluated
, called flux
.
a. What does this represent?
b. What does it mean when a value is zero?
c. Why are some of the number negative?
d. What would be suitable units for this column?
e. How does flux
compare to uppbnd
and lowbnd
?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)
ecoli_core
, and rerunning find_fluxes_df
, you can see the effects of changes to the model.
a. Which reactions can you delete without changing biomass production?
b. Alter the bounds of a reaction to increase biomass production.
c. Find another reaction and change the bounds to reduce biomass production again, but not to 0.find_fluxes_df
(you can see it just by typing the name in at the console).
a. What does the argument do_minimization
do?
b. Why is this possible?
c. Why would we want to do this?EX_ac(e)
.
a. What does it do?
b. 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.