Skip to content

Commit

Permalink
Deploying to docs from @ ff0890c 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
willdumm committed Mar 6, 2024
1 parent 81c7ab1 commit fcbd61e
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 146 deletions.
122 changes: 61 additions & 61 deletions _images/gctree.out.inference.abundance_rank.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/newranking.tree_stats.pairplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/rendering-demo_20_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 20 additions & 15 deletions _modules/gctree/branching_processes.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ <h1>Source code for gctree.branching_processes</h1><div class="highlight"><pre>
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Tuple</span><span class="p">,</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Set</span><span class="p">,</span> <span class="n">Callable</span><span class="p">,</span> <span class="n">Mapping</span><span class="p">,</span> <span class="n">Sequence</span><span class="p">,</span> <span class="n">Optional</span>
<span class="kn">from</span> <span class="nn">decimal</span> <span class="kn">import</span> <span class="n">Decimal</span>
<span class="kn">import</span> <span class="nn">math</span>

<span class="n">sequence_resolutions</span> <span class="o">=</span> <span class="n">hdag</span><span class="o">.</span><span class="n">parsimony_utils</span><span class="o">.</span><span class="n">standard_nt_ambiguity_map_gap_as_char</span><span class="o">.</span><span class="n">get_sequence_resolution_func</span><span class="p">(</span>
<span class="s2">&quot;sequence&quot;</span>
Expand Down Expand Up @@ -601,9 +602,11 @@ <h1>Source code for gctree.branching_processes</h1><div class="highlight"><pre>
<span class="n">C</span> <span class="o">=</span> <span class="n">ete3</span><span class="o">.</span><span class="n">CircleFace</span><span class="p">(</span>
<span class="n">radius</span><span class="o">=</span><span class="n">node_size2</span><span class="p">,</span>
<span class="n">color</span><span class="o">=</span><span class="n">circle_color</span><span class="p">,</span>
<span class="n">label</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;text&quot;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">abundance</span><span class="p">),</span> <span class="s2">&quot;color&quot;</span><span class="p">:</span> <span class="n">text_color</span><span class="p">}</span>
<span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">abundance</span> <span class="o">&gt;</span> <span class="mi">0</span>
<span class="k">else</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">label</span><span class="o">=</span><span class="p">(</span>
<span class="p">{</span><span class="s2">&quot;text&quot;</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">abundance</span><span class="p">),</span> <span class="s2">&quot;color&quot;</span><span class="p">:</span> <span class="n">text_color</span><span class="p">}</span>
<span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">abundance</span> <span class="o">&gt;</span> <span class="mi">0</span>
<span class="k">else</span> <span class="kc">None</span>
<span class="p">),</span>
<span class="p">)</span>
<span class="n">C</span><span class="o">.</span><span class="n">rotation</span> <span class="o">=</span> <span class="o">-</span><span class="mi">90</span>
<span class="n">C</span><span class="o">.</span><span class="n">hz_align</span> <span class="o">=</span> <span class="mi">1</span>
Expand Down Expand Up @@ -720,9 +723,11 @@ <h1>Source code for gctree.branching_processes</h1><div class="highlight"><pre>
<span class="n">node</span><span class="o">.</span><span class="n">add_face</span><span class="p">(</span>
<span class="n">T</span><span class="p">,</span>
<span class="mi">0</span><span class="p">,</span>
<span class="n">position</span><span class="o">=</span><span class="s2">&quot;branch-bottom&quot;</span>
<span class="k">if</span> <span class="n">start</span> <span class="o">==</span> <span class="mi">0</span>
<span class="k">else</span> <span class="s2">&quot;branch-top&quot;</span><span class="p">,</span>
<span class="n">position</span><span class="o">=</span><span class="p">(</span>
<span class="s2">&quot;branch-bottom&quot;</span>
<span class="k">if</span> <span class="n">start</span> <span class="o">==</span> <span class="mi">0</span>
<span class="k">else</span> <span class="s2">&quot;branch-top&quot;</span>
<span class="p">),</span>
<span class="p">)</span>
<span class="k">if</span> <span class="s2">&quot;*&quot;</span> <span class="ow">in</span> <span class="n">aa</span><span class="p">:</span>
<span class="n">nstyle</span><span class="p">[</span><span class="s2">&quot;hz_line_color&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;red&quot;</span>
Expand Down Expand Up @@ -1020,9 +1025,9 @@ <h1>Source code for gctree.branching_processes</h1><div class="highlight"><pre>
<span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">tree</span><span class="o">.</span><span class="n">traverse</span><span class="p">(</span><span class="n">strategy</span><span class="o">=</span><span class="s2">&quot;postorder&quot;</span><span class="p">):</span>
<span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">is_leaf</span><span class="p">():</span>
<span class="n">node</span><span class="o">.</span><span class="n">LB_down</span> <span class="o">=</span> <span class="p">{</span>
<span class="n">node</span><span class="p">:</span> <span class="n">node</span><span class="o">.</span><span class="n">abundance</span> <span class="o">*</span> <span class="n">clone_contribution</span>
<span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">abundance</span> <span class="o">&gt;</span> <span class="mi">1</span>
<span class="k">else</span> <span class="mi">0</span>
<span class="n">node</span><span class="p">:</span> <span class="p">(</span>
<span class="n">node</span><span class="o">.</span><span class="n">abundance</span> <span class="o">*</span> <span class="n">clone_contribution</span> <span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">abundance</span> <span class="o">&gt;</span> <span class="mi">1</span> <span class="k">else</span> <span class="mi">0</span>
<span class="p">)</span>
<span class="p">}</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">node</span><span class="o">.</span><span class="n">LB_down</span> <span class="o">=</span> <span class="p">{</span><span class="n">node</span><span class="p">:</span> <span class="n">node</span><span class="o">.</span><span class="n">abundance</span> <span class="o">*</span> <span class="n">clone_contribution</span><span class="p">}</span>
Expand Down Expand Up @@ -1241,9 +1246,11 @@ <h1>Source code for gctree.branching_processes</h1><div class="highlight"><pre>
<span class="p">)</span>
<span class="n">grad_l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">grad_ls</span><span class="p">[</span><span class="n">i_prime</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">+</span> <span class="n">res</span><span class="p">)</span>
<span class="c1"># count_ls shouldn&#39;t have any zeros in it...</span>
<span class="k">return</span> <span class="p">(</span><span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">count_ls</span><span class="o">.</span><span class="n">sum</span><span class="p">())</span> <span class="o">+</span> <span class="n">scs</span><span class="o">.</span><span class="n">logsumexp</span><span class="p">(</span><span class="n">ls</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="n">count_ls</span><span class="p">)),</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="n">grad_l</span>
<span class="p">)</span>
<span class="c1"># using math.log instead of np.log is essential because np.log</span>
<span class="c1"># doesn&#39;t work on large integers &gt; 2**64 :eyeroll:</span>
<span class="k">return</span> <span class="p">(</span>
<span class="o">-</span><span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">count_ls</span><span class="o">.</span><span class="n">sum</span><span class="p">())</span> <span class="o">+</span> <span class="n">scs</span><span class="o">.</span><span class="n">logsumexp</span><span class="p">(</span><span class="n">ls</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="n">count_ls</span><span class="p">)</span>
<span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">grad_l</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="p">(</span><span class="n">ls</span> <span class="o">*</span> <span class="n">count_ls</span><span class="p">)</span><span class="o">.</span><span class="n">sum</span><span class="p">(),</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span>
<span class="p">[(</span><span class="n">grad_ls</span><span class="p">[:,</span> <span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">count_ls</span><span class="p">)</span><span class="o">.</span><span class="n">sum</span><span class="p">(),</span> <span class="p">(</span><span class="n">grad_ls</span><span class="p">[:,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">count_ls</span><span class="p">)</span><span class="o">.</span><span class="n">sum</span><span class="p">()]</span>
Expand Down Expand Up @@ -1933,9 +1940,7 @@ <h1>Source code for gctree.branching_processes</h1><div class="highlight"><pre>
<span class="s2">&quot;original_ids&quot;</span><span class="p">:</span> <span class="p">(</span>
<span class="n">n</span><span class="o">.</span><span class="n">original_ids</span>
<span class="k">if</span> <span class="s2">&quot;original_ids&quot;</span> <span class="ow">in</span> <span class="n">n</span><span class="o">.</span><span class="n">features</span>
<span class="k">else</span> <span class="p">{</span><span class="n">n</span><span class="o">.</span><span class="n">name</span><span class="p">}</span>
<span class="k">if</span> <span class="n">n</span><span class="o">.</span><span class="n">is_leaf</span><span class="p">()</span>
<span class="k">else</span> <span class="nb">set</span><span class="p">()</span>
<span class="k">else</span> <span class="p">{</span><span class="n">n</span><span class="o">.</span><span class="n">name</span><span class="p">}</span> <span class="k">if</span> <span class="n">n</span><span class="o">.</span><span class="n">is_leaf</span><span class="p">()</span> <span class="k">else</span> <span class="nb">set</span><span class="p">()</span>
<span class="p">),</span>
<span class="s2">&quot;isotype&quot;</span><span class="p">:</span> <span class="n">frozendict</span><span class="p">(),</span>
<span class="p">},</span>
Expand Down
10 changes: 5 additions & 5 deletions _modules/gctree/isotyping.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ <h1>Source code for gctree.isotyping</h1><div class="highlight"><pre>
<span class="k">if</span> <span class="n">weight_matrix</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">weight_matrix</span> <span class="o">=</span> <span class="p">[</span>
<span class="p">[</span>
<span class="mf">0.0</span>
<span class="k">if</span> <span class="n">target</span> <span class="o">==</span> <span class="n">origin</span>
<span class="k">else</span> <span class="mf">1.0</span>
<span class="k">if</span> <span class="n">target</span> <span class="o">&gt;</span> <span class="n">origin</span>
<span class="k">else</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span>
<span class="p">(</span>
<span class="mf">0.0</span>
<span class="k">if</span> <span class="n">target</span> <span class="o">==</span> <span class="n">origin</span>
<span class="k">else</span> <span class="mf">1.0</span> <span class="k">if</span> <span class="n">target</span> <span class="o">&gt;</span> <span class="n">origin</span> <span class="k">else</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span>
<span class="p">)</span>
<span class="k">for</span> <span class="n">target</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
<span class="p">]</span>
<span class="k">for</span> <span class="n">origin</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
Expand Down
6 changes: 3 additions & 3 deletions _modules/gctree/mutation_model.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ <h1>Source code for gctree.mutation_model</h1><div class="highlight"><pre>
<span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">trials</span><span class="p">)</span>
<span class="o">+</span> <span class="s2">&quot; consecutive attempts&quot;</span>
<span class="p">)</span>
<span class="n">sequence_list</span><span class="p">[</span>
<span class="n">mut_pos</span>
<span class="p">]</span> <span class="o">=</span> <span class="n">original_base</span> <span class="c1"># &lt;-- we only get here if we are retrying</span>
<span class="n">sequence_list</span><span class="p">[</span><span class="n">mut_pos</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">original_base</span> <span class="c1"># &lt;-- we only get here if we are retrying</span>
<span class="p">)</span>

<span class="k">return</span> <span class="n">sequence</span></div>

Expand Down
1 change: 1 addition & 0 deletions _modules/gctree/utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@

<h1>Source code for gctree.utils</h1><div class="highlight"><pre>
<span></span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;Utility functions.&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">wraps</span><span class="p">,</span> <span class="n">reduce</span>
<span class="kn">import</span> <span class="nn">Bio.Data.IUPACData</span>
<span class="kn">import</span> <span class="nn">operator</span>
Expand Down
Loading

0 comments on commit fcbd61e

Please sign in to comment.