micom.viz.association

Visualization for phenotype prediction.

Attributes

Classes

Visualization

A visualization object.

Functions

production_rates(results)

Calculate the production rates for a set of metabolites.

consumption_rates(results)

Calculate the production rates for a set of metabolites.

plot_association(results, phenotype[, variable_type, ...])

Test for differential metabolite production.

Module Contents

class micom.viz.association.Visualization(filename, data, template)[source]

Bases: object

A visualization object.

filename

The filename of trhe saved visualization.

Type:

str

data

The data used to create the Visualization.

Type:

dict

template

The jinja template used to render the visualization.

Type:

jinja2.Template

view()[source]

Open the visualization in a browser.

Parameters:

None.

Return type:

nothing

save(**kwargs)[source]

Render and and save the visualization.

micom.viz.association.logger[source]
micom.viz.association.production_rates(results)[source]

Calculate the production rates for a set of metabolites.

Note

Production rates are not net fluxes but the flux of a particular metabolite into the external environment independent whether it is taken up by another taxon. The net rates can be obtained directly by inspecting the exchange fluxes in the “medium” compartment. The (transient) production rates reported here are the fluxes other surrounding cells/consumers would have access to. Thus, they are often more interesting for a phenotype than the net rates which are the excess productin rates, even in the absence of another consumer.

Parameters:

results (micom.GrowthResults) – A growth results as returned by grow.

Returns:

A new flux DataFrame containing the intermediate production rates for each metabolite.

Return type:

pandas.DataFrame

micom.viz.association.consumption_rates(results)[source]

Calculate the production rates for a set of metabolites.

Note

Consumption rates are not net fluxes but the total consumption of a particular metabolite by all taxa in the community independent whether it is secreted again. The net rates can be obtained directly by inspecting the exchange fluxes in the “medium” compartment. The (transient) consumption rates reported here is the total flux of a metabolite imported/consumed by taxa in the community.

Parameters:

results (micom.GrowthResults) – A growth results as returned by grow.

Returns:

A new flux DataFrame containing the intermediate production rates for each metabolite.

Return type:

pandas.DataFrame

micom.viz.association.PANDAS_VERSION[source]
micom.viz.association.plot_association(results, phenotype, variable_type='binary', variable_name='phenotype', filename='association_%s.html' % datetime.now().strftime('%Y%m%d'), flux_type='production', fdr_threshold=0.05, threads=1, atol=1e-06)[source]

Test for differential metabolite production.

This will check for associations of the phenotype with metabolite fluxes. Individual tests are performed using non-parametric tests of the overall consumption or production fluxes for each samples versus the phenotype.

To assess the the global association, this will fit L1-regularized linear models with log-fluxes as features. Will use LASSO regression for a continuous response and L1-regularized Logistic regression for a binary response.

Parameters:
  • results (micom.workflows.GrowthResults) – The results returned by the grow workflow.

  • phenotype (pandas.Series) – The data to be fitted. Its index must correspond to sample_id in exchanges.

  • variable_type (str of ["binary", "continuous"]) – The type of the variable.

  • variable_name (str) – A short description of the phenotype for instance “disease status”.

  • filename (str) – The HTML file where the visualization will be saved.

  • flux_type (str of ["import", "production"]) – Whether to fit using import or production fluxes.

  • threads (int) – The number of threads to use.

  • fdr_threshold (float) – The false discovery rate cutoff to use (FDR-corrected p-value cutoff). Defaults to 0.05.

  • atol (float) – Tolerance to consider a flux different from zero. Will default to the solver tolerance.

Returns:

A MICOM visualization. Can be served with viz.view.

Return type:

Visualization