micom.elasticity

Calculate elasticity coefficients.

Functions to calculate elasticity coefficients for various community quantities.

Module Contents

Functions

_get_fluxes(sol, reactions)

Get the primal values for a set of variables.

_derivatives(before, after)

Get the elasticities for fluxes.

elasticities_by_medium(com, reactions, fraction, growth_rate, progress)

Get the elasticity coefficients for a set of variables.

elasticities_by_abundance(com, reactions, fraction, growth_rate, progress)

Get the elasticity coefficients for a set of variables.

elasticities(com, fraction=0.5, reactions=None, progress=True)

Calculate elasticities for reactions.

Attributes

STEP

micom.elasticity.STEP = 0.1[source]
micom.elasticity._get_fluxes(sol, reactions)[source]

Get the primal values for a set of variables.

micom.elasticity._derivatives(before, after)[source]

Get the elasticities for fluxes.

micom.elasticity.elasticities_by_medium(com, reactions, fraction, growth_rate, progress)[source]

Get the elasticity coefficients for a set of variables.

Parameters
  • com (micom.Community) – The community for wrhich to calculate elasticities.

  • variables (list of optlang.Variable) – The variables for which to calculate the elasticities. All of these must have non-zero primal vaues in the previous solution.

Returns

The long/tidy version of the elasticities. Contains columns variable, effector, and elasticity.

Return type

pandas.Dataframe

micom.elasticity.elasticities_by_abundance(com, reactions, fraction, growth_rate, progress)[source]

Get the elasticity coefficients for a set of variables.

Parameters
  • com (micom.Community) – The community for which to calculate elasticities.

  • variables (list of optlang.Variable) – The variables for which to calculate the elasticities. All of these must have non-zero primal vaues in the previous solution.

Returns

The long/tidy version of the elasticities. Contains columns variable, effector, and elasticity.

Return type

pandas.Dataframe

micom.elasticity.elasticities(com, fraction=0.5, reactions=None, progress=True)[source]

Calculate elasticities for reactions.

Calculates elasticity coefficients using the specified reactions as response and exchange bounds (diet) and taxa abundances as effectors/parameters. Will use an arbitrary flux distribution as base.

Parameters
  • com (micom.Community) – The community for wrhich to calculate elasticities.

  • fraction (double) – The tradeoff to use for the cooperative tradeoff method. Fraction of maximal community growth to enforce.

  • reactions (iterable) – A list of reactions to get elasticities for. Elements can either be reactions from the model, strings specifying the ids of reactions or ints specifying the indices of reactions. Defaults to using all reactions.

  • progress (boolean) – Whether to shwo progress bars. Will show two, one for the diet optimizations and another one for the taxa abundances.

Returns

A data frame with the following columns: “reaction” - the exchange reaction (response), “taxon” - the taxon the reaction is from, “effector” - the parameter that was changed, “direction” - whether the flux runs in the forward or reverse

direction,

”elasticity” - the elasticity coefficient, “type” - the type of effector either “exchange” for diet or “abundance” for taxa abundances.

Return type

pandas.DataFrame