Skip to content

Commit 62c369b

Browse files
committed
Merge branch 'master' into version_flag
2 parents 8373d60 + 6419ce9 commit 62c369b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/hatchet/utils/plot_bins.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,14 @@ def select(bbc, clusters, args):
396396
s = ['{}:\tSIZE= {},\t# CHRS= {}'.format(idx, count[idx]['SIZE'], count[idx]['CHRS']) for idx in sel]
397397
sys.stderr.write(info('## Selected clusters: \n{}\n'.format('\n'.join(s))))
398398

399-
clust_order = sorted(sel, key=(lambda x: count[x]['SIZE']), reverse=True) # order selected clusters large -> small
399+
# if too many clusters are selected, still select the largest ones based on the number of colors in palette
400+
sel = sorted(sel, key=(lambda x: count[x]['SIZE']), reverse=True) # order selected clusters large -> small
401+
sel = sel[0:len(sns.color_palette(args['cmap']))] # select the top ones if more selected clusters than colors
402+
clust_order = [i for i in reversed(sel)] # reverse order for later plotting, smaller selected clusters in front
400403
# add on the rest of the unselected clusters, but we'll know which ones to color based on the number of
401404
# colors in the palette pal
402405
[ clust_order.append(i) if not i in sel else next for i in alls ]
406+
# configure palette; subselecting colors if there are fewer selected clusters than colors
403407
if len(sel) <= len(sns.color_palette(args['cmap'])): # are there more colors than selected clusters?
404408
pal = sns.color_palette(args['cmap'])[0:len(sel)] # only select colors for the selected clusters at begining of clust_order
405409
else:

0 commit comments

Comments
 (0)