-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matplotlib errors #1263
Comments
Hmm, not great. Could you please do a conda env dump / pip freeze in an environment where you had this error? |
Hi Phil, sure, here is the conda env dump. It's not urgent at all though, just wanted to report it! |
I am experiencing similar errors using module mirtrace with MultiQC v1.9. This error only occurs if
Module mirtrace raised an exception: Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/multiqc/plots/bargraph.py", line 178, in plot
return get_template_mod().bargraph(plotdata, plotsamples, pconfig)
AttributeError: module 'multiqc_zymo.templates.zymo' has no attribute 'bargraph'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/matplotlib/colors.py", line 325, in to_rgba_array
result = np.array([to_rgba(cc, alpha) for cc in c])
File "/usr/local/lib/python3.6/site-packages/matplotlib/colors.py", line 325, in <listcomp>
result = np.array([to_rgba(cc, alpha) for cc in c])
File "/usr/local/lib/python3.6/site-packages/matplotlib/colors.py", line 189, in to_rgba
rgba = _to_rgba_no_colorcycle(c, alpha)
File "/usr/local/lib/python3.6/site-packages/matplotlib/colors.py", line 260, in _to_rgba_no_colorcycle
raise ValueError(f"Invalid RGBA argument: {orig_c!r}")
ValueError: Invalid RGBA argument: '('
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/multiqc/multiqc.py", line 569, in run
output = mod()
File "/usr/local/lib/python3.6/site-packages/multiqc/modules/mirtrace/mirtrace.py", line 89, in __init__
plot = self.mirtrace_contamination_check()
File "/usr/local/lib/python3.6/site-packages/multiqc/modules/mirtrace/mirtrace.py", line 320, in mirtrace_contamination_check
return bargraph.plot(self.contamination_data, keys, config)
File "/usr/local/lib/python3.6/site-packages/multiqc/plots/bargraph.py", line 190, in plot
matplotlib_bargraph(plotdata, plotsamples, pconfig)
File "/usr/local/lib/python3.6/site-packages/multiqc/plots/bargraph.py", line 436, in matplotlib_bargraph
linewidth = pconfig.get('borderWidth', 0)
File "/usr/local/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 2631, in barh
align=align, **kwargs)
File "/usr/local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1438, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "/usr/local/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 2443, in bar
color = itertools.chain(itertools.cycle(mcolors.to_rgba_array(color)),
File "/usr/local/lib/python3.6/site-packages/matplotlib/colors.py", line 330, in to_rgba_array
"'rgb'. Note also that the latter is deprecated." % c) from err
ValueError: 'rgb(255,255,179)' is neither a valid single color nor a color sequence consisting of single character color specifiers such as 'rgb'. Note also that the latter is deprecated. I tried changing
Module mirtrace raised an exception: Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/multiqc/plots/bargraph.py", line 178, in plot
return get_template_mod().bargraph(plotdata, plotsamples, pconfig)
AttributeError: module 'multiqc_zymo.templates.zymo' has no attribute 'bargraph'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/multiqc/multiqc.py", line 546, in run
output = mod()
File "/usr/local/lib/python3.6/site-packages/multiqc/modules/mirtrace/mirtrace.py", line 89, in __init__
plot = self.mirtrace_contamination_check()
File "/usr/local/lib/python3.6/site-packages/multiqc/modules/mirtrace/mirtrace.py", line 320, in mirtrace_contamination_check
return bargraph.plot(self.contamination_data, keys, config)
File "/usr/local/lib/python3.6/site-packages/multiqc/plots/bargraph.py", line 190, in plot
matplotlib_bargraph(plotdata, plotsamples, pconfig)
File "/usr/local/lib/python3.6/site-packages/multiqc/plots/bargraph.py", line 436, in matplotlib_bargraph
linewidth = pconfig.get('borderWidth', 0)
File "/usr/local/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 2597, in barh
align=align, **kwargs)
File "/usr/local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1601, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "/usr/local/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 2386, in bar
color = itertools.chain(itertools.cycle(mcolors.to_rgba_array(color)),
File "/usr/local/lib/python3.6/site-packages/matplotlib/colors.py", line 294, in to_rgba_array
result[i] = to_rgba(cc, alpha)
File "/usr/local/lib/python3.6/site-packages/matplotlib/colors.py", line 177, in to_rgba
rgba = _to_rgba_no_colorcycle(c, alpha)
File "/usr/local/lib/python3.6/site-packages/matplotlib/colors.py", line 233, in _to_rgba_no_colorcycle
raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
ValueError: Invalid RGBA argument: '(' |
I also found this (or a similar) error when running multiqc for the new implementation of the nf-core/smrnaseq:
|
Ok, so I don't think that this is module specific - it's something funky going on in the core code when custom bargraph category colours are passed. They work fine for the interactive plots, but if Matplotlib is invoked due to large sample size or exported plots, it throws an error. It clearly also has something to do with Matplotlib syntax as @ggabernet was able to solve the issue by downgrading matplotlib from This is backed up by the code google found for me here (weirdly doesn't seem to correspond to the source on GitHub?) # Convert one at a time.
if isinstance(c, str):
# Single string as color sequence.
# This is deprecated and will be removed in the future.
try:
result = np.array([to_rgba(cc, alpha) for cc in c])
except ValueError as err:
raise ValueError(
"'%s' is neither a valid single color nor a color sequence "
"consisting of single character color specifiers such as "
"'rgb'. Note also that the latter is deprecated." % c) from err
else:
cbook.warn_deprecated(
"3.2", message="Using a string of single character colors as "
"a color sequence is deprecated since %(since)s and will be "
"removed %(removal)s. Use an explicit list instead.")
return result Right, so the actual cause for the exception still seems obscure to me (getting only |
Fix will be to change the core code in MultiQC to pass lists of rgb values instead of strings. Somewhere around.... here:
Huh, looks like the default colours we're giving to matplotlib are hex strings: So if that's not also about to be deprecated imminently another option could be to convert the rgb strings to hex codes. We're already using the |
I really don't understand why this hasn't come up more already.. Version 3.1 of matplotlib was released way back in Feb 2019... I feel like I must be missing something 🤔 |
Ok, managed to replicate this locally now. It's actually quite difficult to get the unhandled traceback above - MultiQC needs to run with normal interactive plots (not Anyway, using verbose logging ( Switching these to Hex codes instead seems to fix the issue. That's done in a1b4cdf - I think this fixes the errors seen by @JoseEspinosa and @zxl124 However, your original error @ggabernet is a bit different. I can't replicate this one, and it's now on a fairly dated version of MultiQC. As I can't replicate it I'm just going to close this issue and ignore it for now if that's ok 😅 If anyone else hits this error or is able to replicate the same matplotlib crash let me know, and we can reopen. Thanks all, Phil |
Awesome @ewels , thanks a lot! |
Just tried and solved the problem! 🎉 Are you planning to release a new version including these changes soon? |
Great! Yes release v. soon. Maybe today, we'll see.. |
Thanks for looking into the issue again, I think now with DSL2 and the new version of MultiQC I should not have this issue any more. |
Description of bug:
I have an error with MultiQC v1.9 and the fastqc module that seems to be related to #973.
MultiQC Error log:
File that triggers the error:
MultiQC run details (please complete the following):
multiqc -f .
v1.10.2
Python 3.6.11
conda
(inside container)Additional context
I solved it by pinning
matplotlib=3.0.3
in theenvironment.yml
, as was suggested already then.The text was updated successfully, but these errors were encountered: