biocore / gneiss

compositional data analysis toolbox
https://biocore.github.io/gneiss/
BSD 3-Clause "New" or "Revised" License
56 stars 28 forks source link

Weird error with rescale function in Dendrogram #126

Open mortonjt opened 7 years ago

mortonjt commented 7 years ago

In some cases, it is possible to get the following error

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-65-0950dae6eb6b> in <module>()
     14     n.length = gradient.loc[list(n.subset())].mean()
     15 
---> 16 p = radialplot(sorted_tree, figsize=(500, 500))
     17 show(p)

/Users/mortonjt/Dropbox/UCSD/research/gneiss/gneiss/plot/_radial.py in radialplot(tree, node_color, node_size, node_alpha, edge_color, edge_alpha, edge_width, figsize, **kwargs)
     62     t = UnrootedDendrogram.from_tree(tree)
     63 
---> 64     nodes = t.coords(figsize[0], figsize[1])
     65 
     66     # fill in all of the node attributes

/Users/mortonjt/Dropbox/UCSD/research/gneiss/gneiss/plot/_dendrogram.py in coords(self, height, width)
    111                 Specifies if the node is a tip in the treee.
    112         """
--> 113         self.rescale(width, height)
    114         result = {}
    115         for node in self.postorder():

/Users/mortonjt/Dropbox/UCSD/research/gneiss/gneiss/plot/_dendrogram.py in rescale(self, width, height)
    226                 mid_y = height / 2 - ((max(ys) + min(ys)) / 2) * scale
    227                 best_args = (scale, mid_x, mid_y, direction, angle)
--> 228 
    229         self.update_coordinates(*best_args)
    230         return best_scale

UnboundLocalError: local variable 'best_args' referenced before assignment
mortonjt commented 7 years ago

This can happen if the branch lengths are np.nan. Will need to find a way to check this better.