@@ -48,28 +48,6 @@ def _get_leaves(condensed_tree):
4848 root = cluster_tree ['parent' ].min ()
4949 return _recurse_leaf_dfs (cluster_tree , root )
5050
51- def _bfs_from_linkage_tree (hierarchy , bfs_root ):
52- """
53- Perform a breadth first search on a tree in scipy hclust format.
54- """
55-
56- dim = hierarchy .shape [0 ]
57- max_node = 2 * dim
58- num_points = max_node - dim + 1
59-
60- to_process = [bfs_root ]
61- result = []
62-
63- while to_process :
64- result .extend (to_process )
65- to_process = [x - num_points for x in
66- to_process if x >= num_points ]
67- if to_process :
68- to_process = hierarchy [to_process , :2 ].flatten ().astype (np .int64 ).tolist ()
69-
70- return result
71-
72-
7351class CondensedTree (object ):
7452 def __init__ (self , condensed_tree_array ):
7553 self ._raw_tree = condensed_tree_array
@@ -165,7 +143,12 @@ def get_plot_data(self, leaf_separation=1, log_size=False):
165143 bar_bottoms .append (current_lambda )
166144 bar_widths .append (current_size )
167145 if log_size :
168- current_size = np .log (np .exp (current_size ) - row ['child_size' ])
146+ exp_size = np .exp (current_size ) - row ['child_size' ]
147+ # Ensure we don't try to take log of zero
148+ if exp_size > 0.01 :
149+ current_size = np .log (np .exp (current_size ) - row ['child_size' ])
150+ else :
151+ current_size = 0.0
169152 else :
170153 current_size -= row ['child_size' ]
171154 current_lambda = row ['lambda_val' ]
@@ -327,7 +310,7 @@ def plot(self, leaf_separation=1, cmap='viridis', select_clusters=False,
327310 )
328311
329312 if selection_palette is not None and \
330- len (selection_palette ) > len (chosen_clusters ):
313+ len (selection_palette ) >= len (chosen_clusters ):
331314 oval_color = selection_palette [i ]
332315 else :
333316 oval_color = 'r'
0 commit comments