micom.media¶
Manages functions for growth media analysis and manipulation.
Functions¶
|
Add a linear version of a minimal medium to the community. |
|
Add a mixed-integer version of a minimal medium to the community. |
|
Get the weight of a molecule. |
|
Obtain elemental weights for metabolites. |
|
Find the minimal growth medium for the community. |
|
Fill in missing components in a growth medium. |
Module Contents¶
- micom.media.add_linear_obj(community, exchanges, weights)[source]¶
Add a linear version of a minimal medium to the community.
Changes the optimization objective to finding the growth medium requiring the smallest total import flux:
minimize sum w_i|r_i| for r_i in import_reactions
- Parameters:
community (micom.Community) – The community to modify.
exchanges (list of cobra.Reaction) – The reactions to constrain.
weights (dict) – Maps each exchange reaction to a weight that is used in the minimization.
- micom.media.add_mip_obj(community, exchanges)[source]¶
Add a mixed-integer version of a minimal medium to the community.
Changes the optimization objective to finding the medium with the least components:
minimize size(R) where R part of import_reactions
- Parameters:
community (micom.Community) – The community to modify.
exchanges (list of cobra.Reaction) – The reactions to constrain.
- micom.media.minimal_medium(community, community_growth, min_growth=0.0, exports=False, exchanges=None, minimize_components=False, open_exchanges=False, solution=False, weights=None, atol=None, rtol=None)[source]¶
Find the minimal growth medium for the community.
Finds the minimal growth medium for the community which allows for community as well as individual growth. Here, a minimal medium can either be the medium requiring the smallest total import flux or the medium requiring the least components (ergo ingredients).
- Parameters:
community (micom.Community) – The community to modify.
community_growth (positive float) – The minimum community-wide growth rate.
min_growth (positive float or array-like object.) – The minimum growth rate for each individual in the community. Either a single value applied to all individuals or one value for each.
exports (boolean) – Whether to include export fluxes in the returned medium. Defaults to False which will only return import fluxes.
exchanges (list of cobra.Reactions) – The list of exchange reactions that are penalized.
minimize_components (boolean) – Whether to minimize the number of components instead of the total import flux. Might be more intuitive if set to True but may also be slow to calculate for large communities.
open_exchanges (boolean or number) – Whether to ignore currently set bounds and make all exchange reactions in the model possible. If set to a number all exchange reactions will be opened with (-number, number) as bounds.
solution (boolean) – Whether to also return the entire solution and all fluxes for the minimal medium.
weights (str) – Will scale the fluxes by a weight factor. Can either be “mass” which will scale by molecular mass, a single element which will scale by the elemental content (for instance “C” to scale by carbon content). If None every metabolite will receive the same weight. Will be ignored if minimize_components is True.
atol (float) – Absolute tolerance for the growth rates. If None will use the solver tolerance.
rtol (float) – Relative tolerqance for the growth rates. If None will use the solver tolerance.
- Returns:
A series {rid: flux} giving the import flux for each required import reaction. If solution is True retuns a dictionary {“medium”: pandas.Series, “solution”: micom.CommunitySolution}. If the medium optimization failed (usually because the specified growth rates are not reachable) it will return None.
- Return type:
pandas.Series, dict or None
- micom.media.complete_medium(model, medium, growth=0.1, min_growth=0.001, max_import=1, minimize_components=False, weights=None, strict=[])[source]¶
Fill in missing components in a growth medium.
Finds the minimal number of additions to make a model form biomass. In order to avoid bias all added reactions will have a maximum import rate of max_import.
Note
This function fixes the growth medium for a single cobra Model. We also provide a function complete_db_medium in micom.workflows that fixes a growth medium for an entire model database.
- Parameters:
model (cobra.Model) – The model to use.
medium (pandas.Series) – A growth medium. Must contain positive floats as elements and exchange reaction ids as index. Note that reactions not present in the model will be removed from the growth medium.
growth (positive float) – The minimum overall growth rate that has to be achieved. For single COBRA model this is just the biomass flux and for community models this is the community biomass flux.
min_growth (positive float or array-like object.) – The minimum growth rate for each individual in the community. Either a single value applied to all individuals or one value for each. Only used if model is a micom.Community model.
minimize_components (boolean) – Whether to minimize the number of components instead of the total import flux. Might be more intuitive if set to True but may also be slow to calculate for large communities.
max_import (positive float) – The import rate applied for the added exchanges.
weights (str) – Will scale the fluxes by a weight factor. Can either be “mass” which will scale by molecular mass, a single element which will scale by the elemental content (for instance “C” to scale by carbon content). If None every metabolite will receive the same weight. Will be ignored if minimize_components is True.
strict (list) – strict : list Whether to match the imports in the predefined medium exactly. For reactions IDs listed here will not allow additional import of the components in the provided medium. For example, if your input medium has a flux of 10 mmol/(gDW*h) defined and the requested growth rate can only be fulfilled by ramping this up that would be allowed in non-strict mode but forbidden in strict mode. To match all medium components to strict mode use strict=medium.index.
- Returns:
A series {rid: flux} giving the import flux for each required import reaction. This will include the initial medium as passed to the function as well as a minimal set of additional changes such that the model produces biomass with a rate >= min_growth.
- Return type:
pandas.Series or dict