# scanpy

**URL:** https://discourse.scverse.org/c/help/scanpy/37.md

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

---

## [About the scanpy category](https://discourse.scverse.org/t/about-the-scanpy-category/331)

<div class="topic-metadata">

**Author:** [@adamgayoso](https://discourse.scverse.org/u/adamgayoso)\
**Replies:** 0

</div>

For questions about using scanpy.

---

## [Confused by percent\_top purpose in scanpy.pp.calculate\_qc\_metrics](https://discourse.scverse.org/t/confused-by-percent-top-purpose-in-scanpy-pp-calculate-qc-metrics/4032)

<div class="topic-metadata">

**Author:** [@anjpad](https://discourse.scverse.org/u/anjpad)\
**Replies:** 2\
**Last updated:** [August 19, 2026, 12:35pm UTC](https://discourse.scverse.org/t/confused-by-percent-top-purpose-in-scanpy-pp-calculate-qc-metrics/4032 "2026-08-19T12:35:03Z")

</div>

Hi! As I am a beginner at utilizing scanpy, I would like for someone to better help me understand the purpose of percent\_top when calculating qc metrics. How can adding a percent\_top argument change my preprocessing vs. …

---

## [Sc.pl.rank\_genes\_groups\_heatmap - saving figure to file](https://discourse.scverse.org/t/sc-pl-rank-genes-groups-heatmap-saving-figure-to-file/3925)

<div class="topic-metadata">

**Author:** [@kevinrue](https://discourse.scverse.org/u/kevinrue)\
**Replies:** 1\
**Last updated:** [March 13, 2026, 3:02pm UTC](https://discourse.scverse.org/t/sc-pl-rank-genes-groups-heatmap-saving-figure-to-file/3925 "2026-03-13T15:02:59Z")

</div>

The sc.pl.rank\_genes\_groups\_heatmap() documentation states that save= is “deprecated in favour of sc.pl.plot(show=False).figure.savefig()“ I’ve tried adapting the example code in the documentation to my interpretation o…

---

## [Interpretting differential gene expression dotplot](https://discourse.scverse.org/t/interpretting-differential-gene-expression-dotplot/3923)

<div class="topic-metadata">

**Author:** [@smartinez](https://discourse.scverse.org/u/smartinez)\
**Replies:** 0\
**Last updated:** [January 23, 2026, 5:17pm UTC](https://discourse.scverse.org/t/interpretting-differential-gene-expression-dotplot/3923 "2026-01-23T17:17:10Z")

</div>

I am going through scanpy tutorials for the first time and don’t understand how to interpret parts of the differential gene expression dotplot of logfoldchange from their plotting tutorial (I did not generate this, it’s …

---

## [When to use the batch\_key in highly\_variable\_genes()](https://discourse.scverse.org/t/when-to-use-the-batch-key-in-highly-variable-genes/3922)

<div class="topic-metadata">

**Author:** [@BiggusDikkusMaximus](https://discourse.scverse.org/u/BiggusDikkusMaximus)\
**Replies:** 0\
**Last updated:** [January 21, 2026, 11:44am UTC](https://discourse.scverse.org/t/when-to-use-the-batch-key-in-highly-variable-genes/3922 "2026-01-21T11:44:22Z")

</div>

Hello, I was reading the readdocs for highly\_variable\_genes() and i was wondering when to use the batch\_key when performing sc Analysis.

---

## [Remove ribosomal genes driving variation (on PC plot)?](https://discourse.scverse.org/t/remove-ribosomal-genes-driving-variation-on-pc-plot/3902)

<div class="topic-metadata">

**Author:** [@npont](https://discourse.scverse.org/u/npont)\
**Replies:** 0\
**Last updated:** [December 17, 2025, 10:19am UTC](https://discourse.scverse.org/t/remove-ribosomal-genes-driving-variation-on-pc-plot/3902 "2025-12-17T10:19:59Z")

</div>

Hi all, Following the tutorial of scanpy about clustering ( Preprocessing and clustering — scanpy ), I plotted some QC metrics (computed with sc.pp.calculate\_qc\_metrics(adata, qc\_vars=\[“mt”, “ribo”\])) on the first four …

---

## [Sc.pp.filter\_genes how to use](https://discourse.scverse.org/t/sc-pp-filter-genes-how-to-use/3901)

<div class="topic-metadata">

**Author:** [@baicai](https://discourse.scverse.org/u/baicai)\
**Replies:** 0\
**Last updated:** [December 16, 2025, 6:41am UTC](https://discourse.scverse.org/t/sc-pp-filter-genes-how-to-use/3901 "2025-12-16T06:41:06Z")

</div>

I would like to ask for clarification regarding the recommended order of sc.pp.filter\_genes and sc.pp.normalize\_total, and the intended interpretation of their interaction. It is clear that filtering genes (e.g. min\_c…

---

## [What is the context or history of having both inplace and copy args everywhere?](https://discourse.scverse.org/t/what-is-the-context-or-history-of-having-both-inplace-and-copy-args-everywhere/3900)

<div class="topic-metadata">

**Author:** [@patcon](https://discourse.scverse.org/u/patcon)\
**Replies:** 1\
**Last updated:** [December 15, 2025, 9:49pm UTC](https://discourse.scverse.org/t/what-is-the-context-or-history-of-having-both-inplace-and-copy-args-everywhere/3900 "2025-12-15T21:49:42Z")

</div>

First off, thanks for this wonderful tool! I left open science back in 2008, took a round-about tour into tech, and am now coming back. I’m feeling very energized while exploring it :slight\_smile: I’m trying to extend s…

---

## [Draw\_graph results in a cloud or nice PAGA-like structure depending on dataset?](https://discourse.scverse.org/t/draw-graph-results-in-a-cloud-or-nice-paga-like-structure-depending-on-dataset/3891)

<div class="topic-metadata">

**Author:** [@Miglio](https://discourse.scverse.org/u/Miglio)\
**Replies:** 0\
**Last updated:** [December 4, 2025, 6:10pm UTC](https://discourse.scverse.org/t/draw-graph-results-in-a-cloud-or-nice-paga-like-structure-depending-on-dataset/3891 "2025-12-04T18:10:41Z")

</div>

Hello, I turned to scanpy to analyze metacells datasets and I am intrigued by the draw\_graph to show data toppology, potentially with PAGA or MST. For one of my datasets it worked beautifully with the metacell clusters …

---

## [Sc.tl.ingest over representing rare cell types in spatial transcriptomics data](https://discourse.scverse.org/t/sc-tl-ingest-over-representing-rare-cell-types-in-spatial-transcriptomics-data/3868)

<div class="topic-metadata">

**Author:** [@spatts14](https://discourse.scverse.org/u/spatts14)\
**Replies:** 0\
**Last updated:** [November 18, 2025, 8:46am UTC](https://discourse.scverse.org/t/sc-tl-ingest-over-representing-rare-cell-types-in-spatial-transcriptomics-data/3868 "2025-11-18T08:46:43Z")

</div>

I am trying to use sc.tl.ingest to predict cell types for my Xenium 5k spatial transcriptomics data. I have subsetted the reference dataset to only contain the disease types and tissue types that are present in my STx d…

---

## [Impact of scaling on clustering results and controlling minimum cluster size in Leiden clustering](https://discourse.scverse.org/t/impact-of-scaling-on-clustering-results-and-controlling-minimum-cluster-size-in-leiden-clustering/3849)

<div class="topic-metadata">

**Author:** [@asmlgkj](https://discourse.scverse.org/u/asmlgkj)\
**Replies:** 1\
**Last updated:** [November 10, 2025, 9:19am UTC](https://discourse.scverse.org/t/impact-of-scaling-on-clustering-results-and-controlling-minimum-cluster-size-in-leiden-clustering/3849 "2025-11-10T09:19:14Z")

</div>

Description Hi scanpy team, I’ve encountered two related issues with clustering that I’d like to understand better: Issue 1: Dramatic difference in cluster numbers with/without scaling I’m observing a significant dis…

---

## [How should I process the data after removing low-quality cell clusters?](https://discourse.scverse.org/t/how-should-i-process-the-data-after-removing-low-quality-cell-clusters/3855)

<div class="topic-metadata">

**Author:** [@XJY](https://discourse.scverse.org/u/XJY)\
**Replies:** 0\
**Last updated:** [November 9, 2025, 7:00pm UTC](https://discourse.scverse.org/t/how-should-i-process-the-data-after-removing-low-quality-cell-clusters/3855 "2025-11-09T19:00:40Z")

</div>

I have already completed the standard single-cell analysis workflow, but I found that one cluster consisted of low-quality cells. I want to remove this cluster, and an AI suggested that I should rerun the preprocessing …

---

## [Rank\_genes\_groups expects log data but default to adata.raw, why?](https://discourse.scverse.org/t/rank-genes-groups-expects-log-data-but-default-to-adata-raw-why/3852)

<div class="topic-metadata">

**Author:** [@luguna](https://discourse.scverse.org/u/luguna)\
**Replies:** 0\
**Last updated:** [November 7, 2025, 5:19pm UTC](https://discourse.scverse.org/t/rank-genes-groups-expects-log-data-but-default-to-adata-raw-why/3852 "2025-11-07T17:19:40Z")

</div>

Hi all, I am relatively new to single-cell (and spatial) data analysis. I was following this pipeline to try to replicate an analysis, and it had the following steps: sc.pp.filter\_cells(adata,min\_counts=40) sc.pp.filte…

---

## [Question about implementation of highly\_variable\_genes](https://discourse.scverse.org/t/question-about-implementation-of-highly-variable-genes/3847)

<div class="topic-metadata">

**Author:** [@ekgrantham](https://discourse.scverse.org/u/ekgrantham)\
**Replies:** 0\
**Last updated:** [November 3, 2025, 4:10pm UTC](https://discourse.scverse.org/t/question-about-implementation-of-highly-variable-genes/3847 "2025-11-03T16:10:36Z")

</div>

When performing scanpy.pp.highly\_variable\_genes, documentation states that “Depending on flavor, this reproduces the R-implementations of Seurat…” does this mean it reproduces the latest version of Seurat? I am wondering…

---

## [Posterior probability interpretability (soft=True)](https://discourse.scverse.org/t/posterior-probability-interpretability-soft-true/3787)

<div class="topic-metadata">

**Author:** [@ondy](https://discourse.scverse.org/u/ondy)\
**Replies:** 1\
**Last updated:** [September 25, 2025, 12:46pm UTC](https://discourse.scverse.org/t/posterior-probability-interpretability-soft-true/3787 "2025-09-25T12:46:32Z")

</div>

Hello, I used scANVI to transfer cell type labels from a single-cell reference to my spatial transcriptomics data (MERFISH). I assigned labels at three hierarchical levels and then compared the prediction scores obtain…

---

## [How could \`adata.raw.X\` contain non-integer values?](https://discourse.scverse.org/t/how-could-adata-raw-x-contain-non-integer-values/3708)

<div class="topic-metadata">

**Author:** [@mschilli](https://discourse.scverse.org/u/mschilli)\
**Replies:** 2\
**Last updated:** [July 13, 2025, 7:56pm UTC](https://discourse.scverse.org/t/how-could-adata-raw-x-contain-non-integer-values/3708 "2025-07-13T19:56:26Z")

</div>

Hello scverse communtity, I need some help troubleshooting an issue I do not understand. I have a (non-public) H5ad file with a dataset that was analysed (QC, cell/gene/sample annotation, normalisation, dimensionality …

---

## [Scanpy write compression vs os compression](https://discourse.scverse.org/t/scanpy-write-compression-vs-os-compression/3687)

<div class="topic-metadata">

**Author:** [@vivere-dally](https://discourse.scverse.org/u/vivere-dally)\
**Replies:** 1\
**Last updated:** [June 28, 2025, 12:21pm UTC](https://discourse.scverse.org/t/scanpy-write-compression-vs-os-compression/3687 "2025-06-28T12:21:20Z")

</div>

Hi! I am wondering if there is any difference between using compression via scanpy.write, or running lz4 on a h5ad uncompressed file on the disk. Can scanpy load it again? I want to compress some h5ad files that are on …

---

## [How can I change the color of the "groupby" labels from a dotplot?](https://discourse.scverse.org/t/how-can-i-change-the-color-of-the-groupby-labels-from-a-dotplot/3679)

<div class="topic-metadata">

**Author:** [@timslittle](https://discourse.scverse.org/u/timslittle)\
**Replies:** 0\
**Last updated:** [June 4, 2025, 1:05pm UTC](https://discourse.scverse.org/t/how-can-i-change-the-color-of-the-groupby-labels-from-a-dotplot/3679 "2025-06-04T13:05:47Z")

</div>

Hi folks, I want to change the color of the “var\_group\_labels” at the top of a dotplot body. I can change the color of other parts of the graph, such as the “groupby” labels, but I cannot figure out how to do it for the…

---

## [Unexplained change in UMAP](https://discourse.scverse.org/t/unexplained-change-in-umap/3601)

<div class="topic-metadata">

**Author:** [@LioLnr](https://discourse.scverse.org/u/LioLnr)\
**Replies:** 3\
**Last updated:** [May 27, 2025, 6:54pm UTC](https://discourse.scverse.org/t/unexplained-change-in-umap/3601 "2025-05-27T18:54:43Z")

</div>

A few months ago, I did an analysis, today I rerun the same bit of code : sc.pp.neighbors(sco, use\_rep = 'integrated\_scvi') sc.tl.leiden(sco, resolution=0.70, key\_added='cluster\_int') sc.tl.umap(sco) But the UMAP hav…

---

## [Sc.pp.highly\_variable\_genes with batch\_key causes segmentation fault](https://discourse.scverse.org/t/sc-pp-highly-variable-genes-with-batch-key-causes-segmentation-fault/1968)

<div class="topic-metadata">

**Author:** [@malonzm1](https://discourse.scverse.org/u/malonzm1)\
**Replies:** 2\
**Last updated:** [May 26, 2025, 12:30pm UTC](https://discourse.scverse.org/t/sc-pp-highly-variable-genes-with-batch-key-causes-segmentation-fault/1968 "2025-05-26T12:30:45Z")

</div>

Hi, I’m analyzing scRNAseq datasets from various GSE studies. When I use sc.pp.highly\_variable\_genes without batch\_key it works fine. But when I use batch\_key as the GSE study: sc.pp.highly\_variable\_genes( adatas, …

---

## [Best Practices for Multi-Panel Figures](https://discourse.scverse.org/t/best-practices-for-multi-panel-figures/3603)

<div class="topic-metadata">

**Author:** [@wbrett87](https://discourse.scverse.org/u/wbrett87)\
**Replies:** 0\
**Last updated:** [April 11, 2025, 8:43pm UTC](https://discourse.scverse.org/t/best-practices-for-multi-panel-figures/3603 "2025-04-11T20:43:25Z")

</div>

Hello everyone, I am putting together a multi-panel figure containing bioinformatic plots from that are getting output from a variety of different python scRNAseq packages. One problem I am encountering is that when I u…

---

## [Stacked violin API related question](https://discourse.scverse.org/t/stacked-violin-api-related-question/545)

<div class="topic-metadata">

**Author:** [@khksw0403](https://discourse.scverse.org/u/khksw0403)\
**Replies:** 2\
**Last updated:** [April 1, 2025, 9:11pm UTC](https://discourse.scverse.org/t/stacked-violin-api-related-question/545 "2025-04-01T21:11:06Z")

</div>

Good morning, now i use scanpy module and get results. but when i use \[name.add\_totals()\] function, i don’t know how to save it pdf or image files. sample1: → it’s working sc.pl.stacked\_violin(data, markers, groupby=‘s…

---

## [Any MLX (MPS) framework accelerate solution for scanpy？](https://discourse.scverse.org/t/any-mlx-mps-framework-accelerate-solution-for-scanpy/3452)

<div class="topic-metadata">

**Author:** [@c0nleyinnnn](https://discourse.scverse.org/u/c0nleyinnnn)\
**Replies:** 1\
**Last updated:** [March 31, 2025, 3:53pm UTC](https://discourse.scverse.org/t/any-mlx-mps-framework-accelerate-solution-for-scanpy/3452 "2025-03-31T15:53:59Z")

</div>

On the NVIDIA platform, the rapids-singlecell library uses CUDA to achieve very fast single-cell data processing and calculation. The unified memory architecture of the M chip is very beneficial for single-cell data anal…

---

## [Split dotplot by condition](https://discourse.scverse.org/t/split-dotplot-by-condition/2513)

<div class="topic-metadata">

**Author:** [@spatts14](https://discourse.scverse.org/u/spatts14)\
**Replies:** 2\
**Last updated:** [March 3, 2025, 4:53pm UTC](https://discourse.scverse.org/t/split-dotplot-by-condition/2513 "2025-03-03T16:53:58Z")

</div>

Is possible to do something like this in scanpy? (see photo below) It would be great if it could be seperated by cell type, gene, and condition like x axis (bottom) = gene x axis (top) = condition (i.e one column f…

---

## [Rank\_genes\_groups pts and DE](https://discourse.scverse.org/t/rank-genes-groups-pts-and-de/3519)

<div class="topic-metadata">

**Author:** [@Slack90](https://discourse.scverse.org/u/Slack90)\
**Replies:** 0\
**Last updated:** [February 27, 2025, 7:35pm UTC](https://discourse.scverse.org/t/rank-genes-groups-pts-and-de/3519 "2025-02-27T19:35:16Z")

</div>

Hi, I am using ran rank\_genes\_groups specifying pts as true as I want the percentage of cells in the cluster that have the gene I am calling. This is what I am using: sc.tl.rank\_genes\_groups(adata, 'cell type', pts = T…

---

## [Reg negative and positive TF activity values](https://discourse.scverse.org/t/reg-negative-and-positive-tf-activity-values/3504)

<div class="topic-metadata">

**Author:** [@dub2s](https://discourse.scverse.org/u/dub2s)\
**Replies:** 0\
**Last updated:** [February 24, 2025, 5:00am UTC](https://discourse.scverse.org/t/reg-negative-and-positive-tf-activity-values/3504 "2025-02-24T05:00:45Z")

</div>

Hii, I was playing around with decoupler-py to infer TF activities in a pseudobulk’d scRNA-seq data. In the data, I have different cell-types and two conditions. I wanted to identify TFs with differential activity betwe…

---

## [Help with harmony and scanpy](https://discourse.scverse.org/t/help-with-harmony-and-scanpy/3477)

<div class="topic-metadata">

**Author:** [@bioinf](https://discourse.scverse.org/u/bioinf)\
**Replies:** 3\
**Last updated:** [February 14, 2025, 9:05pm UTC](https://discourse.scverse.org/t/help-with-harmony-and-scanpy/3477 "2025-02-14T21:05:56Z")

</div>

Hello, I am interested in using harmony to integrate some samples but I am not sure if I am doing it correctly. I have 6 samples with 2 conditions (3 control/3 treated) I do the following steps: Merge samples QC Nor…

---

## [Weird output combat integration two datasets](https://discourse.scverse.org/t/weird-output-combat-integration-two-datasets/3469)

<div class="topic-metadata">

**Author:** [@Slack90](https://discourse.scverse.org/u/Slack90)\
**Replies:** 2\
**Last updated:** [February 6, 2025, 7:43pm UTC](https://discourse.scverse.org/t/weird-output-combat-integration-two-datasets/3469 "2025-02-06T19:43:49Z")

</div>

Hi, I am trying to integrate two datasets, and I have tested several methods, including scvi, BBKKN, scanorama, combat and some others in R (RCCA, and Harmony). In some cases I see weird integration output such as the o…

---

## [How to deal with negative logfoldchange in dotplot](https://discourse.scverse.org/t/how-to-deal-with-negative-logfoldchange-in-dotplot/3472)

<div class="topic-metadata">

**Author:** [@LioLnr](https://discourse.scverse.org/u/LioLnr)\
**Replies:** 0\
**Last updated:** [February 6, 2025, 10:43am UTC](https://discourse.scverse.org/t/how-to-deal-with-negative-logfoldchange-in-dotplot/3472 "2025-02-06T10:43:23Z")

</div>

Hello, I have simply ran scanpy.tl.rank\_genes\_groups(). After obtaining the results per cluster with scanpy.get.rank\_genes\_groups\_df(), I filter them using a pval threshold of 0.05 and a lfc threshold of 1. Unfortunatl…

---

## [Replicating data analysis using published pipeline](https://discourse.scverse.org/t/replicating-data-analysis-using-published-pipeline/3378)

<div class="topic-metadata">

**Author:** [@hannah-98](https://discourse.scverse.org/u/hannah-98)\
**Replies:** 0\
**Last updated:** [December 10, 2024, 3:58pm UTC](https://discourse.scverse.org/t/replicating-data-analysis-using-published-pipeline/3378 "2024-12-10T15:58:30Z")

</div>

Hi, I am trying to analyse a scRNAseq dataset using the same parameters they have used, but I am struggling to understand how to implement the parameters for each function they have described in their methods. How woul…

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