Skip to content

Commit

Permalink
deploy: 56633a9
Browse files Browse the repository at this point in the history
  • Loading branch information
cdiener committed Aug 19, 2024
1 parent d9b2a99 commit 3ec91e5
Show file tree
Hide file tree
Showing 24 changed files with 246 additions and 269 deletions.
333 changes: 169 additions & 164 deletions NEWS.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _modules/micom/viz/association.html
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ <h1>Source code for micom.viz.association</h1><div class="highlight"><pre>


<div class="viewcode-block" id="plot_association">
<a class="viewcode-back" href="../../../autoapi/micom/viz/index.html#micom.viz.association.plot_association">[docs]</a>
<a class="viewcode-back" href="../../../autoapi/micom/viz/association/index.html#micom.viz.association.plot_association">[docs]</a>
<span class="k">def</span> <span class="nf">plot_association</span><span class="p">(</span>
<span class="n">results</span><span class="p">,</span>
<span class="n">phenotype</span><span class="p">,</span>
Expand Down
2 changes: 1 addition & 1 deletion _modules/micom/viz/growth.html
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ <h1>Source code for micom.viz.growth</h1><div class="highlight"><pre>


<div class="viewcode-block" id="plot_growth">
<a class="viewcode-back" href="../../../autoapi/micom/viz/growth/index.html#micom.viz.growth.plot_growth">[docs]</a>
<a class="viewcode-back" href="../../../autoapi/micom/viz/index.html#micom.viz.growth.plot_growth">[docs]</a>
<span class="k">def</span> <span class="nf">plot_growth</span><span class="p">(</span>
<span class="n">results</span><span class="p">,</span>
<span class="n">filename</span><span class="o">=</span><span class="s2">&quot;growth_rates_</span><span class="si">%s</span><span class="s2">.html&quot;</span> <span class="o">%</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y%m</span><span class="si">%d</span><span class="s2">&quot;</span><span class="p">),</span>
Expand Down
8 changes: 4 additions & 4 deletions _modules/micom/workflows/db_media.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ <h1>Source code for micom.workflows.db_media</h1><div class="highlight"><pre>
<a class="viewcode-back" href="../../../autoapi/micom/workflows/db_media/index.html#micom.workflows.db_media._grow">[docs]</a>
<span class="k">def</span> <span class="nf">_grow</span><span class="p">(</span><span class="n">args</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Get the maximum growth rate under a given medium.&quot;&quot;&quot;</span>
<span class="n">file</span><span class="p">,</span> <span class="n">med</span> <span class="o">=</span> <span class="n">args</span>
<span class="n">mid</span><span class="p">,</span> <span class="n">file</span><span class="p">,</span> <span class="n">med</span> <span class="o">=</span> <span class="n">args</span>
<span class="n">mod</span> <span class="o">=</span> <span class="n">load_model</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
<span class="n">good</span> <span class="o">=</span> <span class="n">med</span><span class="p">[</span><span class="n">med</span><span class="o">.</span><span class="n">index</span><span class="o">.</span><span class="n">isin</span><span class="p">([</span><span class="n">r</span><span class="o">.</span><span class="n">id</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">mod</span><span class="o">.</span><span class="n">exchanges</span><span class="p">])]</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">good</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
Expand All @@ -334,7 +334,7 @@ <h1>Source code for micom.workflows.db_media</h1><div class="highlight"><pre>
<span class="p">)</span>
<span class="n">mod</span><span class="o">.</span><span class="n">medium</span> <span class="o">=</span> <span class="n">med</span><span class="p">[</span><span class="n">med</span><span class="o">.</span><span class="n">index</span><span class="o">.</span><span class="n">isin</span><span class="p">([</span><span class="n">r</span><span class="o">.</span><span class="n">id</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">mod</span><span class="o">.</span><span class="n">exchanges</span><span class="p">])]</span>
<span class="n">rate</span> <span class="o">=</span> <span class="n">mod</span><span class="o">.</span><span class="n">slim_optimize</span><span class="p">()</span>
<span class="k">return</span> <span class="n">rate</span></div>
<span class="k">return</span> <span class="p">{</span><span class="s2">&quot;id&quot;</span><span class="p">:</span> <span class="n">mid</span><span class="p">,</span> <span class="s2">&quot;growth_rate&quot;</span><span class="p">:</span> <span class="n">rate</span><span class="p">}</span></div>



Expand Down Expand Up @@ -427,9 +427,9 @@ <h1>Source code for micom.workflows.db_media</h1><div class="highlight"><pre>
<span class="o">%</span> <span class="p">(</span><span class="n">manifest</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">rank</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">medium</span><span class="p">))</span>
<span class="p">)</span>

<span class="n">args</span> <span class="o">=</span> <span class="p">[(</span><span class="n">f</span><span class="p">,</span> <span class="n">medium</span><span class="o">.</span><span class="n">flux</span><span class="p">)</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">manifest</span><span class="o">.</span><span class="n">file</span><span class="p">]</span>
<span class="n">args</span> <span class="o">=</span> <span class="p">[(</span><span class="n">r</span><span class="p">[</span><span class="s2">&quot;id&quot;</span><span class="p">],</span> <span class="n">r</span><span class="p">[</span><span class="s2">&quot;file&quot;</span><span class="p">],</span> <span class="n">medium</span><span class="o">.</span><span class="n">flux</span><span class="p">)</span> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">manifest</span><span class="o">.</span><span class="n">iterrows</span><span class="p">()]</span>
<span class="n">results</span> <span class="o">=</span> <span class="n">workflow</span><span class="p">(</span><span class="n">_grow</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">threads</span><span class="p">)</span>
<span class="n">manifest</span><span class="p">[</span><span class="s2">&quot;growth_rate&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">results</span>
<span class="n">results</span> <span class="o">=</span> <span class="n">manifest</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="o">.</span><span class="n">from_records</span><span class="p">(</span><span class="n">results</span><span class="p">),</span> <span class="n">on</span><span class="o">=</span><span class="s2">&quot;id&quot;</span><span class="p">)</span>
<span class="n">manifest</span><span class="p">[</span><span class="s2">&quot;can_grow&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">manifest</span><span class="o">.</span><span class="n">growth_rate</span><span class="o">.</span><span class="n">notna</span><span class="p">()</span> <span class="o">&amp;</span> <span class="p">(</span><span class="n">manifest</span><span class="o">.</span><span class="n">growth_rate</span> <span class="o">&gt;</span> <span class="mf">1e-6</span><span class="p">)</span>

<span class="k">if</span> <span class="n">compressed</span><span class="p">:</span>
Expand Down
4 changes: 4 additions & 0 deletions _sources/NEWS.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This includes a list of major changes for each minor version starting from 0.19.
For information on how to use `micom` please refer to
[the documentation](https://micom-dev.github.io/micom).

### 0.36.4

Fix a bug in `check_db_medium` where the growth rate order was random.

### 0.36.3

Require a newer optlang version to stay compatible with numpy 2.0.
Expand Down
56 changes: 17 additions & 39 deletions _sources/autoapi/micom/viz/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Functions

micom.viz.plot_exchanges_per_sample
micom.viz.plot_exchanges_per_taxon
micom.viz.plot_growth
micom.viz.plot_focal_interactions
micom.viz.plot_mes
micom.viz.plot_association
micom.viz.plot_tradeoff


Expand Down Expand Up @@ -135,6 +135,22 @@ Package Contents
:rtype: Visualization


.. py:function:: plot_growth(results, filename='growth_rates_%s.html' % datetime.now().strftime('%Y%m%d'), tolerance=1e-06)
Plot the taxa growth rates.

:param results: The results returned by the `grow` workflow.
:type results: micom.workflows.GrowthResults
:param filename: The HTML file where the visualization will be saved.
:type filename: str
:param tolerance: Smallest growth rate that will be considered. Everything lower will be
considered not growing.
:type tolerance: float

:returns: A MICOM visualization. Can be served with `viz.serve`.
:rtype: Visualization


.. py:function:: plot_focal_interactions(results: micom.workflows.GrowthResults, taxon: str, filename: str = 'focal_interactions_%s.html' % datetime.now().strftime('%Y%m%d'), kind: str = 'mass') -> None
Plot metabolic interactions between a focal taxa and all other taxa.
Expand Down Expand Up @@ -200,44 +216,6 @@ Package Contents



.. py:function:: 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)
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.

:param results: The results returned by the `grow` workflow.
:type results: micom.workflows.GrowthResults
:param phenotype: The data to be fitted. Its index must correspond to `sample_id` in
`exchanges`.
:type phenotype: pandas.Series
:param variable_type: The type of the variable.
:type variable_type: str of ["binary", "continuous"]
:param variable_name: A short description of the phenotype for instance "disease status".
:type variable_name: str
:param filename: The HTML file where the visualization will be saved.
:type filename: str
:param flux_type: Whether to fit using import or production fluxes.
:type flux_type: str of ["import", "production"]
:param threads: The number of threads to use.
:type threads: int
:param fdr_threshold: The false discovery rate cutoff to use (FDR-corrected p-value cutoff). Defaults
to 0.05.
:type fdr_threshold: float
:param atol: Tolerance to consider a flux different from zero. Will default
to the solver tolerance.
:type atol: float

:returns: A MICOM visualization. Can be served with `viz.view`.
:rtype: Visualization


.. py:function:: plot_tradeoff(tradeoff_rates, filename='tradeoff_%s.html' % datetime.now().strftime('%Y%m%d'), tolerance=1e-06)
Plot diagnostics for varying tradeoff values.
Expand Down
Loading

0 comments on commit 3ec91e5

Please sign in to comment.