- Notifications
You must be signed in to change notification settings - Fork1
maxconway/fbar
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
fbar is a simple, easy to use Flux Balance Analysis package with atidy data approach. Justdata_frames and the occasionallist, no newclasses to learn. The focus is on simplicity and speed. Models areexpected as a flat table, and results can be simply appended to thetable. This makes this package very suitable for useage in pipelineswith pre- and post- processing of models and results, so that it workswell as a backbone for customized methods. Loading, parsing andevaluating a model takes around 0.1s, which, together with thestraightforward data structures used, makes this library very suitablefor large parameter sweeps.
This example calculates the fluxes for the model ecoli_core.Ecoli_core starts out as a data frame, and is returned as the same dataframe, with fluxes appended.
library(fbar)data(ecoli_core)try({# this will fail if no appropriate solver is available. library(ROI.plugin.ecos)ecoli_core_with_flux<- find_fluxes_df(ecoli_core)})
This example finds the fluxes in ecoli_core, just like the previouscase. However, this has more detail to show how the package works.
library(fbar)library(dplyr)library(ROI)try(library(ROI.plugin.ecos))data(ecoli_core)roi_model<-ecoli_core %>%reactiontbl_to_expanded %>%expanded_to_ROI# First, we need to check that an appropriate solver is available.# If you don't have an appropriate solver, see the section on installing# one later in this document.if(length(ROI_applicable_solvers(roi_model))>=1){roi_result<- ROI_solve(roi_model)ecoli_core_with_flux<-ecoli_core %>% mutate(flux=roi_result[['solution']])}
This example expands the single data frame model into an intermediateform, the collapses it back to a gurobi model and evaluates it. Then itadds the result as a column, named flux. This longer style is usefulbecause it allows access to the intermediate form. This just consists ofthree data frames: metabolites, stoichiometry, and reactions. This makesit easy to alter and combine models.
fbar’s functions can be considered in three groups: conveniencewrappers which perform a common workflow all in one go, parsing andconversion functions that form the core of the package and provideextensibility, and functions for gene set processing which allow modelsto be parameterized by genetic information.
These functions wrap common workflows. They parse and evaluate modelsall in one go.
find_fluxes_df- Given a metabolic model as a data frame, return anew data frame with fluxes. For simple FBA, this is what you want.find_flux_varability_df- Given a metabolic model as a data frame,return a new data frame with fluxes and variability.
These functions convert metabolic models between different formats.
reactiontbl_to_expanded- Convert a reaction table to an expanded,intermediate, format.expanded_to_gurobi,expanded_to_glpkandexpanded_to_ROI-Convert a metabolic model in expanded format to the input format fora linear programming library.reactiontbl_to_gurobi- Convert a reaction table data frame togurobi format. This is shorthand forreactiontbl_to_expandedfollowed byexpanded_to_gurobi.
These functions process gene protein reaction mappings.
gene_eval- Evaluate gene sets in the context of particular genepresence levels.gene_associate- Apply gene presence levels to a metabolic model.
devtools::install_github('maxconway/fbar')
This package requires a linear programming solver.ROI.plugin.ecos isinstalled by default, and does the job, but other solvers, such asGurobi and GLPK are faster. Anything that is supported by the ROptimization Infrastructure package should work.
The most famous package for constraint based methods is probably COBRA,a Matlab package. If you prefer Matlab to R, you’ll probably want to trythat beforefbar.
The existing R packages for Flux Balance Analysis includesybil andabcdeFBA. Compared to these packages,fbar is smaller and does less.The aim offbar is to be more suitable for use as a building block inbioinformatics pipelines. Whereassybil and to a lesser extentabcdeFBA intend to act as tools with a function for each analysis youmight want to do,fbar intends to supply just enough functionalitythat you can easily construct your analysis with only standard dataframe operations.
fbar usesROI by default,which gives access to a number of solvers via plugins. It also supportsRglpk and Gurobi directly.Gurobi issubstantially faster than other solvers in my experience, so it isrecommended if you can get it (it is commercial, but has a free academiclicence).
If you find problems with the package, or there’s anything that itdoesn’t do which you think it should, please submit them tohttps://github.com/maxconway/fbar/issues. In particular, let me knowabout optimizers and formats which you’d like supported, or if you havea workflow which might make sense for inclusion as a default conveniencefunction.
About
A simple, easy to use Flux Balance Analysis package with a tidy data approach
Resources
Uh oh!
There was an error while loading.Please reload this page.