Scanpy: sc.pl.heatmap cannot show different colors for more than 20 cell types

Created on 21 Mar 2019  Â·  6Comments  Â·  Source: theislab/scanpy

I plot heatmap for normalized gene expression for 34 clusters. The code is as below:

sc.pl.heatmap(adata, marker_genes, use_raw=False, swap_axes=True, show=False, show_gene_labels=True, save=ofile, groupby='louvain', dendrogram=True)

However, there are only 20 colors for the cluster bars. How can I deal with this issue?

heatmap

bug plots

Most helpful comment

@gokceneraslan If I follow you correctly, the idea would be to add a palette argument to heatmap. That indeed may solve the issue and should not be difficult to achieve. I will put it on my list of future enhancements.

All 6 comments

the problem is related to the palette being used. The color palette is taken from the scatter plots. A way to fix this is by running for example sc.pl.umap(adata, palette='Blues'). Then run the heatmap again.

Cool! It did solve my problems. Thank you!

From: Fidel Ramirez
Sent: Friday, March 22, 2019 5:55 AM
To: theislab/scanpy
Cc: screamer; Author
Subject: Re: [theislab/scanpy] sc.pl.heatmap cannot show different colors formore than 20 cell types (#548)

the problem is related to the palette being used. The color palette is taken from the scatter plots. A way to fix this is by running for example sc.pl.umap(adata, palette='Blues'). Then run the heatmap again.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Actually, it'd be great to reuse category number-based dynamic color map selection code thingy we have for scatterplots here. What do you think @fidelram ?

@gokceneraslan If I follow you correctly, the idea would be to add a palette argument to heatmap. That indeed may solve the issue and should not be difficult to achieve. I will put it on my list of future enhancements.

the problem is related to the palette being used. The color palette is taken from the scatter plots. A way to fix this is by running for example sc.pl.umap(adata, palette='Blues'). Then run the heatmap again.

Does it work if I manually update the adata.uns['louvain_colors'] ?
It feels weird to run umap just to create the slot for colormap althought it worked for me.
Just want to double check.

@brianpenghe I believe it'll work if you manually update adata.uns["louvain_colors"], at least it does for the scatter plots.

It is weird. We've talked a bit about having a better API for this here #596.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

naity picture naity  Â·  5Comments

sjfleming picture sjfleming  Â·  3Comments

wflynny picture wflynny  Â·  6Comments

giovp picture giovp  Â·  4Comments

Khalid-Usman picture Khalid-Usman  Â·  3Comments