Skip to content

Commit

Permalink
GrowthCouplingPotential (#215)
Browse files Browse the repository at this point in the history
* FSEOF improvements

* feat: implement GrowthCouplingPotential optimization

* fix: flake8

* test: add test for GrowthCouplingPotential

* feat: add gurobi solution pool capability

* fix: remove blocked reactions from reaction lists

* fix: flake8

* chore: bring branch up to date

* fix: avoid adding list and set

* test: update GrowthCouplingPotential tests

* fix: remove commented line

* test: assert that target is not growth coupled in wild-type

Co-authored-by: KristianJensen <krisje@nnfcb-l0275.local>
Co-authored-by: Kristian Jensen <dkkrje@chr-hansen.com>
Co-authored-by: carrascomj <carrascomurielj@gmail.com>
  • Loading branch information
4 people committed Nov 15, 2021
1 parent 598b0a0 commit 8b1adb7
Show file tree
Hide file tree
Showing 3 changed files with 438 additions and 35 deletions.
31 changes: 0 additions & 31 deletions cameo/strain_design/deterministic/flux_variability_based.py
Expand Up @@ -74,7 +74,6 @@

class DifferentialFVA(StrainDesignMethod):
r"""Differential flux variability analysis.
Compares flux ranges of a reference model to a set of models that
have been parameterized to lie on a grid of evenly spaced points in the
# n-dimensional production envelope (n being the number of reaction bounds
Expand All @@ -89,10 +88,8 @@ class DifferentialFVA(StrainDesignMethod):
| . . . . . . \
o--------------*- >
growth
Overexpression, downregulation, knockout, flux-reversal and other
strain engineering targets can be inferred from the resulting comparison.
Parameters
----------
design_space_model : cobra.Model
Expand All @@ -113,7 +110,6 @@ class DifferentialFVA(StrainDesignMethod):
will be normalized by.
points : int, optional
Number of points to lay on the surface of the n-dimensional production envelope (defaults to 10).
Examples
--------
>>> from cameo import models
Expand Down Expand Up @@ -283,7 +279,6 @@ def _init_search_grid(self, surface_only=False, improvements_only=True):
def run(self, surface_only=True, improvements_only=True, progress=True,
view=None, fraction_of_optimum=1.0):
"""Run the differential flux variability analysis.
Parameters
----------
surface_only : bool, optional
Expand All @@ -299,7 +294,6 @@ def run(self, surface_only=True, improvements_only=True, progress=True,
A value between zero and one that determines the width of the
flux ranges of the reference solution. The lower the value,
the larger the ranges.
Returns
-------
pandas.Panel
Expand Down Expand Up @@ -482,25 +476,18 @@ def __init__(self, solutions, phase_plane, reference_fva, **kwargs):
def _generate_designs(cls, solutions, reference_fva):
"""
Generates strain designs for Differential FVA.
The conversion method has three scenarios:
#### 1. Knockout
Creates a ReactionKnockoutTarget.
#### 2. Flux reversal
If the new flux is negative then it should be at least the upper
bound of the interval. Otherwise it should be at least the lower
bound of the interval.
#### 3. The flux increases or decreases
This table illustrates the possible combinations.
* Gap is the sign of the normalized gap between the intervals.
* Ref is the sign of the closest bound (see _closest_bound).
* Bound is the value to use
+-------------------+
| Gap | Ref | Bound |
+-----+-----+-------+
Expand All @@ -509,15 +496,12 @@ def _generate_designs(cls, solutions, reference_fva):
| + | - | UB |
| + | + | LB |
+-----+-----+-------+
Parameters
----------
solutions: pandas.Panel
The DifferentialFVA panel with all the solutions. Each DataFrame is a design.
reference_fva: pandas.DataFrame
The FVA limits for the reference strain.
Returns
-------
list
Expand Down Expand Up @@ -620,7 +604,6 @@ def __getitem__(self, item):
def nth_panel(self, index):
"""
Return the nth DataFrame defined by (biomass, production) pairs.
When the solutions were still based on pandas.Panel this was simply
self.solutions.iloc
"""
Expand Down Expand Up @@ -704,23 +687,18 @@ def plot_scale(self, palette="YlGnBu"):
"""
Generates a color scale based on the flux distribution.
It makes an array containing the absolute values and minus absolute values.
The colors set as follows (p standsfor palette colors array):
min -2*std -std 0 std 2*std max
|-------|-------|-------|-------|-------|-------|
p[0] p[0] .. p[1] .. p[2] .. p[3] .. p[-1] p[-1]
Parameters
----------
palette: Palette, list, str
A Palette from palettable of equivalent, a list of colors (size 5) or a palette name
Returns
-------
tuple:
((-2*std, color), (-std, color) (0 color) (std, color) (2*std, color))
"""
if isinstance(palette, str):
palette = mapper.map_palette(palette, 5)
Expand Down Expand Up @@ -868,20 +846,17 @@ def _set_bounds(self, point):
class FSEOF(StrainDesignMethod):
"""
Performs a Flux Scanning based on Enforced Objective Flux (FSEOF) analysis.
Parameters
----------
model : cobra.Model
enforced_reaction : Reaction
The flux that will be enforced. Reaction object or reaction id string.
primary_objective : Reaction
The primary objective flux (defaults to model.objective).
References
----------
.. [1] H. S. Choi, S. Y. Lee, T. Y. Kim, and H. M. Woo, 'In silico identification of gene amplification targets
for improvement of lycopene production.,' Appl Environ Microbiol, vol. 76, no. 10, pp. 3097–3105, May 2010.
"""

def __init__(self, model, primary_objective=None, *args, **kwargs):
Expand Down Expand Up @@ -909,7 +884,6 @@ def run(self, target=None, max_enforced_flux=0.9, number_of_results=10, exclude=
simulation_kwargs=None):
"""
Performs a Flux Scanning based on Enforced Objective Flux (FSEOF) analysis.
Parameters
----------
target: str, Reaction, Metabolite
Expand All @@ -920,17 +894,14 @@ def run(self, target=None, max_enforced_flux=0.9, number_of_results=10, exclude=
number_of_results : int, optional
The number of enforced flux levels (defaults to 10).
exclude : Iterable of reactions or reaction ids that will not be included in the output.
Returns
-------
FseofResult
An object containing the identified reactions and the used parameters.
References
----------
.. [1] H. S. Choi, S. Y. Lee, T. Y. Kim, and H. M. Woo, 'In silico identification of gene amplification targets
for improvement of lycopene production.,' Appl Environ Microbiol, vol. 76, no. 10, pp. 3097–3105, May 2010.
"""
model = self.model
target = get_reaction_for(model, target)
Expand Down Expand Up @@ -1004,7 +975,6 @@ def run(self, target=None, max_enforced_flux=0.9, number_of_results=10, exclude=
class FSEOFResult(StrainDesignMethodResult):
"""
Object for storing a FSEOF result.
Attributes:
-----------
reactions: list
Expand All @@ -1015,7 +985,6 @@ class FSEOFResult(StrainDesignMethodResult):
A pandas DataFrame containing the fluxes for every reaction for each enforced flux.
run_args: dict
The arguments that the analysis was run with. To repeat do 'FSEOF.run(**FSEOFResult.run_args)'.
"""

__method_name__ = "FSEOF"
Expand Down

0 comments on commit 8b1adb7

Please sign in to comment.