aertslab / pycisTopic

pycisTopic is a Python module to simultaneously identify cell states and cis-regulatory topics from single cell epigenomics data.
Other
58 stars 12 forks source link

Error when running plot_topic() - `Unable to determine Axes to steal space for Colorbar` #99

Open solvi808 opened 1 year ago

solvi808 commented 1 year ago

Describe the bug I am running the standard vignette provided in the SCENIC plus tutorial, in jupyter notebook

When I am running plot_topic I get the error ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the *cax* argument to use as the Axes for the Colorbar, provide the *ax* argument to steal space from it, or add *mappable* to an Axes.

This similar error seems to be related to issues with matplotlib and was described , https://github.com/shap/shap/issues/2721

It was recommend to install matplotlib version 3.6 but this isnt fixing it in my case

To Reproduce

plot_topic(cistopic_obj, reduction_name = 'UMAP', num_columns=5 )

Error output

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[16], line 1
----> 1 plot_topic(cistopic_obj, reduction_name = 'UMAP', num_columns=5 )

File ~/CORE/VENV/venv_pycisTopic/lib/python3.10/site-packages/pycisTopic/clust_vis.py:728, in plot_topic(cistopic_obj, reduction_name, target, cmap, dot_size, alpha, scale, selected_topics, selected_features, harmony, figsize, num_columns, save)
    726 scalarmappaple = cm.ScalarMappable(norm=normalize, cmap=cmap)
    727 scalarmappaple.set_array(var_data)
--> 728 plt.colorbar(scalarmappaple)
    729 if num_columns == 1:
    730     if save is not None:

File ~/CORE/VENV/venv_pycisTopic/lib/python3.10/site-packages/matplotlib/pyplot.py:2326, in colorbar(mappable, cax, ax, **kwargs)
   2321     if mappable is None:
   2322         raise RuntimeError('No mappable was found to use for colorbar '
   2323                            'creation. First define a mappable such as '
   2324                            'an image (with imshow) or a contour set ('
   2325                            'with contourf).')
-> 2326 ret = gcf().colorbar(mappable, cax=cax, ax=ax, **kwargs)
   2327 return ret

File ~/CORE/VENV/venv_pycisTopic/lib/python3.10/site-packages/matplotlib/figure.py:1285, in FigureBase.colorbar(self, mappable, cax, ax, use_gridspec, **kwargs)
   1283 if cax is None:
   1284     if ax is None:
-> 1285         raise ValueError(
   1286             'Unable to determine Axes to steal space for Colorbar. '
   1287             'Either provide the *cax* argument to use as the Axes for '
   1288             'the Colorbar, provide the *ax* argument to steal space '
   1289             'from it, or add *mappable* to an Axes.')
   1290     fig = (  # Figure of first axes; logic copied from make_axes.
   1291         [*ax.flat] if isinstance(ax, np.ndarray)
   1292         else [*ax] if np.iterable(ax)
   1293         else [ax])[0].figure
   1294     current_ax = fig.gca()

ValueError: Unable to determine Axes to steal space for Colorbar. Either provide the *cax* argument to use as the Axes for the Colorbar, provide the *ax* argument to steal space from it, or add *mappable* to an Axes.

python environment

VENVPATH="./VENV/venv_pycisTopic"

python3.10 -m venv $VENVPATH 
source $VENVPATH/bin/activate 

pip install -U pip wheel setuptools 
pip install -U pip numba matplotlib numpy 
pip install lda 
pip install pyrle 

pip install jupyter

git clone https://github.com/aertslab/pycisTopic.git
cd pycisTopic
pip install .

Versions: Python 3.10.5 pycisTopic 1.0.3.dev18+ge563fb6 pyscenic 0.12.1+6.g31d51a1 matplotlib 3.8.0 jupyter 1.0.0 jupyterlab 4.0.6