DRL / blobtools

Modular command-line solution for visualisation, quality control and taxonomic partitioning of genome datasets
GNU General Public License v3.0
184 stars 44 forks source link

ValueError: Invalid RGBA argument: '#' when assigning HEX color to phyla #86

Closed anhdha closed 5 years ago

anhdha commented 5 years ago

Hello, I got this error while trying to assign colors to phyla in my blob plot: blobtools plot -p 15 -i match_bin.blobDB.json --colours colours.txt

Traceback (most recent call last): File "/local/cluster/blobtools/lib/blobplot.py", line 183, in main() File "/local/cluster/blobtools/lib/blobplot.py", line 175, in main plotObj.plotScatter(cov_lib, info_flag, out_f) File "/local/cluster/blobtools/lib/BtPlot.py", line 649, in plotScatter axHistx.hist(group_x_array, weights=weights_array, color = colour, bins = top_bins, histtype='step', lw = 3) File "/local/cluster/lib/python2.7/site-packages/matplotlib/init.py", line 1867, in inner return func(ax, *args, **kwargs) File "/local/cluster/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 6611, in hist color = mcolors.to_rgba_array(color) File "/local/cluster/lib/python2.7/site-packages/matplotlib/colors.py", line 267, in to_rgba_array result[i] = to_rgba(cc, alpha) File "/local/cluster/lib/python2.7/site-packages/matplotlib/colors.py", line 168, in to_rgba rgba = _to_rgba_no_colorcycle(c, alpha) File "/local/cluster/lib/python2.7/site-packages/matplotlib/colors.py", line 212, in _to_rgba_no_colorcycle raise ValueError("Invalid RGBA argument: {!r}".format(orig_c)) ValueError: Invalid RGBA argument: '#'

The match_bin.blobDB.json file could be plotted fine without the --colours flag. My colours.txt file looks like this:

Firmicutes,#f3b2bc Chrysiogenetes,#eb7f90 Spirochaetes,#e34c63 Synergistetes,#db1937 undef,#d80021 Gemmatimonadetes,#ac001a Deferribacteres,#810013 Dictyoglomi,#56000d Nitrospirae,#400009 Thermotogae,#2b0006 Thermodesulfobacteria,#000000

Could you help me with this issue? Thank you so much for your time!

DRL commented 5 years ago

Hi anhdha,

probably easiest if you switch to the latest version (v1.1). The colour-scheme has been changed and you might not even have to change it yourself. One small downside is that -p is now restricted to max 9. Please let me know if the issue persists.

cheers,

dom

anhdha commented 5 years ago

Thank you for your super quick reply! I do wish to be able to plot at least -p 12 though. Is there anything I could try to avoid the error in this current version (1.0)? I even tried to assign the phyla with categories using --catcolour and run with the --colours flag containing HEX color for each category, but then all the blobs in my plot were white, and in the .stats.txt file their colors all became #ffffff.

DRL commented 5 years ago

Made a change to the code so that one can circumvent the --plotgroups limit by specifying a colour.txt file. This is now in the newest release (v1.1.1).

Please reopen the issue if the problem is not solved.

cheers,

dom