<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Thanks, Jan, that was helpful for debugging. I pushed a fix to GitHub, so if you can install the development version of Biopython, it should work for you now.<br><br>The problem was a bug in networkx release 1.9.1 (and maybe others) that existed between August 2013 and September 2014. The networkx "draw" function would pass all keywords to "draw_networkx", except that while "draw_networkx" has a keywords argument "with_labels" that defaults to True, "draw" would override this to "False" unless it had been specified explicitly. It has since been fixed in networkx and should be included in the next release:<br><a href="https://github.com/networkx/networkx/blame/master/networkx/drawing/nx_pylab.py">https://github.com/networkx/networkx/blame/master/networkx/drawing/nx_pylab.py</a><br><br></div><div class="gmail_quote"><br>On Mon, Jan 26, 2015 at 2:41 AM, Jan Zaucha <span dir="ltr"><<a href="mailto:Jan.Zaucha@bristol.ac.uk" target="_blank">Jan.Zaucha@bristol.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks Eric,<div><br></div><div>I'm using biopython 1.65 and networkx 1.9.1. </div><div><br></div><div>When I ran the commands you've proposed I still see the node names assigned:</div><div>[Clade(branch_length=2.0, name='foo'), Clade(branch_length=4.0, name='bar), Clade(...), ... ]<br></div><div><br></div><div>I'm not sure what the source file format is, I created the tree myself from a distance matrix, the examples I was looking at were importing trees </div><div>from <span style="font-size:12.8px">PhyloXML. Here's the code I'm running, maybe this will help: </span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">###################### testing graphviz</span></div><div><div><span style="font-size:12.8px">from Bio import Phylo</span></div><div><span style="font-size:12.8px">from Bio.Phylo.TreeConstruction import _DistanceMatrix</span></div><div><span style="font-size:12.8px">from Bio.Phylo.TreeConstruction import DistanceTreeConstructor</span></div><div><span style="font-size:12.8px">import pylab</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">names = ['foo', 'bar', 'cat', 'dog']</span></div><div><span style="font-size:12.8px">matrix = [[0], [1, 0], [2, 3, 0], [4, 5, 6, 0]]</span></div><div><span style="font-size:12.8px">m = _DistanceMatrix(names, matrix)</span></div><div><span style="font-size:12.8px">constructor = DistanceTreeConstructor()</span></div><div><span style="font-size:12.8px">tree = constructor.nj(m)</span></div><div><span style="font-size:12.8px">graph = Phylo.to_networkx(tree)</span></div><div><span style="font-size:12.8px">print graph.nodes()</span></div><div><span style="font-size:12.8px">Phylo.draw_graphviz(tree, prog="neato", node_size=50)</span></div><div><span style="font-size:12.8px">pylab.show()</span></div><div style="font-size:12.8px">##########################</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I still don't understand where I'm going wrong.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Best wishes, </div><span class=""><font color="#888888"><div style="font-size:12.8px">Jan</div><div style="font-size:12.8px"><br></div></font></span></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 23 January 2015 at 16:33, Eric Talevich <span dir="ltr"><<a href="mailto:eric.talevich@gmail.com" target="_blank">eric.talevich@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div>Hi Jan,<br><br></div>Could you show us some more information about your tree, like the first few lines you see with "print tree"? Also try converting the tree to a NetworkX graph, which is the intermediate form used by draw_graphviz, and inspecting the nodes to see if names were lost or retained:<br><br></div><div>graph = Phylo.to_networkx(tree)<br></div><div>graph.nodes()<br><br></div><div>Also:<br><br></div><div>- What was the source file format (e.g. Newick, Nexus, PhyloXML, NeXML)<br></div><div>- Which versions of Biopython and NetworkX are you using?<br></div><div><br></div>It's possible the node names are assigned to a different attribute than the node name, in which case you can use the "label_func" argument in draw_graphviz to retrieve the name from the graph node.<br><br></div>Hope that helps,<br>Eric<br><div><div><br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, Jan 22, 2015 at 8:02 AM, Jan Zaucha <span dir="ltr"><<a href="mailto:Jan.Zaucha@bristol.ac.uk" target="_blank">Jan.Zaucha@bristol.ac.uk</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="ltr"><span style="font-size:13px">Hi everyone,</span><div style="font-size:13px"><br></div><div style="font-size:13px">I'm trying to visualize the trees I generate, but for some reason the plots do not display the node names. When I print the tree each node has an associated name (string format). Phylo.draw(tree) also works fine and plots a tree with the node names. </div><div style="font-size:13px"><br></div><div style="font-size:13px">I simply use:</div><div style="font-size:13px">Phylo.draw_graphviz(tree)<br></div><div style="font-size:13px">pylab.show()</div><div style="font-size:13px"><br></div><div style="font-size:13px">There is no error, I can't work out how to force the node names to be printed. </div><div style="font-size:13px"><br></div><div style="font-size:13px">Any ideas?</div><div style="font-size:13px"><br></div><div style="font-size:13px">Thanks,</div><div style="font-size:13px">Jan Zaucha</div><span><font color="#888888"><div><br></div>-- <br><div><div dir="ltr"><div>Jan Zaucha</div><div>Bristol Centre for Complexity Sciences<br></div><div>Computational Genomics Group<br></div><div>University of Bristol</div></div></div>
</font></span></div>
<br></div></div>_______________________________________________<br>
Biopython mailing list - <a href="mailto:Biopython@mailman.open-bio.org" target="_blank">Biopython@mailman.open-bio.org</a><br>
<a href="http://mailman.open-bio.org/mailman/listinfo/biopython" target="_blank">http://mailman.open-bio.org/mailman/listinfo/biopython</a><br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div>Jan Zaucha</div><div>Bristol Centre for Complexity Sciences<br></div><div>Computational Genomics Group<br></div><div>University of Bristol</div></div></div>
</div>
</div></div></blockquote></div><br></div></div>