Help with error scanpy
1
0
Entering edit mode
5 months ago
Chris ▴ 260

Hi all,

I try to do annotation for single cell using scanpy and got this error that I didn't found on the internet:
Would you please have a suggestion? Code is adapt from https://github.com/bnsreenu/python_for_microscopists/blob/master/326_Cell_type_annotation_for_single_cell_RNA_seq_data%E2%80%8B.ipynb Thank you so much!

sc.pl.umap(adata)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [34], in <cell line: 1>()
----> 1 sc.pl.umap(adata)

File ~/.local/lib/python3.9/site-packages/scanpy/plotting/_tools/scatterplots.py:668, in umap(adata, **kwargs)
    609 @_wraps_plot_scatter
    610 @_doc_params(
    611     adata_color_etc=doc_adata_color_etc,
   (...)
    615 )
    616 def umap(adata, **kwargs) -> Union[Axes, List[Axes], None]:
    617     """\
    618     Scatter plot in UMAP basis.
    619 
   (...)
    666     tl.umap
    667     """
--> 668     return embedding(adata, 'umap', **kwargs)

File ~/.local/lib/python3.9/site-packages/scanpy/plotting/_tools/scatterplots.py:162, in embedding(adata, basis, color, gene_symbols, use_raw, sort_order, edges, edges_width, edges_color, neighbors_key, arrows, arrows_kwds, groups, components, dimensions, layer, projection, scale_factor, color_map, cmap, palette, na_color, na_in_legend, size, frameon, legend_fontsize, legend_fontweight, legend_loc, legend_fontoutline, colorbar_loc, vmax, vmin, vcenter, norm, add_outline, outline_width, outline_color, ncols, hspace, wspace, title, show, save, ax, return_fig, **kwargs)
    160     else:
    161         cmap = color_map
--> 162 cmap = copy(colormaps.get_cmap(cmap))
    163 cmap.set_bad(na_color)
    164 kwargs["cmap"] = cmap

AttributeError: 'ColormapRegistry' object has no attribute 'get_cmap'
scanpy • 1.9k views
ADD COMMENT
1
Entering edit mode

You probably need to do following again.

conda install -c conda-forge scanpy python-igraph leidenalg

If it does not work, you may need to install whole conda. See below-

https://discourse.scverse.org/t/error-when-draw-umap-object-has-no-attribute-get-cmap/1726/3

ADD REPLY
0
Entering edit mode

Seem this installation precess takes a long time. Still waiting. Thank you so much!

ADD REPLY
1
Entering edit mode

Switch to mamba. It's orders of magnitude faster.

ADD REPLY
4
Entering edit mode
5 months ago
Jorge ▴ 40

Hi,

I had the same issue, and I resolved it as follows:

  1. I replaced the problematic line in the ~/.local/lib/python3.8/site-packages/scanpy/plotting/_tools/scatterplots.py file (line 162) with the following code:

     cmap = copy(plt.cm.get_cmap(cmap))
    

    Since 'plt' was not loaded in the file, I added the following import statement at the top of the same file to import Matplotlib as 'plt':

     import matplotlib.pyplot as plt
    
  2. After making these changes, I saved the file.

  3. To apply the fix, I restarted my Jupyter Notebook or the Python environment where I was using Scanpy.

After following these steps, the issue was resolved, and my process executed correctly.

ADD COMMENT
0
Entering edit mode

It worked! Thank you so much!

ADD REPLY
0
Entering edit mode

Thank you for these steps!

ADD REPLY

Login before adding your answer.

Traffic: 1944 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6