# Scaling Gene Set Heatmap

**URL:** <https://discourse.scverse.org/t/scaling-gene-set-heatmap/2157>\
**Category:** Help\
**Created:** [March 13, 2024, 8:59pm UTC](https://discourse.scverse.org/t/scaling-gene-set-heatmap/2157 "2024-03-13T20:59:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wbrett87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/wbrett87/32/517_2.png) [@wbrett87](https://discourse.scverse.org/u/wbrett87)\
**Post date:** [March 13, 2024, 8:59pm UTC](https://discourse.scverse.org/t/scaling-gene-set-heatmap/2157/1 "2024-03-13T20:59:18Z")

</div>

Hello,

I am currently trying to plot a selection of gene sets on a heat map via the following overall workflow:

1)DEG analysis  
2)GSEA on DEG  
3)sc.tl.score\_genes() on ~20 relevant gene sets  
4)using sc.pl.heatmap() to plot the gene sets

I set the standard\_scale parameter to “vars” in order to scale all the gene set values to between 0 and 1, and it looks quite good. Is there a way to scale the gene set values so they instead fall between -1 and 1?

Thanks for all the great work and any help you can provide!

---

<div class="post-metadata">

**Author:** ![abbass2](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/abbass2/32/884_2.png) [@abbass2](https://discourse.scverse.org/u/abbass2)\
**Post date:** [March 13, 2024, 10:12pm UTC](https://discourse.scverse.org/t/scaling-gene-set-heatmap/2157/2 "2024-03-13T22:12:14Z")

</div>

Hello,

I’m entirely sure about this but you may try `vcenter`, `vmax`, `vmin`. Let me know if it works!

Shahroze

---

<div class="post-metadata">

**Author:** ![wbrett87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/wbrett87/32/517_2.png) [@wbrett87](https://discourse.scverse.org/u/wbrett87)\
**Post date:** [March 13, 2024, 10:57pm UTC](https://discourse.scverse.org/t/scaling-gene-set-heatmap/2157/3 "2024-03-13T22:57:57Z")

</div>

I ended up using the following solution that GitHub copilot generated for me, and it seems to work quite well. I basically use the sklearn MinMaxScaler to scale the column of the obs dataframe containing the score\_gene() output for each gene set. Do you think this is appropriate in this context?

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

---

<div class="post-metadata">

**Author:** ![abbass2](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/abbass2/32/884_2.png) [@abbass2](https://discourse.scverse.org/u/abbass2)\
**Post date:** [March 14, 2024, 4:19pm UTC](https://discourse.scverse.org/t/scaling-gene-set-heatmap/2157/4 "2024-03-14T16:19:04Z")

</div>

I’m not sure to be honest, but it’s worth a shot to try. The parameters I suggested earlier are directly part of the heatmap function so may be easier to implement. Whatever gets you the result you’re looking for 🙂
