deeptools / HiCExplorer

HiCExplorer is a powerful and easy to use set of tools to process, normalize and visualize Hi-C data.
https://hicexplorer.readthedocs.org
GNU General Public License v3.0
223 stars 68 forks source link

Installation with newer version of `matplotlib`: "`ValueError: Passing a Normalize instance simultaneously with vmin/vmax is not supported.`" #873

Closed kalavattam closed 8 months ago

kalavattam commented 9 months ago

Welcome to the HiCExplorer GitHub repository! Before opening the issue please check that the following requirements are met:

❯ hicexplorer --version hicexplorer 3.7.2

❯ mamba list | grep matplotlib-base matplotlib-base 3.6.2 py310h8d5ebf3_0 conda-forge

❯ mamba list | grep python biopython 1.81 py310h1fa729e_0 conda-forge brotli-python 1.1.0 py310hc6cd4ac_1 conda-forge bx-python 0.10.0 py310h551a815_0 bioconda ipython 8.16.0 pyh0d859eb_0 conda-forge msgpack-python 1.0.6 py310hd41b1e2_0 conda-forge python 3.10.12 hd12c33a_0_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-graphviz 0.20.1 pyh22cad53_0 conda-forge python-tzdata 2023.3 pyhd8ed1ab_0 conda-forge python_abi 3.10 4_cp310 conda-forge

II. Test environment with installation per this comment:

https://github.com/deeptools/HiCExplorer/issues/764#issuecomment-985617076

Still encounter bug

❯ echo "${CONDA_DEFAULT_ENV}" hicexplorer_test_env_1

❯ hicexplorer --version hicexplorer 3.7.2

❯ mamba list | grep matplotlib-base matplotlib-base 3.5.3 py37hf395dca_2 conda-forge

❯ mamba list | grep python biopython 1.79 py37h540881e_2 conda-forge bx-python 0.9.0 py37hfa8f21c_1 bioconda ipython 7.33.0 py37h89c1867_0 conda-forge msgpack-python 1.0.4 py37h7cecad7_0 conda-forge python 3.7.12 hf930737_100_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-graphviz 0.20.1 pyh22cad53_0 conda-forge python-lzo 1.14 py37hd06c622_1 conda-forge python_abi 3.7 4_cp37m conda-forge

III. Test environment with installation per this comment:

https://github.com/deeptools/HiCExplorer/issues/764#issuecomment-985631158

No longer encounter bug

❯ echo "${CONDA_DEFAULT_ENV}" hicexplorer_test_env_2

❯ hicexplorer --version hicexplorer 3.7.2

❯ mamba list | grep matplotlib-base matplotlib-base 3.2.2 py37h1d35a4c_1 conda-forge

❯ mamba list | grep python biopython 1.79 py37h540881e_2 conda-forge bx-python 0.9.0 py37hfa8f21c_1 bioconda ipython 7.33.0 py37h89c1867_0 conda-forge msgpack-python 1.0.4 py37h7cecad7_0 conda-forge python 3.7.12 hf930737_100_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-graphviz 0.20.1 pyh22cad53_0 conda-forge python-lzo 1.14 py37hd06c622_1 conda-forge python_abi 3.7 4_cp37m conda-forge


