Skip to content

Commit cee4c18

Browse files
committed
1 parent 85941e5 commit cee4c18

File tree

3 files changed

+61
-47
lines changed

3 files changed

+61
-47
lines changed

docs/dev/generated/skbio.tree.nj.html

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -666,29 +666,42 @@
666666
<h1>skbio.tree.nj<a class="headerlink" href="#skbio-tree-nj" title="Link to this heading">#</a></h1>
667667
<dl class="py function">
668668
<dt class="sig sig-object py" id="skbio.tree.nj">
669-
<span class="sig-prename descclassname"><span class="pre">skbio.tree.</span></span><span class="sig-name descname"><span class="pre">nj</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dm</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">disallow_negative_branch_length</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">result_constructor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-bio/scikit-bio/blob/main/skbio/tree/_nj.py#L17"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#skbio.tree.nj" title="Link to this definition">#</a></dt>
669+
<span class="sig-prename descclassname"><span class="pre">skbio.tree.</span></span><span class="sig-name descname"><span class="pre">nj</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dm</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clip_to_zero</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">result_constructor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">disallow_negative_branch_length</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-bio/scikit-bio/blob/main/skbio/tree/_nj.py#L16"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#skbio.tree.nj" title="Link to this definition">#</a></dt>
670670
<dd><p>Perform neighbor joining (NJ) for phylogenetic reconstruction.</p>
671-
<dl class="field-list simple">
671+
<dl class="field-list">
672672
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
673-
<dd class="field-odd"><dl class="simple">
674-
<dt><strong>dm</strong><span class="classifier">skbio.DistanceMatrix</span></dt><dd><p>Input distance matrix containing distances between taxa.</p>
673+
<dd class="field-odd"><dl>
674+
<dt><strong>dm</strong><span class="classifier">skbio.DistanceMatrix</span></dt><dd><p>Input distance matrix containing pairwise distances among taxa.</p>
675675
</dd>
676-
<dt><strong>disallow_negative_branch_length</strong><span class="classifier">bool, optional</span></dt><dd><p>Neighbor joining can result in negative branch lengths, which don’t
677-
make sense in an evolutionary context. If <cite>True</cite>, negative branch
678-
lengths will be returned as zero, a common strategy for handling this
679-
issue that was proposed by the original developers of the algorithm.</p>
676+
<dt><strong>clip_to_zero</strong><span class="classifier">bool, optional</span></dt><dd><p>If True (default), convert negative branch lengths into zeros.</p>
677+
<div class="versionadded">
678+
<p><span class="versionmodified added">Added in version 0.6.3.</span></p>
679+
</div>
680680
</dd>
681681
<dt><strong>result_constructor</strong><span class="classifier">function, optional</span></dt><dd><p>Function to apply to construct the result object. This must take a
682-
newick-formatted string as input. The result of applying this function
683-
to a newick-formatted string will be returned from this function. This
684-
defaults to <code class="docutils literal notranslate"><span class="pre">lambda</span> <span class="pre">x:</span> <span class="pre">TreeNode.read(StringIO(x),</span> <span class="pre">format='newick')</span></code>.</p>
682+
newick-formatted string as input. Deprecated and to be removed in a
683+
future release.</p>
684+
<div class="deprecated">
685+
<p><span class="versionmodified deprecated">Deprecated since version 0.6.3.</span></p>
686+
</div>
687+
</dd>
688+
<dt><strong>disallow_negative_branch_length</strong><span class="classifier">bool, optional</span></dt><dd><p>Alias of <code class="docutils literal notranslate"><span class="pre">clip_to_zero</span></code> for backward compatibility. Deprecated and to be
689+
removed in a future release.</p>
690+
<div class="deprecated">
691+
<p><span class="versionmodified deprecated">Deprecated since version 0.6.3.</span></p>
692+
</div>
685693
</dd>
686694
</dl>
687695
</dd>
688696
<dt class="field-even">Returns<span class="colon">:</span></dt>
689-
<dd class="field-even"><dl class="simple">
690-
<dt>TreeNode</dt><dd><p>By default, the result object is a <cite>TreeNode</cite>, though this can be
691-
overridden by passing <cite>result_constructor</cite>.</p>
697+
<dd class="field-even"><dl>
698+
<dt>TreeNode</dt><dd><p>Reconstructed phylogenetic tree.</p>
699+
<div class="versionchanged">
700+
<p><span class="versionmodified changed">Changed in version 0.6.3: </span>The NJ algorithm has been optimized. The output may be slightly different
701+
from the previous one in root placement, node ordering, and the numeric
702+
precision of branch lengths. However, the overall tree topology and branch
703+
lengths should remain the same.</p>
704+
</div>
692705
</dd>
693706
</dl>
694707
</dd>
@@ -702,13 +715,26 @@ <h1>skbio.tree.nj<a class="headerlink" href="#skbio-tree-nj" title="Link to this
702715
</dl>
703716
</div>
704717
<p class="rubric">Notes</p>
705-
<p>Neighbor joining was initially described in Saitou and Nei (1987) <a class="reference internal" href="#r7def033fcc8e-1" id="id1">[1]</a>. The
706-
example presented here is derived from the Wikipedia page on neighbor
707-
joining <a class="reference internal" href="#r7def033fcc8e-2" id="id2">[2]</a>. Gascuel and Steel (2006) provide a detailed overview of
708-
Neighbor joining in terms of its biological relevance and limitations <a class="reference internal" href="#r7def033fcc8e-3" id="id3">[3]</a>.</p>
709-
<p>Neighbor joining, by definition, creates unrooted trees. One strategy for
710-
rooting the resulting trees is midpoint rooting, which is accessible as
711-
<code class="docutils literal notranslate"><span class="pre">TreeNode.root_at_midpoint</span></code>.</p>
718+
<p>Neighbor joining (NJ) was initially described by Saitou and Nei (1987) <a class="reference internal" href="#r7def033fcc8e-1" id="id1">[1]</a>. It is
719+
a simple and efficient agglomerative clustering method that builds a phylogenetic
720+
tree based on a distance matrix. Gascuel and Steel (2006) provide a detailed
721+
overview of neighbor joining in terms of its biological relevance and limitations
722+
<a class="reference internal" href="#r7def033fcc8e-2" id="id2">[2]</a>.</p>
723+
<p>Neighbor joining, by definition, creates unrooted trees with varying tip heights,
724+
which contrasts UPGMA (<a class="reference internal" href="skbio.tree.upgma.html#skbio.tree.upgma" title="skbio.tree.upgma"><code class="xref py py-func docutils literal notranslate"><span class="pre">upgma()</span></code></a>). One strategy for rooting the resulting tree
725+
is midpoint rooting, which is accessible as <a class="reference internal" href="skbio.tree.TreeNode.root_at_midpoint.html#skbio.tree.TreeNode.root_at_midpoint" title="skbio.tree.TreeNode.root_at_midpoint"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TreeNode.root_at_midpoint()</span></code></a>.</p>
726+
<p>Note that the tree constructed using neighbor joining is not rooted at a tip,
727+
unlike minimum evolution (<a class="reference internal" href="skbio.tree.bme.html#skbio.tree.bme" title="skbio.tree.bme"><code class="xref py py-func docutils literal notranslate"><span class="pre">bme()</span></code></a>), so re-rooting is required before tree
728+
re-arrangement operations such as nearest neighbor interchange (NNI) (<a class="reference internal" href="skbio.tree.nni.html#skbio.tree.nni" title="skbio.tree.nni"><code class="xref py py-func docutils literal notranslate"><span class="pre">nni()</span></code></a>)
729+
can be performed.</p>
730+
<p>Neighbor joining is most accurate when distances are additive – the distance
731+
between two taxa in the matrix equals to the sum of branch lengths connecting them
732+
in the tree. When this assumption is violated, which is common in real-world data,
733+
negative branch lengths may be produced, which cause challenges in interpretation
734+
and subsequent analyses. This function converts negative branch lengths into zeros
735+
by default, but this behavior can be disabled by setting <code class="docutils literal notranslate"><span class="pre">clip_to_zero</span></code> to False.</p>
736+
<p>The example presented here is derived from the Wikipedia page on neighbor joining
737+
<a class="reference internal" href="#r7def033fcc8e-3" id="id3">[3]</a>.</p>
712738
<p class="rubric">References</p>
713739
<div role="list" class="citation-list">
714740
<div class="citation" id="r7def033fcc8e-1" role="doc-biblioentry">
@@ -719,13 +745,13 @@ <h1>skbio.tree.nj<a class="headerlink" href="#skbio-tree-nj" title="Link to this
719745
</div>
720746
<div class="citation" id="r7def033fcc8e-2" role="doc-biblioentry">
721747
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id2">2</a><span class="fn-bracket">]</span></span>
722-
<p><a class="reference external" href="http://en.wikipedia.org/wiki/Neighbour_joining">http://en.wikipedia.org/wiki/Neighbour_joining</a></p>
748+
<p>Gascuel O, and Steel M. (2006) “Neighbor-Joining Revealed” Molecular
749+
Biology and Evolution, Volume 23, Issue 11, November 2006,
750+
Pages 1997-2000, <a class="reference external" href="https://doi.org/10.1093/molbev/msl072">https://doi.org/10.1093/molbev/msl072</a></p>
723751
</div>
724752
<div class="citation" id="r7def033fcc8e-3" role="doc-biblioentry">
725753
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id3">3</a><span class="fn-bracket">]</span></span>
726-
<p>Gascuel O, and Steel M. (2006) “Neighbor-Joining Revealed” Molecular
727-
Biology and Evolution, Volume 23, Issue 11, November 2006,
728-
Pages 1997–2000, <a class="reference external" href="https://doi.org/10.1093/molbev/msl072">https://doi.org/10.1093/molbev/msl072</a></p>
754+
<p><a class="reference external" href="http://en.wikipedia.org/wiki/Neighbour_joining">http://en.wikipedia.org/wiki/Neighbour_joining</a></p>
729755
</div>
730756
</div>
731757
<p class="rubric">Examples</p>
@@ -748,29 +774,17 @@ <h1>skbio.tree.nj<a class="headerlink" href="#skbio-tree-nj" title="Link to this
748774
those taxa. This is returned as a TreeNode object.</p>
749775
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">tree</span> <span class="o">=</span> <span class="n">nj</span><span class="p">(</span><span class="n">dm</span><span class="p">)</span>
750776
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">tree</span><span class="o">.</span><span class="n">ascii_art</span><span class="p">())</span>
751-
<span class="go"> /-d</span>
777+
<span class="go"> /-a</span>
778+
<span class="go"> /--------|</span>
779+
<span class="go"> /--------| \-b</span>
780+
<span class="go"> | |</span>
781+
<span class="go"> | \-c</span>
782+
<span class="go">---------|</span>
783+
<span class="go"> |--e</span>
752784
<span class="go"> |</span>
753-
<span class="go"> | /-c</span>
754-
<span class="go"> |---------|</span>
755-
<span class="go">---------| | /-b</span>
756-
<span class="go"> | \--------|</span>
757-
<span class="go"> | \-a</span>
758-
<span class="go"> |</span>
759-
<span class="go"> \-e</span>
760-
</pre></div>
761-
</div>
762-
<p>Again, construct the neighbor joining tree, but instead return the newick
763-
string representing the tree, rather than the TreeNode object. (Note that
764-
in this example the string output is truncated when printed to facilitate
765-
rendering.)</p>
766-
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">newick_str</span> <span class="o">=</span> <span class="n">nj</span><span class="p">(</span><span class="n">dm</span><span class="p">,</span> <span class="n">result_constructor</span><span class="o">=</span><span class="nb">str</span><span class="p">)</span>
767-
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">newick_str</span><span class="p">[:</span><span class="mi">55</span><span class="p">],</span> <span class="s2">&quot;...&quot;</span><span class="p">)</span>
768-
<span class="go">(d:2.000000, (c:4.000000, (b:3.000000, a:2.000000):3.00 ...</span>
785+
<span class="go"> \-d</span>
769786
</pre></div>
770787
</div>
771-
<p>Notice that the tree constructed using neighbor joining is not rooted at a
772-
leaf node, unlike minimum evolution, so re-rooting is required before
773-
nearest neighbor interchange can be performed.</p>
774788
</dd></dl>
775789

776790
</section>

docs/dev/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dev/tree.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ <h2>Tree Construction<a class="headerlink" href="#tree-construction" title="Link
685685
<tr class="row-odd"><td><p><a class="reference internal" href="generated/skbio.tree.upgma.html#skbio.tree.upgma" title="skbio.tree.upgma"><code class="xref py py-obj docutils literal notranslate"><span class="pre">upgma</span></code></a>(dm[, weighted])</p></td>
686686
<td><p>Perform unweighted pair group method with arithmetic mean (UPGMA) or its weighted variant (WPGMA) for phylogenetic reconstruction.</p></td>
687687
</tr>
688-
<tr class="row-even"><td><p><a class="reference internal" href="generated/skbio.tree.nj.html#skbio.tree.nj" title="skbio.tree.nj"><code class="xref py py-obj docutils literal notranslate"><span class="pre">nj</span></code></a>(dm[, disallow_negative_branch_length, ...])</p></td>
688+
<tr class="row-even"><td><p><a class="reference internal" href="generated/skbio.tree.nj.html#skbio.tree.nj" title="skbio.tree.nj"><code class="xref py py-obj docutils literal notranslate"><span class="pre">nj</span></code></a>(dm[, clip_to_zero, result_constructor, ...])</p></td>
689689
<td><p>Perform neighbor joining (NJ) for phylogenetic reconstruction.</p></td>
690690
</tr>
691691
<tr class="row-odd"><td><p><a class="reference internal" href="generated/skbio.tree.gme.html#skbio.tree.gme" title="skbio.tree.gme"><code class="xref py py-obj docutils literal notranslate"><span class="pre">gme</span></code></a>(dm[, allow_edge_estimation])</p></td>

0 commit comments

Comments
 (0)