Answers.Body: <p>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 <code>sc.tl.umap()</code> 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</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-23T18:39:57.590Z
Answers.Text: I compare the `umap` in `scanpy` with the original [`umap`](https://umap-learn.readthedocs.io/en/latest/plotting.html) (https://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
Answers.UserDisplayName: Dan Li
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-24T22:53:49.990Z
Answers.Text: @DanLi It might be this: https://github.com/scverse/scanpy/issues/2045 or related. Try with the latest scanpy version and consider reporting to scanpy github if not already reported
Answers.UserDisplayName: Chris_Rands
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-27T13:49:29.363Z
Answers.Text: Yes, thanks. @Chris_Rands
Answers.UserDisplayName: Dan Li
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-23T17:03:02.753Z
Answers.LastActivityDate: 2022-12-23T17:03:02.753Z
Answers.UserDisplayName: Chris_Rands
Body: <p>I tried umap visualization with <a href="https://github.com/scverse/scanpy" rel="nofollow noreferrer"><code>scanpy</code></a> :</p>
  <pre><code>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')
  </code></pre>
  <p>version</p>
  <pre><code>anndata     0.7.5
  scanpy      1.6.1
  </code></pre>
  <p>But the cells can't separate well
  <img src="https://user-images.githubusercontent.com/33963919/209233854-db64fddd-4266-4f87-805b-dced45b1547f.png" alt="image" /></p>
  <p>I tried another small dataset with <code>scanpy</code> using the same parameters as before:
  <img src="https://user-images.githubusercontent.com/33963919/209387824-3a5b1037-f226-49c8-9222-f54c04a62155.jpg" alt="1" /></p>
  <p><code>sc.tl.umap</code> still failed to down dimension the data properly.</p>
  <p>Then I tried the original <a href="https://umap-learn.readthedocs.io/en/latest/plotting.html" rel="nofollow noreferrer"><code>umap</code> package</a> using the same data set:</p>
  <pre><code>import umap
  import umap.plot
  mapper = umap.UMAP().fit(adata.X)
  umap.plot.points(mapper)
  </code></pre>
  <p>Now the original <code>umap</code> package can do down dimension very well:
  <img src="https://user-images.githubusercontent.com/33963919/209387903-0161dfa6-0ca5-48cc-8661-465930e23fef.jpg" alt="2" /></p>
  <p>I think there may be something wrong with the <code>umap</code> function in <code>scanpy</code>
  Can anyone please let me know the reason?
  Thanks a lot.</p>
  
Tags: <scrnaseq><single-cell><umap>
Title: umap failed to cluster the cells
ThreadText: # umap failed to cluster the cells
  
  (Asked by: username_0 on 2022-12-22)
  
  I tried umap visualization with [`scanpy`](https://github.com/scverse/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')
  
  ```
  
  version
  
  ```
  anndata     0.7.5
  scanpy      1.6.1
  
  ```
  
  But the cells can't separate well
  ![image](https://user-images.githubusercontent.com/33963919/209233854-db64fddd-4266-4f87-805b-dced45b1547f.png)
  
  I tried another small dataset with `scanpy` using the same parameters as before:
  ![1](https://user-images.githubusercontent.com/33963919/209387824-3a5b1037-f226-49c8-9222-f54c04a62155.jpg)
  
  `sc.tl.umap` still failed to down dimension the data properly.
  
  Then I tried the original [`umap` package](https://umap-learn.readthedocs.io/en/latest/plotting.html) using the same data set:
  
  ```
  import umap
  import umap.plot
  mapper = umap.UMAP().fit(adata.X)
  umap.plot.points(mapper)
  
  ```
  
  Now the original `umap` package can do down dimension very well:
  ![2](https://user-images.githubusercontent.com/33963919/209387903-0161dfa6-0ca5-48cc-8661-465930e23fef.jpg)
  
  I think there may be something wrong with the `umap` function in `scanpy`
  Can anyone please let me know the reason?
  Thanks a lot.
  
  **Tags:** scrnaseq, single-cell, umap
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-12-23. Score: 2 | Accepted answer
  
  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
  
  > **Comments:**
  > **username_0**: I compare the `umap` in `scanpy` with the original [`umap`](https://umap-learn.readthedocs.io/en/latest/plotting.html) (https://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  
  > **username_1**: @username_0 It might be this: https://github.com/scverse/scanpy/issues/2045 or related. Try with the latest scanpy version and consider reporting to scanpy github if not already reported  
  > **username_0**: Yes, thanks. @username_1  
  
  ---
  
  