I tried umap visualization with scanpy :

sc.pp.normalize_total(adata, target_sum=1e6)
sc.pp.log1p(adata, base=2)
sc.pp.highly_variable_genes(adata, flavor='cell_ranger', n_top_genes=400)

sc.pp.scale(adata, zero_center=True, max_value=None, copy=False, layer=None, obsm=None)
sc.pp.pca(adata, n_comps=50, use_highly_variable=True, svd_solver='arpack')
sc.pp.neighbors(adata, n_neighbors=50)

sc.tl.umap(adata, min_dist=0.5, spread=1.0)
sc.pl.umap(adata, color='fullname', use_raw=False, save='samples_umap.pdf')


anndata     0.7.5
scanpy      1.6.1

But the cells can't separate well image

I tried another small dataset with scanpy using the same parameters as before: 1

sc.tl.umap still failed to down dimension the data properly.

Then I tried the original umap package using the same data set:

import umap
import umap.plot
mapper = umap.UMAP().fit(adata.X)

Now the original umap package can do down dimension very well: 2

I think there may be something wrong with the umap function in scanpy Can anyone please let me know the reason? Thanks a lot.


1 Answer 1


Without more code and data, this can't be debugged. But first question would be does the data pass basic QC (e.g. look at cellranger web summaries or equivalent). If yes, you could trying different normalisation (code not shown) and/or no scaling. Try sc.tl.umap() with default params. Plot the PCA, try t-SNE. Plot the basic QC metrics following the introductory scanpy tutorial. That is how I would start debugging

  • $\begingroup$ I compare the umap in scanpy with the original umap (umap-learn.readthedocs.io/en/latest/plotting.html) using the same dataset, the original umap works well, I think the problem is in scanpy. I edited my question to include this. Do you have some suggestions? Thanks $\endgroup$
    – Dan Li
    Commented Dec 23, 2022 at 18:39
  • $\begingroup$ @DanLi It might be this: github.com/scverse/scanpy/issues/2045 or related. Try with the latest scanpy version and consider reporting to scanpy github if not already reported $\endgroup$ Commented Dec 24, 2022 at 22:53
  • $\begingroup$ Yes, thanks. @Chris_Rands $\endgroup$
    – Dan Li
    Commented Dec 27, 2022 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.