micom.viz#

Init file for MICOM Visualization.

Submodules#

Package Contents#

Classes#

Visualization

A visualization object.

Functions#

plot_exchanges_per_sample(.strftime[, direction, cluster])

Plot the per sample exchange fluxes.

plot_exchanges_per_taxon(.strftime[, direction, ...])

Plot the exchange fluxes per taxon.

plot_growth(results[, filename, tolerance])

Plot the taxa growth rates.

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

Test for differential metabolite production.

class micom.viz.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()#

Open the visualization in a browser.

Parameters:

None.

Return type:

nothing

save(**kwargs)#

Render and and save the visualization.

micom.viz.plot_exchanges_per_sample(results, filename='sample_exchanges_%s.html' % datetime.now().strftime('%Y%m%d'), direction='import', cluster=True) None[source]#

Plot the per sample exchange fluxes.

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

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

  • direction (str either "import" or "export") – The direction of fluxes to plot.

  • cluster (bool) – Whether to reorder samples so that samples with similar exchange fluxes are close to another.

Returns:

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

Return type:

Visualization

micom.viz.plot_exchanges_per_taxon(results, filename='taxon_exchanges_%s.html' % datetime.now().strftime('%Y%m%d'), direction='import', use_total_flux=False, **tsne_args) None[source]#

Plot the exchange fluxes per taxon.

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

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

  • direction (str either "import" or "export") – The direction of fluxes to plot.

  • use_total_fluxes (bool) – Whether to use fluxes normalized to 1gDW of bacteria or the total flux.

  • tsne_args (dict) – Additional arguments passed to TSNE.

Returns:

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

Return type:

Visualization

micom.viz.plot_growth(results, filename='growth_rates_%s.html' % datetime.now().strftime('%Y%m%d'), tolerance=1e-06)[source]#

Plot the taxa growth rates.

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

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

  • tolerance (float) – Smallest growth rate that will be considered. Everything lower will be considered not growing.

Returns:

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

Return type:

Visualization

micom.viz.plot_fit(results, phenotype, variable_type='binary', variable_name='phenotype', filename='fit_%s.html' % datetime.now().strftime('%Y%m%d'), flux_type='production', min_coef=0.001, atol=1e-06)[source]#

Test for differential metabolite production.

This will fit the phenotype response using 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.

  • min_coef (float in [0.0, Inf]) – Only report coefficient that are at least that large.

  • atol (float) – Tolerance to consider a flux different from zero. Should be roughly equivalent to the solver tolerance.

Returns:

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

Return type:

Visualization