# scanpy

**URL:** https://discourse.scverse.org/c/help/scanpy/37.md?page=2

[Latest](https://discourse.scverse.org/latest.md) · [Categories](https://discourse.scverse.org/categories.md) · [Tags](https://discourse.scverse.org/tags.md)

**Page:** 3

---

## [TCR and BCR genes and HVGs selection](https://discourse.scverse.org/t/tcr-and-bcr-genes-and-hvgs-selection/2139)

<div class="topic-metadata">

**Author:** [@pmarzano97](https://discourse.scverse.org/u/pmarzano97)\
**Replies:** 5\
**Last updated:** [April 3, 2024, 1:02am UTC](https://discourse.scverse.org/t/tcr-and-bcr-genes-and-hvgs-selection/2139 "2024-04-03T01:02:07Z")

</div>

Hello world! I’ve read in many papers that when performing a re-clustering of some populations, like T cells or B cells, prior to the step of integration and so on, they re-calculate the HVGs but excluding the TCR- or B…

---

## [Differential expression genes: test to use?](https://discourse.scverse.org/t/differential-expression-genes-test-to-use/2190)

<div class="topic-metadata">

**Author:** [@pmarzano97](https://discourse.scverse.org/u/pmarzano97)\
**Replies:** 0\
**Last updated:** [April 2, 2024, 7:19am UTC](https://discourse.scverse.org/t/differential-expression-genes-test-to-use/2190 "2024-04-02T07:19:30Z")

</div>

Hello! I have a question on the computation of differential expression genes with the scanpy function scanpy.tl.rank\_genes\_groups(). There is a way to understand which is the correct statistical test to use when comput…

---

## [Leiden clustering gives me different results when I run it](https://discourse.scverse.org/t/leiden-clustering-gives-me-different-results-when-i-run-it/2179)

<div class="topic-metadata">

**Author:** [@st4302](https://discourse.scverse.org/u/st4302)\
**Replies:** 1\
**Last updated:** [April 1, 2024, 9:14pm UTC](https://discourse.scverse.org/t/leiden-clustering-gives-me-different-results-when-i-run-it/2179 "2024-04-01T21:14:54Z")

</div>

Hello, I am analyzing some data using scanpy. I am following the following steps: QC, PCA, harmony integration, UMAP, leiden clustering, and finding the markers. However, every time I run the whole notebook I get diffe…

---

## [Does Scanpy stores raw count as int or float?](https://discourse.scverse.org/t/does-scanpy-stores-raw-count-as-int-or-float/2177)

<div class="topic-metadata">

**Author:** [@lwtan](https://discourse.scverse.org/u/lwtan)\
**Replies:** 1\
**Last updated:** [March 25, 2024, 8:30pm UTC](https://discourse.scverse.org/t/does-scanpy-stores-raw-count-as-int-or-float/2177 "2024-03-25T20:30:26Z")

</div>

Hi single-cell connoisseur, I am curious if the default type for AnnData raw object is float or int? For example: raw\_adata = adata.raw.to\_adata() raw\_adata.X Output: \<220752x29484 sparse matrix of type '\<class 'num…

---

## [Sc.pl.draw\_graph](https://discourse.scverse.org/t/sc-pl-draw-graph/2098)

<div class="topic-metadata">

**Author:** [@mariafahim](https://discourse.scverse.org/u/mariafahim)\
**Replies:** 1\
**Last updated:** [March 19, 2024, 4:51pm UTC](https://discourse.scverse.org/t/sc-pl-draw-graph/2098 "2024-03-19T16:51:02Z")

</div>

Hello, I keep getting this error when trying to visualize some marker genes (I am using a preprocessing pipeline for scanpy to prepare my data for another program). Any help would be appreciated!

---

## [Normalized data found instead of raw counts](https://discourse.scverse.org/t/normalized-data-found-instead-of-raw-counts/2163)

<div class="topic-metadata">

**Author:** [@f6v](https://discourse.scverse.org/u/f6v)\
**Replies:** 2\
**Last updated:** [March 18, 2024, 10:46am UTC](https://discourse.scverse.org/t/normalized-data-found-instead-of-raw-counts/2163 "2024-03-18T10:46:24Z")

</div>

I’m running a scRNA-seq scVI workflow and getting warnings saying that non-integers were found in the AnnData: adata.layers\['counts'\] = adata.X.copy() sc.pp.normalize\_total(adata, target\_sum=1e4) sc.pp.log1p(adata) adat…

---

## [Sc.pl.draw\_graph is strongly affected by the outliers](https://discourse.scverse.org/t/sc-pl-draw-graph-is-strongly-affected-by-the-outliers/2167)

<div class="topic-metadata">

**Author:** [@chansigit](https://discourse.scverse.org/u/chansigit)\
**Replies:** 0\
**Last updated:** [March 18, 2024, 4:46am UTC](https://discourse.scverse.org/t/sc-pl-draw-graph-is-strongly-affected-by-the-outliers/2167 "2024-03-18T04:46:25Z")

</div>

I am visualizing graphs but my points are strongly affected by the outliers. how can i alleviate the outliers’ impacts? i dont’ want the data crouched in the center. are theire any parameters that can dismiss these out…

---

## [How to reuse cmap for other plots?](https://discourse.scverse.org/t/how-to-reuse-cmap-for-other-plots/2147)

<div class="topic-metadata">

**Author:** [@chem1kal](https://discourse.scverse.org/u/chem1kal)\
**Replies:** 3\
**Last updated:** [March 9, 2024, 5:01am UTC](https://discourse.scverse.org/t/how-to-reuse-cmap-for-other-plots/2147 "2024-03-09T05:01:41Z")

</div>

I have used scanpy to create UMAP figures through this line of code: sc.pl.umap(adata1, color = \[‘cell\_type’\], frameon = False, legend\_loc = “right margin”) However, I am trying to create a stacked bar chart showing pr…

---

## [How to get dot values from \`sc.pl.dotplot()\`?](https://discourse.scverse.org/t/how-to-get-dot-values-from-sc-pl-dotplot/2116)

<div class="topic-metadata">

**Author:** [@jdime](https://discourse.scverse.org/u/jdime)\
**Replies:** 1\
**Last updated:** [March 1, 2024, 3:44pm UTC](https://discourse.scverse.org/t/how-to-get-dot-values-from-sc-pl-dotplot/2116 "2024-03-01T15:44:36Z")

</div>

Hello, I’m using the sc.pl.dotplot function to draw dotplots, and I’m interested to get the fraction of cells and mean expression values for each dot. If I assign the function call output to a variable dp, I can see so…

---

## [Remove genes from highly variable genes](https://discourse.scverse.org/t/remove-genes-from-highly-variable-genes/2085)

<div class="topic-metadata">

**Author:** [@malonzm1](https://discourse.scverse.org/u/malonzm1)\
**Replies:** 1\
**Last updated:** [February 21, 2024, 4:09pm UTC](https://discourse.scverse.org/t/remove-genes-from-highly-variable-genes/2085 "2024-02-21T16:09:46Z")

</div>

Hi, I would like to remove certain genes from my list of highly variable genes generated from sc.pp.highly\_variable\_genes. Is it enough to assign adata.var.highly\_variable\[gene\] = False? Or is there some other way? Tha…

---

## [Converting tab-delimited files to adata in a memory-efficient way](https://discourse.scverse.org/t/converting-tab-delimited-files-to-adata-in-a-memory-efficient-way/2083)

<div class="topic-metadata">

**Author:** [@jorvis](https://discourse.scverse.org/u/jorvis)\
**Replies:** 3\
**Last updated:** [February 21, 2024, 2:22pm UTC](https://discourse.scverse.org/t/converting-tab-delimited-files-to-adata-in-a-memory-efficient-way/2083 "2024-02-21T14:22:57Z")

</div>

We are processing matrix files with 30k+ rows and 700k+ columns, and the approach of converting like this can take 20+ hours and 500GB+ of RAM to create the h5ad file: adata = sc.read('expression.tab', first\_column\_name…

---

## [ModuleNotFoundErrror: no module named "importlib.metadata"](https://discourse.scverse.org/t/modulenotfounderrror-no-module-named-importlib-metadata/2095)

<div class="topic-metadata">

**Author:** [@mariafahim](https://discourse.scverse.org/u/mariafahim)\
**Replies:** 4\
**Last updated:** [February 15, 2024, 8:25pm UTC](https://discourse.scverse.org/t/modulenotfounderrror-no-module-named-importlib-metadata/2095 "2024-02-15T20:25:49Z")

</div>

hello! I’m a not very experienced user trying to analyze my sc data in scanpy. I’ve ran into this error just now when trying to run sc.tl.umap(adata) ModuleNotFoundErrror: no module named “importlib.metadata” I have i…

---

## [Error with cyclone \['DataFrame' object has no attribute 'iteritems' \]](https://discourse.scverse.org/t/error-with-cyclone-dataframe-object-has-no-attribute-iteritems/2079)

<div class="topic-metadata">

**Author:** [@Marwansha](https://discourse.scverse.org/u/Marwansha)\
**Replies:** 0\
**Last updated:** [February 12, 2024, 1:08pm UTC](https://discourse.scverse.org/t/error-with-cyclone-dataframe-object-has-no-attribute-iteritems/2079 "2024-02-12T13:08:02Z")

</div>

i am trying to use cycline for cell cycle phase assignment and i am running into this error \[\> from scanpy.external.tl import sandbag \> from pypairs import datasets \> y = datasets.leng15() \> marker\_pairs = sandbag(y, …

---

## [Plots shifted when using scanpy in R markdown](https://discourse.scverse.org/t/plots-shifted-when-using-scanpy-in-r-markdown/2044)

<div class="topic-metadata">

**Author:** [@mlebel](https://discourse.scverse.org/u/mlebel)\
**Replies:** 0\
**Last updated:** [February 1, 2024, 2:12pm UTC](https://discourse.scverse.org/t/plots-shifted-when-using-scanpy-in-r-markdown/2044 "2024-02-01T14:12:13Z")

</div>

Hello, I’m new to the scverse, and I’ve been doing my analysis primarily using R-based packages. I’ve started branching out a bit to Python to be able to use scverse tools, and for ease of work, I wanted to group my ana…

---

## [Trying to read custom genome using sc.read\_10x\_h5](https://discourse.scverse.org/t/trying-to-read-custom-genome-using-sc-read-10x-h5/2029)

<div class="topic-metadata">

**Author:** [@mgelm](https://discourse.scverse.org/u/mgelm)\
**Replies:** 0\
**Last updated:** [January 26, 2024, 12:51pm UTC](https://discourse.scverse.org/t/trying-to-read-custom-genome-using-sc-read-10x-h5/2029 "2024-01-26T12:51:51Z")

</div>

Hello! I’m having trouble reading my .h5 files to a 10x mm10 Custom Genome containing LacZ. When I run this file in Seurat it picks up the LacZ gene but in scanpy the gene seems to be missing. I tried to run the convert…

---

## [Heatmap cannot be assigned as a subplot](https://discourse.scverse.org/t/heatmap-cannot-be-assigned-as-a-subplot/1996)

<div class="topic-metadata">

**Author:** [@Matthias](https://discourse.scverse.org/u/Matthias)\
**Replies:** 1\
**Last updated:** [January 16, 2024, 12:59am UTC](https://discourse.scverse.org/t/heatmap-cannot-be-assigned-as-a-subplot/1996 "2024-01-16T00:59:21Z")

</div>

Hi, as per the documentation, it is possible to assign plots created by scanpy to matplotlib subplots. However, this does not work for heatmaps, since they internally use multiple axes to construct the plot. This minima…

---

## [Umap shapes different for the same dataset](https://discourse.scverse.org/t/umap-shapes-different-for-the-same-dataset/2004)

<div class="topic-metadata">

**Author:** [@malonzm1](https://discourse.scverse.org/u/malonzm1)\
**Replies:** 1\
**Last updated:** [January 15, 2024, 9:48am UTC](https://discourse.scverse.org/t/umap-shapes-different-for-the-same-dataset/2004 "2024-01-15T09:48:53Z")

</div>

Hi, I generated two umaps using the same dataset but with one I first plotted background cells (in gray) before the cells of interest. The shapes of the two umaps are different. The code for the regular umap: sc.pp.hi…

---

## [Mismatch between MAST DE results and dotplot](https://discourse.scverse.org/t/mismatch-between-mast-de-results-and-dotplot/1989)

<div class="topic-metadata">

**Author:** [@Simon](https://discourse.scverse.org/u/Simon)\
**Replies:** 0\
**Last updated:** [January 9, 2024, 10:21am UTC](https://discourse.scverse.org/t/mismatch-between-mast-de-results-and-dotplot/1989 "2024-01-09T10:21:56Z")

</div>

Dear community, I found that a gene that has only a small fold-change between two conditions based on MAST, conversely appears to have a large difference if plotted in a dotplot: MAST results: gene log2FC pct.1 …

---

## [Pl.dotplot : legend(mean expression in group) number is so large](https://discourse.scverse.org/t/pl-dotplot-legend-mean-expression-in-group-number-is-so-large/1473)

<div class="topic-metadata">

**Author:** [@jinyuanchun](https://discourse.scverse.org/u/jinyuanchun)\
**Replies:** 1\
**Last updated:** [January 9, 2024, 10:02am UTC](https://discourse.scverse.org/t/pl-dotplot-legend-mean-expression-in-group-number-is-so-large/1473 "2024-01-09T10:02:17Z")

</div>

2 i use pl.dotplot for drawing. I’m puzzled why the numbers are so large

---

## [Option to plot separate umaps for concatenated datasets](https://discourse.scverse.org/t/option-to-plot-separate-umaps-for-concatenated-datasets/1955)

<div class="topic-metadata">

**Author:** [@ishwarvh](https://discourse.scverse.org/u/ishwarvh)\
**Replies:** 4\
**Last updated:** [December 27, 2023, 5:49pm UTC](https://discourse.scverse.org/t/option-to-plot-separate-umaps-for-concatenated-datasets/1955 "2023-12-27T17:49:06Z")

</div>

Is there an option/argument that can be passed to sc.pl.umap to plot separate UMAPs based on a categorical variable i.e. batch,sample etc. Something like the “split.by” argument in Seurat. Thank you, Ishwar

---

## [Weird oval umap cluster](https://discourse.scverse.org/t/weird-oval-umap-cluster/1969)

<div class="topic-metadata">

**Author:** [@malonzm1](https://discourse.scverse.org/u/malonzm1)\
**Replies:** 0\
**Last updated:** [December 25, 2023, 12:46am UTC](https://discourse.scverse.org/t/weird-oval-umap-cluster/1969 "2023-12-25T00:46:08Z")

</div>

Hi, I generated a umap of scRNAseq data from various GSE studies. One cluster is odd because it’s almost a perfect oval (cluster #2). It consists of 12 GSE studies. Any thoughts on what is causing this shape? Good d…

---

## [Differential gene expression - normalize gene values?](https://discourse.scverse.org/t/differential-gene-expression-normalize-gene-values/1944)

<div class="topic-metadata">

**Author:** [@mmvicente](https://discourse.scverse.org/u/mmvicente)\
**Replies:** 0\
**Last updated:** [December 6, 2023, 9:47am UTC](https://discourse.scverse.org/t/differential-gene-expression-normalize-gene-values/1944 "2023-12-06T09:47:10Z")

</div>

Hi all, I am running scanpy…tl.rank\_genes\_groups() to perform DGE between two cell clusters. My question is whether I should normalize the gene values per cell or can I run it with non-normalized values? The two approa…

---

## [Error when saving adata with adata.write\_h5ad(): "Above error raised while writing key 'names' of to /"](https://discourse.scverse.org/t/error-when-saving-adata-with-adata-write-h5ad-above-error-raised-while-writing-key-names-of-to/1737)

<div class="topic-metadata">

**Author:** [@hmnzo5gy](https://discourse.scverse.org/u/hmnzo5gy)\
**Replies:** 2\
**Last updated:** [December 3, 2023, 3:28am UTC](https://discourse.scverse.org/t/error-when-saving-adata-with-adata-write-h5ad-above-error-raised-while-writing-key-names-of-to/1737 "2023-12-03T03:28:38Z")

</div>

When I am trying to save anndata with adata.write\_h5ad(), I am encountering the following error: --------------------------------------------------------------------------- TypeError Trac…

---

## [UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored](https://discourse.scverse.org/t/userwarning-no-data-for-colormapping-provided-via-c-parameters-cmap-will-be-ignored/1221)

<div class="topic-metadata">

**Author:** [@DRSEI](https://discourse.scverse.org/u/DRSEI)\
**Replies:** 8\
**Last updated:** [December 1, 2023, 4:36pm UTC](https://discourse.scverse.org/t/userwarning-no-data-for-colormapping-provided-via-c-parameters-cmap-will-be-ignored/1221 "2023-12-01T16:36:21Z")

</div>

Hello, I am experiencing an issue with my UMAP plots in Scanpy. When trying to plot my data, the process takes over 20 minutes and does not produce any output. I have updated my Scanpy to the latest version and re-insta…

---

## [Methods of calculating graphs](https://discourse.scverse.org/t/methods-of-calculating-graphs/1870)

<div class="topic-metadata">

**Author:** [@AlSzmigiel](https://discourse.scverse.org/u/AlSzmigiel)\
**Replies:** 0\
**Last updated:** [November 9, 2023, 10:40am UTC](https://discourse.scverse.org/t/methods-of-calculating-graphs/1870 "2023-11-09T10:40:20Z")

</div>

As far as I understand, there are three possibilities to calculate a graph in scanpy. We can go with the UMAP method along with knn=True and with the Gauss method with knn=True and knn=False. I’m getting a bit lost in …

---

## [Scanpy equivalent of Seurat's FindConservedMarkers](https://discourse.scverse.org/t/scanpy-equivalent-of-seurats-findconservedmarkers/1864)

<div class="topic-metadata">

**Author:** [@mgelm](https://discourse.scverse.org/u/mgelm)\
**Replies:** 0\
**Last updated:** [November 8, 2023, 3:03pm UTC](https://discourse.scverse.org/t/scanpy-equivalent-of-seurats-findconservedmarkers/1864 "2023-11-08T15:03:48Z")

</div>

Hello, I wanted to know if there is a function or code which would replicate Seurat’s FindConservedMarkers in scanpy to identify conserved genes across two clusters or objects. Any help will be greatly appreciated! Th…

---

## [Correlation matrix values](https://discourse.scverse.org/t/correlation-matrix-values/1860)

<div class="topic-metadata">

**Author:** [@pmarzano97](https://discourse.scverse.org/u/pmarzano97)\
**Replies:** 0\
**Last updated:** [November 8, 2023, 8:47am UTC](https://discourse.scverse.org/t/correlation-matrix-values/1860 "2023-11-08T08:47:40Z")

</div>

Hello world! I’m using the scanpy function to make correlation matrixes (sc.pl.correlation\_matrix() funciton) and I was wondering if there could be the possibility to extract the values from this correlation matrix. And…

---

## [Reading matrix.mtx with "real" number format](https://discourse.scverse.org/t/reading-matrix-mtx-with-real-number-format/1842)

<div class="topic-metadata">

**Author:** [@seagrowler](https://discourse.scverse.org/u/seagrowler)\
**Replies:** 0\
**Last updated:** [October 29, 2023, 7:47pm UTC](https://discourse.scverse.org/t/reading-matrix-mtx-with-real-number-format/1842 "2023-10-29T19:47:22Z")

</div>

Hello, I am trying to read the matrix.mtx.gz into an anndata (anndata-0.10.2) object using scanpy (scanpy-1.9.5). The matrix.mtx has the following header - %%MatrixMarket matrix coordinate real general 60319 2636 1060…

---

## [Contour Plot based on gene expression or score](https://discourse.scverse.org/t/contour-plot-based-on-gene-expression-or-score/1836)

<div class="topic-metadata">

**Author:** [@dub2s](https://discourse.scverse.org/u/dub2s)\
**Replies:** 0\
**Last updated:** [October 26, 2023, 3:21pm UTC](https://discourse.scverse.org/t/contour-plot-based-on-gene-expression-or-score/1836 "2023-10-26T15:21:13Z")

</div>

Hii I am trying to replicate contour plots depicting expression of a gene over UMAP such as this : Source Publication : https://www.sciencedirect.com/science/article/pii/S1074761320303587?via%3Dihub I tried getting…

---

## [How to show the cells on my umap projection based on barcodes](https://discourse.scverse.org/t/how-to-show-the-cells-on-my-umap-projection-based-on-barcodes/1798)

<div class="topic-metadata">

**Author:** [@zochzh](https://discourse.scverse.org/u/zochzh)\
**Replies:** 2\
**Last updated:** [October 12, 2023, 2:22am UTC](https://discourse.scverse.org/t/how-to-show-the-cells-on-my-umap-projection-based-on-barcodes/1798 "2023-10-12T02:22:31Z")

</div>

Thank you for the tool your team developed. I want to show the cells on my umap projection based on barcodes. I see you’ve shared similar code before. https://github.com/scverse/scanpy/issues/946 adata.obs\[‘filtered\_…

[Previous page](https://discourse.scverse.org/c/help/scanpy/37.md?page=1)

[Next page](https://discourse.scverse.org/c/help/scanpy/37.md?page=3)
