:py:mod:`cobra.flux_analysis.phenotype_phase_plane` =================================================== .. py:module:: cobra.flux_analysis.phenotype_phase_plane .. autoapi-nested-parse:: Provide functions for phenotype phase plane analysis. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: cobra.flux_analysis.phenotype_phase_plane.production_envelope cobra.flux_analysis.phenotype_phase_plane._add_envelope cobra.flux_analysis.phenotype_phase_plane._total_yield cobra.flux_analysis.phenotype_phase_plane._reaction_elements cobra.flux_analysis.phenotype_phase_plane._reaction_weight cobra.flux_analysis.phenotype_phase_plane._total_components_flux cobra.flux_analysis.phenotype_phase_plane._find_carbon_sources .. py:function:: production_envelope(model: cobra.Model, reactions: List[cobra.Reaction], objective: Union[Dict, optlang.interface.Objective, None] = None, carbon_sources: Optional[List[cobra.Reaction]] = None, points: int = 20, threshold: Optional[float] = None) -> pandas.DataFrame Calculate the objective value conditioned on all flux combinations. The production envelope can be used to analyze a model's ability to produce a given compound conditional on the fluxes for another set of reactions, such as the uptake rates. The model is alternately optimized with respect to minimizing and maximizing the objective and the obtained fluxes are recorded. Ranges to compute production is set to the effective bounds, i.e., the minimum / maximum fluxes that can be obtained given current reaction bounds. :param model: The model to compute the production envelope for. :type model: cobra.Model :param reactions: A list of reaction objects. :type reactions: list of cobra.Reaction :param objective: The objective (reaction) to use for the production envelope. Use the model's current objective if left missing (default None). :type objective: dict or cobra.Model.objective, optional :param carbon_sources: One or more reactions that are the source of carbon for computing carbon (mol carbon in output over mol carbon in input) and mass yield (gram product over gram output). Only objectives with a carbon containing input and output metabolite is supported. Will identify active carbon sources in the medium if none are specified (default None). :type carbon_sources: list of cobra.Reaction, optional :param points: The number of points to calculate production for (default 20). :type points: int, optional :param threshold: A cut-off under which flux values will be considered to be zero. If not specified, it defaults to `model.tolerance` (default None). :type threshold: float, optional :returns: A DataFrame with fixed columns as: - carbon_source : identifiers of carbon exchange reactions - flux_maximum : maximum objective flux - flux_minimum : minimum objective flux - carbon_yield_maximum : maximum yield of a carbon source - carbon_yield_minimum : minimum yield of a carbon source - mass_yield_maximum : maximum mass yield of a carbon source - mass_yield_minimum : minimum mass yield of a carbon source and variable columns (for each input `reactions`) as: - reaction_id : flux at each given point :rtype: pandas.DataFrame :raises ValueError: If model's objective is comprised of multiple reactions. .. rubric:: Examples >>> import cobra.io >>> from cobra.flux_analysis import production_envelope >>> model = cobra.io.load_model("textbook") >>> production_envelope(model, ["EX_glc__D_e", "EX_o2_e"]) carbon_source flux_minimum carbon_yield_minimum mass_yield_minimum ... 0 EX_glc__D_e 0.0 0.0 NaN ... 1 EX_glc__D_e 0.0 0.0 NaN ... 2 EX_glc__D_e 0.0 0.0 NaN ... 3 EX_glc__D_e 0.0 0.0 NaN ... 4 EX_glc__D_e 0.0 0.0 NaN ... .. ... ... ... ... ... 395 EX_glc__D_e NaN NaN NaN ... 396 EX_glc__D_e NaN NaN NaN ... 397 EX_glc__D_e NaN NaN NaN ... 398 EX_glc__D_e NaN NaN NaN ... 399 EX_glc__D_e NaN NaN NaN ... [400 rows x 9 columns] .. py:function:: _add_envelope(model: cobra.Model, reactions: List[cobra.Reaction], grid: pandas.DataFrame, c_input: List[cobra.Reaction], c_output: List[cobra.Reaction], threshold: float) -> None Add a production envelope based on the parameters provided. :param model: The model to operate on. :type model: cobra.Model :param reactions: The input reaction objects. :type reactions: list of cobra.Reaction :param grid: The DataFrame containing all the data regarding the operation. :type grid: pandas.DataFrame :param c_input: The list of reaction objects acting as carbon inputs. :type c_input: list of cobra.Reaction :param c_output: The list of reaction objects acting as carbon outputs. :type c_output: list of cobra.Reaction .. py:function:: _total_yield(input_fluxes: List[float], input_elements: List[float], output_flux: List[float], output_elements: List[float]) -> float Compute total output per input unit. Units are typically mol carbon atoms or gram of source and product. :param input_fluxes: A list of input reaction fluxes in the same order as the `input_components`. :type input_fluxes: list of float :param input_elements: A list of reaction components which are in turn list of numbers. :type input_elements: list of float :param output_flux: The output flux value. :type output_flux: float :param output_elements: A list of stoichiometrically weighted output reaction components. :type output_elements: list :returns: The ratio between output (mol carbon atoms or grams of product) and input (mol carbon atoms or grams of source compounds). If input flux of carbon sources is zero then numpy.nan is returned. :rtype: float .. py:function:: _reaction_elements(reaction: cobra.Reaction) -> List[float] Split metabolites into atoms times their stoichiometric coefficients. :param reaction: The reaction whose metabolite components are desired. :type reaction: cobra.Reaction :returns: Each of the reaction's metabolites' desired carbon elements (if any) times that metabolite's stoichiometric coefficient. :rtype: list of float .. py:function:: _reaction_weight(reaction: cobra.Reaction) -> List[float] Return the metabolite weight times its stoichiometric coefficient. :param reaction: The reaction whose metabolite component weights is desired. :type reaction: cobra.Reaction :returns: Each of reaction's metabolite components' weights. :rtype: list of float :raises ValueError: If more than one metabolite comprises the `reaction`. .. py:function:: _total_components_flux(flux: float, components: List[float], consumption: bool = True) -> float Compute the total components consumption or production flux. :param flux: The reaction flux for the components. :type flux: float :param components: List of stoichiometrically weighted components. :type components: list of float :param consumption: Whether to sum up consumption or production fluxes (default True). :type consumption: bool, optional :returns: The total consumption or production flux of `components`. :rtype: float .. py:function:: _find_carbon_sources(model: cobra.Model) -> List[cobra.Reaction] Find all active carbon source reactions. :param model: The model whose active carbon sources need to found. :type model: Model :returns: The medium reactions with carbon input flux. :rtype: list of cobra.Reaction