<div dir="ltr">Hmm, I don't have access to a Mac so I'm not going to be able to fix this one myself. Can anyone else take a shot at fixing this bug? Jan?<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 27, 2015 at 7:48 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Eric, </div><div><br></div><div>This is brilliant, the problem is solved on the linux, and I'm totally happy with that (as can get on with my work :) ), but please be advised that this seems to have created some issue the matplotlib mac OSX backend doesn't like: </div><div><br></div><div>on mac OSX pylab.show() yields: </div><div><br></div><div>---------------------------------------------------------------------------<br></div><div><div>TypeError Traceback (most recent call last)</div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)</div><div> 57 def draw_wrapper(artist, renderer, *args, **kwargs):</div><div> 58 before(artist, renderer)</div><div>---> 59 draw(artist, renderer, *args, **kwargs)</div><div> 60 after(artist, renderer)</div><div> 61</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/figure.pyc in draw(self, renderer)</div><div> 1077 dsu.sort(key=itemgetter(0))</div><div> 1078 for zorder, a, func, args in dsu:</div><div>-> 1079 func(*args)</div><div> 1080</div><div> 1081 renderer.close_group('figure')</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)</div><div> 57 def draw_wrapper(artist, renderer, *args, **kwargs):</div><div> 58 before(artist, renderer)</div><div>---> 59 draw(artist, renderer, *args, **kwargs)</div><div> 60 after(artist, renderer)</div><div> 61</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)</div><div> 2090</div><div> 2091 for zorder, a in dsu:</div><div>-> 2092 a.draw(renderer)</div><div> 2093</div><div> 2094 renderer.close_group('axes')</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)</div><div> 57 def draw_wrapper(artist, renderer, *args, **kwargs):</div><div> 58 before(artist, renderer)</div><div>---> 59 draw(artist, renderer, *args, **kwargs)</div><div> 60 after(artist, renderer)</div><div> 61</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/text.pyc in draw(self, renderer)</div><div> 536 renderer.open_group('text', self.get_gid())</div><div> 537</div><div>--> 538 bbox, info, descent = self._get_layout(renderer)</div><div> 539 trans = self.get_transform()</div><div> 540</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/text.pyc in _get_layout(self, renderer)</div><div> 309 tmp, lp_h, lp_bl = renderer.get_text_width_height_descent('lp',</div><div> 310 self._fontproperties,</div><div>--> 311 ismath=False)</div><div> 312 offsety = (lp_h - lp_bl) * self._linespacing</div><div> 313</div><div><br></div><div>/Users/janzaucha/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.pyc in get_text_width_height_descent(self, s, prop, ismath)</div><div> 164 size = self.points_to_pixels(points)</div><div> 165 width, height, descent = self.gc.get_text_width_height_descent(</div><div>--> 166 six.text_type(s), family, size, weight, style)</div><div> 167 return width, height, 0.0*descent</div><div> 168</div></div><div><br></div><div>Best wishes,</div><div>Jan Zaucha<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 26 January 2015 at 21:06, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" target="_blank">https://github.com/networkx/networkx/blame/master/networkx/drawing/nx_pylab.py</a><br><br></div><div><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><font color="#888888"><div style="font-size:12.8px">Jan</div><div style="font-size:12.8px"><br></div></font></span></div><div><div><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></div></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></div>