aertslab / scenicplus

SCENIC+ is a python package to build gene regulatory networks (GRNs) using combined or separate single-cell gene expression (scRNA-seq) and single-cell chromatin accessibility (scATAC-seq) data.
Other
165 stars 27 forks source link

Plot_eRegulon error #268

Open MozzyCow opened 6 months ago

MozzyCow commented 6 months ago

When trying to plot use plot_eRegulon a matplotlib error is thrown "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." I have read elsewhere that this may be due to a matplotlib incompatibility. Running poot_AUC_gene_given_ax runs fine.

To Reproduce from scenicplus.dimensionality_reduction import plot_eRegulon plot_eRegulon( scplus_obj = scplus_obj, reduction_name = 'eRegulons_UMAP', selectedregulons = ['Ehf+'], scale = True, auc_key = 'eRegulon_AUC_filtered', save='Plot_test.pdf')

Error output

ValueError Traceback (most recent call last) Cell In[11], line 2 1 from scenicplus.dimensionality_reduction import plot_eRegulon ----> 2 plot_eRegulon( 3 scplus_obj = scplus_obj, 4 reduction_name = 'eRegulons_UMAP', 5 selectedregulons = ['Ehf+'], 6 scale = True, 7 auc_key = 'eRegulon_AUC_filtered', 8 save='Plot_test.pdf')

File /dmh/packages/scenic_plus/scenicplus/src/scenicplus/dimensionality_reduction.py:927, in plot_eRegulon(scplus_obj, reduction_name, auc_key, signature_keys, normalize_tf_expression, cmap, dot_size, alpha, scale, selected_regulons, selected_cells, figsize, num_columns, save) 925 scalarmappaple = cm.ScalarMappable(norm=normalize, cmap=cmap) 926 scalarmappaple.set_array(tf_expr) --> 927 plt.colorbar(scalarmappaple) 928 if num_columns == 1: 929 if save is not None:

File //lib/python3.9/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 //lib/python3.9/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.

most recent version of SCENIC+ 1.0.1.dev4+ge4bdd9f and Matplotlib 3.8.2

Thanks again.

twoneu commented 6 months ago

Downgrading to matplotlib==3.5.3 resolved this error for me, might be worth a shot!

MozzyCow commented 6 months ago

Hi, @twoneu this solves the lack of plotting for this function but generates a new error downstream for heatmap_dotplot(),

" ModuleNotFoundError: No module named 'matplotlib.layout_engine' "

based on the downgrading I believe this is due to the warning plotnine 0.12.4 requires matplotlib>=3.6.0 which is involved in these plots. Quick fix is to create to environments with different versions, but the dependencies for scenic plus may need to be updated.