Metaphlan4 error with hclust2.py

Hello,
I’m trying to analyse my merged abundance table with hclust2.py and get the following errors. Could you please advise on what I might be doing wrong please?
Thanks.

/home/plzrja/miniconda3/bin/hclust2.py -i merged_abundance_table.txt -o HMP.sqrt_scale.png --skip_rows 1 --ftop 50 --f_dist_f correlation --s_dist_f braycurtis --cell_aspect_ratio 9 -s --fperc 99 --flabel_size 4 --metadata_rows 2,3,4 --legend_file HMP.sqrt_scale.legend.png --max_flabel_len 100 --metadata_height 0.075 --minv 0.01 --no_slabels --dpi 300 --slinkage complete
/home/plzrja/miniconda3/bin/hclust2.py:588: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. This has been deprecated since 3.3 and in 3.6, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = mpl.cm.get_cmap(“bbcry”).copy()
cm.set_under( bottom_col )
/home/plzrja/miniconda3/bin/hclust2.py:594: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. This has been deprecated since 3.3 and in 3.6, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = mpl.cm.get_cmap(“bbcry”).copy()
cm.set_over( top_col )
/home/plzrja/miniconda3/bin/hclust2.py:678: MatplotlibDeprecationWarning: Passing parameters norm and vmin/vmax simultaneously is deprecated since 3.3 and will become an error two minor releases later. Please pass vmin/vmax directly to the norm when creating it.
im = ax_hm.imshow( self.numpy_matrix, #origin=‘lower’,
Traceback (most recent call last):
File “/home/plzrja/miniconda3/bin/hclust2.py”, line 825, in
hclust2_main()
File “/home/plzrja/miniconda3/bin/hclust2.py”, line 822, in hclust2_main
hm.draw()
File “/home/plzrja/miniconda3/bin/hclust2.py”, line 708, in draw
cbar = fig.colorbar(im, ax_cm, orientation = ‘horizontal’, spacing=‘proportional’ if self.args.sqrt_scale else ‘uniform’ ) # , format = ticker.LogFormatterMathtext() )
File “/home/plzrja/miniconda3/lib/python3.9/site-packages/matplotlib/figure.py”, line 1176, in colorbar
cb = cbar.Colorbar(cax, mappable, **cb_kw)
File “/home/plzrja/miniconda3/lib/python3.9/site-packages/matplotlib/colorbar.py”, line 1197, in init
super().init(ax, **kwargs)
File “/home/plzrja/miniconda3/lib/python3.9/site-packages/matplotlib/_api/deprecation.py”, line 471, in wrapper
return func(*args, **kwargs)
File “/home/plzrja/miniconda3/lib/python3.9/site-packages/matplotlib/colorbar.py”, line 511, in init
self.draw_all()
File “/home/plzrja/miniconda3/lib/python3.9/site-packages/matplotlib/colorbar.py”, line 528, in draw_all
self._process_values()
File “/home/plzrja/miniconda3/lib/python3.9/site-packages/matplotlib/colorbar.py”, line 962, in _process_values
b = self.norm.inverse(self._uniform_y(self.cmap.N + 1))
File “/home/plzrja/miniconda3/bin/hclust2.py”, line 74, in inverse
if matplotlib.cbook.iterable(value):
AttributeError: module ‘matplotlib.cbook’ has no attribute ‘iterable’

It seems your matplotlib version is in conflict with the version needed to run hclust2.py. I would recommend you to downgrade the matplotlib version to 2.0.0, here an example how to do it:
$ pip install seaborn==0.8.1 matplotlib==2.0.0

1 Like

Hi,

I’ve followed your advice but unfortunately got an error message :

Traceback (most recent call last):
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/hclust2.py", line 5, in <module>
    import matplotlib.ticker as ticker
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/matplotlib/ticker.py", line 181, in <module>
    from matplotlib import transforms as mtransforms
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/matplotlib/transforms.py", line 55, in <module>
    MINFLOAT = np.MachAr(float).xmin
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'MachAr'

Then I additionally tried pip install numpy==1.23.5 for attribute MachAr of numpy.

But I got an other error message :

Traceback (most recent call last):
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/hclust2.py", line 12, in <module>
    import pylab
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/matplotlib/pylab.py", line 257, in <module>
    from matplotlib import cbook, mlab, pyplot as plt
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/matplotlib/pyplot.py", line 29, in <module>
    import matplotlib.colorbar
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/matplotlib/colorbar.py", line 36, in <module>
    import matplotlib.contour as contour
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/matplotlib/contour.py", line 22, in <module>
    import matplotlib.font_manager as font_manager
  File "/home/hjy/miniconda3/envs/biobakery/lib/python3.10/site-packages/matplotlib/font_manager.py", line 50, in <module>
    from collections import Iterable
ImportError: cannot import name 'Iterable' from 'collections' (/home/hjy/miniconda3/envs/biobakery/lib/python3.10/collections/__init__.py)

with

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
metaphlan 4.0.6 requires hclust2, which is not installed.

my command for running hclust2 is

~/miniconda3/envs/biobakery/lib/python3.10/site-packages/hclust2.py \
-i sgb_merge_sp.tsv \
-o sgb_merge_sp.png \
--f_dist_f braycurtis \
--s_dist_f braycurtis \
--cell_aspect_ratio 0.5 \
--log_scale \
--flabel_size 5 --slabel_size 5 \
--max_flabel_len 100 --max_slabel_len 100 \
--colorbar_font_size 10 \
--dpi 600 \
-c RdYlBu

I don’t know what to do to overcome these error.
I would appreciate any advice.

Hi @Kirby, it seems there is a lot of package conflicts in your installation, you might want to try to install it all in a clean conda environment

downgrading libraries can sometimes lead to other compatibility issues, especially if you’re working in an environment with many dependencies. It’s often a good idea to do this in a virtual environment to avoid affecting other projects or system-wide settings. If you’re not familiar with virtual environments, you can create one using tools like venv or conda .