# Trouble Making a Z-Score Heatmap

**URL:** <https://discourse.scverse.org/t/trouble-making-a-z-score-heatmap/1227>\
**Category:** scanpy\
**Created:** [March 14, 2023, 7:06pm UTC](https://discourse.scverse.org/t/trouble-making-a-z-score-heatmap/1227 "2023-03-14T19:06:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BioinformatixDude](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/bioinformatixdude/32/580_2.png) [@BioinformatixDude](https://discourse.scverse.org/u/BioinformatixDude)\
**Post date:** [March 14, 2023, 7:06pm UTC](https://discourse.scverse.org/t/trouble-making-a-z-score-heatmap/1227/1 "2023-03-14T19:06:17Z")

</div>

Hello,  
I’m working on a single cell project and have done your typical pre-processing by log-normalizing and scaling the data. I want to generate heatmaps that depict the z-score of each differentially expressed across all cells. I performed differential gene expression analysis using the `rank_genes_groups()` function with the Wilcoxon test. After looking through the documentation, I’m quite confused on a few things. First, the documentation states that the “score” generated from the Wilcoxon test is the z-score, and the docs also state that plotting the DGE using the `rank_genes_groups_heatmap()` produces a heatmap of the “ranking of genes using a heatmap”. My question is: what exactly is being plotted when calling the `rank_genes_groups_heatmap()` function? Is it the log-normalized and scaled expression stored in adata.X? or is it the z-score produced by the Wilcoxon test? The heatmap looks like this:

 ![heatmap_temp](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/1X/10767bb2c23601c556e743b43dbfd5be63fa0483.png)

I also tried another approach to producing the z-score heatmap. in the alternative approach, I simply calculated the z-score of the log-normalized counts that I stored in an anndata layer, called “counts-lognorm”, and then saved the z-score calculation in another layer, called “z-score”. When trying to make the heatmap using the `heatmap()` and passing the “z-score” layer to the layers parameter, my heatmap is completely different than the heatmap generated above and is almost all dark blue.

Can the community please help me generate a heatmap depicting z-scores?

Thanks in advanced

---

<div class="post-metadata">

**Author:** ![BioinformatixDude](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/bioinformatixdude/32/580_2.png) [@BioinformatixDude](https://discourse.scverse.org/u/BioinformatixDude)\
**Post date:** [March 14, 2023, 7:07pm UTC](https://discourse.scverse.org/t/trouble-making-a-z-score-heatmap/1227/2 "2023-03-14T19:07:14Z")

</div>

The alternative attempt at making the heatmap looks like this:

 ![heatmap_Zscore_DGEByTime_top50](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/1X/bd4e9cd0a6b5e989f6cafc4ddba311cd99c685b5.png)

---

<div class="post-metadata">

**Author:** ![jpmcga](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/jpmcga/32/1163_2.png) [@jpmcga](https://discourse.scverse.org/u/jpmcga)\
**Post date:** [September 11, 2024, 2:20am UTC](https://discourse.scverse.org/t/trouble-making-a-z-score-heatmap/1227/3 "2024-09-11T02:20:37Z")

</div>

I’m having the same issue! What exactly is being plotted in the heatmap? The z-score? Thanks.