- [x] Have you checked our documentation on [hicexplorer.readthedocs.io](https://hicexplorer.readthedocs.io)?
- [x] Do you use [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html) to install HiCExplorer? 
```bash
#  I. Installation command for initial environment
#  ### Encounter bug ###
mamba create \
    -n hicexplorer_env \
    -c conda-forge -c bioconda \
        hicexplorer=3.7.2=pyhdfd78af_1

#  II. Installation command for initial environment
#  ### Encounter bug ###
mamba create \
    -n hicexplorer_test_env_1 \
    -c bioconda -c conda-forge \
        hicexplorer=3.7.2 \
        python=3.7

#  III. Installation command for initial environment
#  ### No longer encounter bug ###
mamba create \
    -n hicexplorer_test_env_2 \
    -c bioconda -c conda-forge \
        hicexplorer=3.7.2 \
        python=3.7 \
        matplotlib=3.2.2

Retry your command, is it solved now? If not please continue with the following:

Working with S. cerevisiae, so chromosomes have roman-numeral names

hicPlotMatrix \ --chromosomeOrder I II III IV V VI VII VIII IX X XI XII XIII XIV XV XVI \ --colorMap "PuRd" \ --log \ --vMin 0.0001 \ --vMax 1 \ --matrix "${dir}/${cool}" \ --outFileName "test.pdf"

Bug seems to arise from invocation of --vMin ${value_floor} and --vMax

${value_celing} with the flag --log; however, it's expected that this should

work and, indeed, did work when I used earlier versions of HiCExplorer


- [x] Paste the output printed on screen from the command that produces the issue
  below (ignore if you simply spotted the issue in the code/documentation).
```txt
❯ echo "${CONDA_DEFAULT_ENV}"
hicexplorer_env  # Same error with hicexplorer_test_env_1

❯ hicPlotMatrix \
>     --chromosomeOrder I II III IV V VI VII VIII IX X XI XII XIII XIV XV XVI \
>     --colorMap "PuRd" \
>     --log \
>     --vMin 0.0001 \
>     --vMax 1 \
>     --matrix "${dir}/${cool}" \
>     --outFileName "test.pdf"
INFO:hicexplorer.hicPlotMatrix:Cooler or no cooler: True
INFO:hicexplorer.hicPlotMatrix:min: 2.0356669271154623e-05, max: 0.32483315613704933

Traceback (most recent call last):
  File "/home/kalavatt/miniconda3/envs/hicexplorer_env/bin/hicPlotMatrix", line 7, in <module>
    main()
  File "/home/kalavatt/miniconda3/envs/hicexplorer_env/lib/python3.10/site-packages/hicexplorer/hicPlotMatrix.py", line 820, in main
    plotHeatmap(matrix, ma.get_chromosome_sizes(), fig, position,
  File "/home/kalavatt/miniconda3/envs/hicexplorer_env/lib/python3.10/site-packages/hicexplorer/hicPlotMatrix.py", line 244, in plotHeatmap
    img3 = axHeat2.pcolormesh(
  File "/home/kalavatt/miniconda3/envs/hicexplorer_env/lib/python3.10/site-packages/matplotlib/__init__.py", line 1423, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/home/kalavatt/miniconda3/envs/hicexplorer_env/lib/python3.10/site-packages/matplotlib/axes/_axes.py", line 6174, in pcolormesh
    collection._scale_norm(norm, vmin, vmax)
  File "/home/kalavatt/miniconda3/envs/hicexplorer_env/lib/python3.10/site-packages/matplotlib/cm.py", line 436, in _scale_norm
    raise ValueError(
ValueError: Passing a Normalize instance simultaneously with vmin/vmax is not supported.  Please pass vmin/vmax directly to the norm when creating it.

❯ echo "${CONDA_DEFAULT_ENV}"
hicexplorer_test_env_2

❯ hicPlotMatrix \
>     --chromosomeOrder I II III IV V VI VII VIII IX X XI XII XIII XIV XV XVI \
>     --colorMap "PuRd" \
>     --log \
>     --vMin 0.0001 \
>     --vMax 1 \
>     --matrix "${dir}/${cool}" \
>     --outFileName "test.pdf"
INFO:hicexplorer.hicPlotMatrix:Cooler or no cooler: True
INFO:hicexplorer.hicPlotMatrix:min: 2.0356669271154623e-05, max: 0.32483315613704933


Workaround

When installing hicexplorer via conda or mamba, explicitly specify an older version of matplotlib per the developer comment here: matplotlib >=3.1.1,<=3.2.2

Example installation call to avoid bug

mamba create \
    -n hicexplorer_test_env_2 \
    -c bioconda -c conda-forge \
        hicexplorer=3.7.2 \
        python=3.7 \
        matplotlib=3.2.2
joachimwolff commented 8 months ago

I published today a maintenance update version 3.7.3 which should fix this issue.