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:
or
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:
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.
obj_coef
represents the objective coefficient.
geneAssociation
shows which genes control the reaction.
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)
?
::
mean?ecoli_core_evaluated
, called flux
.
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.
ecoli_core
, and rerunning find_fluxes_df
, you can see the effects of changes to the model.
find_fluxes_df
(you can see it just by typing the name in at the console).
do_minimization
do?EX_ac(e)
.
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.