corneto.methods.MultiSampleFBA#
- class corneto.methods.MultiSampleFBA(lambda_reg=0.0, beta_reg=0.0, flux_indicator_name='edge_has_flux', disable_structured_sparsity=False, default_flow_upper_bound=None, default_flow_lower_bound=None, backend=None)#
Bases:
FlowMethodFlux Balance Analysis (FBA) method for multiple samples.
This class implements Flux Balance Analysis for metabolic networks across multiple samples. It supports sparsity regularization and reaction objectives.
Note
The graph is expected to be a genome scale metabolic network. It can also be imported in SBML format (XML) using the
corneto.io.import_cobra_modelfunction (requires cobrapy).Flux Balance Analysis calculates metabolic fluxes by optimizing an objective such as biomass production subject to stoichiometric constraints.
MultiSampleFBA extends traditional FBA to analyze multiple samples or conditions simultaneously.
- Parameters:
- lambda_reg#
Regularization parameter to minimize the number of active reactions across samples (only when samples > 1).
- Type:
- beta_reg#
Additional regularization parameter for controlling sparsity individually for each sample.
- Type:
Examples
Basic usage with a single condition:
>>> from corneto.io import import_miom_model >>> from corneto.methods.fba import MultiSampleFBA >>> model = import_miom_model("path/to/metabolic_model.miom") >>> P = MultiSampleFBA().build( ... model, ... objectives={"EX_biomass_e": -1}, ... ) >>> P.solve()
Multi-condition analysis with a reaction knockout:
>>> P = MultiSampleFBA().build_many( ... model, ... objectives={ ... "control": {"EX_biomass_e": -1}, ... "knockout": {"EX_biomass_e": -1}, ... }, ... reaction_bounds={ ... "control": {}, ... "knockout": {"MDHm": (0, 0)}, ... }, ... )
- __init__(lambda_reg=0.0, beta_reg=0.0, flux_indicator_name='edge_has_flux', disable_structured_sparsity=False, default_flow_upper_bound=None, default_flow_lower_bound=None, backend=None)#
Initialize a MultiSampleFBA instance.
- Parameters:
lambda_reg (float, optional) – Primary sparsity regularization. Higher values encourage fewer active reactions. Defaults to 0.0.
beta_reg (float, optional) – Secondary regularization parameter for sparsity. Used when both types of regularization are needed. Defaults to 0.0.
flux_indicator_name (str, optional) – Name for the flux indicator variables. These track whether a reaction is active. Defaults to “edge_has_flux”.
disable_structured_sparsity (bool, optional) – Disable structured sparsity optimization. Defaults to False.
default_flow_lower_bound (float, optional) – Default reaction lower bound when the graph does not provide one.
default_flow_upper_bound (float, optional) – Default reaction upper bound when the graph does not provide one.
backend (Optional[Backend], optional) – The optimization backend to use. If None, the default backend is used. Defaults to None.
Methods
__init__([lambda_reg, beta_reg, ...])Initialize a MultiSampleFBA instance.
build(model[, data, objectives, reaction_bounds])Build a single-condition FBA problem from explicit inputs.
build_from_data(graph[, data])Build the complete optimization problem.
build_many(model, *[, objectives, ...])Build a multi-condition FBA problem from named condition mappings.
create_flow_based_problem(flow_problem, ...)Create the flow-based optimization problem.
create_problem(graph, data)Create the optimization problem using a flow-based formulation.
description()Returns a description of the method.
get_flow_bounds(graph, data)Return sample-specific flux bounds for the flow formulation.
name()Returns the name of the method.
preprocess(graph, data)Preprocess the graph and data before solving.
Return citation keys for the method.
show_bibtex()Display raw BibTeX entries in a formatted block for easy copying.
show_references()Display formatted citations in a Jupyter notebook.
Attributes
Return the optimization backend being used.
- build(model, data=None, *, objectives=None, reaction_bounds=None)#
Build a single-condition FBA problem from explicit inputs.
- build_many(model, *, objectives=None, reaction_bounds=None)#
Build a multi-condition FBA problem from named condition mappings.
- Parameters:
model (BaseGraph)
- preprocess(graph, data)#
Preprocess the graph and data before solving.
This can be extended with flux-consistent preprocessing such as removing blocked reactions or dead-end metabolites.
- get_flow_bounds(graph, data)#
Return sample-specific flux bounds for the flow formulation.
- create_flow_based_problem(flow_problem, graph, data)#
Create the flow-based optimization problem.
- static references()#
Return citation keys for the method.