cobra.flux_analysis.deletion
¶
Provide functions for reaction and gene deletions.
Module Contents¶
Classes¶
Access unique combinations of reactions in deletion results. |
Functions¶
|
Return the growth from the model. |
|
Perform reaction deletion. |
|
Perform reaction deletions on worker process. |
|
Perform gene deletions. |
|
Perform gene deletions on worker process. |
|
Initialize worker process. |
|
Provide a common interface for single or multiple knockouts. |
|
Return the IDs of the entities. |
|
Return the elements. |
|
Knock out each reaction from reaction_list. |
|
Knock out each gene from gene_list. |
|
Knock out each reaction pair from the combinations of two given lists. |
|
Knock out each gene pair from the combination of two given lists. |
Attributes¶
- cobra.flux_analysis.deletion._get_growth(model: cobra.core.Model) Tuple[float, str] [source]¶
Return the growth from the model.
- Parameters
model (cobra.Model) – The model to obtain growth for.
- Returns
The obtained growth value. Returns nan if there is some error while optimizing.
- Return type
- cobra.flux_analysis.deletion._reaction_deletion(model: cobra.core.Model, reaction_ids: List[str]) Tuple[List[str], float, str] [source]¶
Perform reaction deletion.
- cobra.flux_analysis.deletion._reaction_deletion_worker(ids: List[str]) Tuple[List[str], float, str] [source]¶
Perform reaction deletions on worker process.
- cobra.flux_analysis.deletion._gene_deletion(model: cobra.core.Model, gene_ids: List[str]) Tuple[List[str], float, str] [source]¶
Perform gene deletions.
- cobra.flux_analysis.deletion._gene_deletion_worker(ids: List[str]) Tuple[List[str], float, str] [source]¶
Perform gene deletions on worker process.
- cobra.flux_analysis.deletion._init_worker(model: cobra.core.Model) None [source]¶
Initialize worker process.
- cobra.flux_analysis.deletion._multi_deletion(model: cobra.core.Model, entity: str, element_lists: List[Union[cobra.core.Gene, cobra.core.Reaction]], method: str = 'fba', solution: Optional[cobra.Solution] = None, processes: Optional[int] = None, **kwargs) pandas.DataFrame [source]¶
Provide a common interface for single or multiple knockouts.
- Parameters
model (cobra.Model) – The metabolic model to perform deletions in.
entity ({"gene", "reaction"}) – The entity to knockout.
element_lists (list of cobra.Gene or cobra.Reaction) – List of cobra.Gene or cobra.Reaction to be deleted.
method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate (default “fba”).
solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM (default None).
processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to configuration.processes (default None).
**kwargs – Passed on to underlying simulation functions.
- Returns
A representation of all combinations of entity deletions. The columns are ‘growth’ and ‘status’, where
- indextuple(str)
The gene or reaction identifiers that were knocked out.
- growthfloat
The growth rate of the adjusted model.
- statusstr
The solution’s status.
- Return type
pandas.DataFrame
- cobra.flux_analysis.deletion._entities_ids(entities: List[Union[str, cobra.core.Gene, cobra.core.Reaction]]) List[str] [source]¶
Return the IDs of the entities.
- Parameters
entities (list of str or cobra.Gene or cobra.Reaction) – The list of entities whose IDs need to be returned.
- Returns
The IDs of the entities.
- Return type
- cobra.flux_analysis.deletion._element_lists(entities: List[Union[str, cobra.core.Gene, cobra.core.Reaction]], *ids: List[str]) List[str] [source]¶
Return the elements.
- Parameters
entities (list of str or cobra.Gene or cobra.Reaction) – The list of entities.
- Returns
The list of IDs.
- Return type
- cobra.flux_analysis.deletion.single_reaction_deletion(model: cobra.core.Model, reaction_list: Optional[List[Union[cobra.core.Reaction, str]]] = None, method: str = 'fba', solution: Optional[cobra.Solution] = None, processes: Optional[int] = None, **kwargs) pandas.DataFrame [source]¶
Knock out each reaction from reaction_list.
- Parameters
model (cobra.Model) – The metabolic model to perform deletions in.
reaction_list (list of cobra.Reaction or str, optional) – The reactions be knocked out. If not passed, all the reactions from the model are used (default None).
method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate (default “fba”).
solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM (default None).
processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to configuration.processes (default None).
**kwargs – Keyword arguments are passed on to underlying simulation functions such as add_room.
- Returns
A representation of all single reaction deletions. The columns are ‘growth’ and ‘status’, where
- indextuple(str)
The reaction identifier that was knocked out.
- growthfloat
The growth rate of the adjusted model.
- statusstr
The solution’s status.
- Return type
pandas.DataFrame
- cobra.flux_analysis.deletion.single_gene_deletion(model: cobra.core.Model, gene_list: Optional[List[Union[cobra.core.Gene, str]]] = None, method: str = 'fba', solution: Optional[cobra.Solution] = None, processes: Optional[int] = None, **kwargs) pandas.DataFrame [source]¶
Knock out each gene from gene_list.
- Parameters
model (cobra.Model) – The metabolic model to perform deletions in.
gene_list (list of cobra.Gene or str, optional) – The gene objects to be deleted. If not passed, all the genes from the model are used (default None).
method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate (default “fba”).
solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM (default None).
processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to configuration.processes (default None).
**kwargs – Keyword arguments are passed on to underlying simulation functions such as add_room.
- Returns
A representation of all single gene deletions. The columns are ‘growth’ and ‘status’, where
- indextuple(str)
The gene identifier that was knocked out.
- growthfloat
The growth rate of the adjusted model.
- statusstr
The solution’s status.
- Return type
pandas.DataFrame
- cobra.flux_analysis.deletion.double_reaction_deletion(model: cobra.core.Model, reaction_list1: Optional[List[Union[cobra.core.Reaction, str]]] = None, reaction_list2: Optional[List[Union[cobra.core.Reaction, str]]] = None, method: str = 'fba', solution: Optional[cobra.Solution] = None, processes: Optional[int] = None, **kwargs) pandas.DataFrame [source]¶
Knock out each reaction pair from the combinations of two given lists.
We say ‘pair’ here but the order order does not matter.
- Parameters
model (cobra.Model) – The metabolic model to perform deletions in.
reaction_list1 (list of cobra.Reaction or str, optional) – The first reaction list to be deleted. If not passed, all the reactions from the model are used (default None).
reaction_list2 (list of cobra.Reaction or str, optional) – The second reaction list to be deleted. If not passed, all the reactions from the model are used (default None).
method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate (default “fba”).
solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM (default None).
processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to configuration.processes (default None).
**kwargs – Keyword arguments are passed on to underlying simulation functions such as add_room.
- Returns
A representation of all combinations of reaction deletions. The columns are ‘growth’ and ‘status’, where
- indextuple(str)
The reaction identifiers that were knocked out.
- growthfloat
The growth rate of the adjusted model.
- statusstr
The solution’s status.
- Return type
pandas.DataFrame
- cobra.flux_analysis.deletion.double_gene_deletion(model: cobra.core.Model, gene_list1: Optional[List[Union[cobra.core.Gene, str]]] = None, gene_list2: Optional[List[Union[cobra.core.Gene, str]]] = None, method: str = 'fba', solution: Optional[cobra.Solution] = None, processes: Optional[int] = None, **kwargs) pandas.DataFrame [source]¶
Knock out each gene pair from the combination of two given lists.
We say ‘pair’ here but the order order does not matter.
- Parameters
model (cobra.Model) – The metabolic model to perform deletions in.
gene_list1 (list of cobra.Gene or str, optional) – The first gene list to be deleted. If not passed, all the genes from the model are used (default None).
gene_list2 (list of cobra.Gene or str, optional) – The second gene list to be deleted. If not passed, all the genes from the model are used (default None).
method ({"fba", "moma", "linear moma", "room", "linear room"}, optional) – Method used to predict the growth rate (default None).
solution (cobra.Solution, optional) – A previous solution to use as a reference for (linear) MOMA or ROOM (default None).
processes (int, optional) – The number of parallel processes to run. Can speed up the computations if the number of knockouts to perform is large. If not passed, will be set to configuration.processes (default None).
**kwargs – Keyword arguments are passed on to underlying simulation functions such as add_room.
- Returns
A representation of all combinations of gene deletions. The columns are ‘growth’ and ‘status’, where
- indextuple(str)
The gene identifiers that were knocked out.
- growthfloat
The growth rate of the adjusted model.
- statusstr
The solution’s status.
- Return type
pandas.DataFrame
- class cobra.flux_analysis.deletion.KnockoutAccessor(pandas_obj: Union[pandas.DataFrame, pandas.Series])[source]¶
Access unique combinations of reactions in deletion results.
This allows acces in the form of results.knockout[rxn1] or results.knockout[“rxn1_id”]. Each individual entry will return a deletion so results.knockout[rxn1, rxn2] will return two deletions (for individual knockouts of rxn1 and rxn2 respectively). Multi-deletions can be accessed by passing in sets like results.knockout[{rxn1, rxn2}] which denotes the double deletion of both reactions. Thus, the following are allowed index elements:
single reactions or genes (depending on whether it is a gene or reaction deletion)
single reaction IDs or gene IDs
lists of single single reaction IDs or gene IDs (will return one row for each element in the list)
sets of reactions or genes (for multi-deletions)
sets of reactions IDs or gene IDs
list of sets of objects or IDs (to get several multi-deletions)
Parameters:¶
- pandas_objpandas.DataFrame or pandas.Series
A result from one of the deletion methods.
- static _validate(obj: pandas.DataFrame) None [source]¶
Validate the object given.
- Parameters
obj (pandas.DataFrame) – The object to validate.
- Raises
AttributeError – If the object supplied is not a DataFrame.
- __getitem__(args: Union[cobra.core.Gene, List[cobra.core.Gene], Set[cobra.core.Gene], List[Set[cobra.core.Gene]], cobra.core.Reaction, List[cobra.core.Reaction], Set[cobra.core.Reaction], List[Set[cobra.core.Reaction]], str, List[str], Set[str], List[Set[str]]]) pandas.DataFrame [source]¶
Return the deletion result for a particular set of knocked entities.
- Parameters
args (cobra.Reaction, cobra.Gene, str, set, or list) – The deletions to be returned. Accepts: - single reactions or genes - single reaction IDs or gene IDs - lists of single single reaction IDs or gene IDs - sets of reactions or genes - sets of reactions IDs or gene IDs - list of sets of objects or IDs See the docs for usage examples.
- Returns
The deletion result where the chosen entities have been deleted. Each row denotes a deletion.
- Return type
pandas.DataFrame
- Raises
ValueError – If any other object is used as index for lookup.