scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.89k stars 594 forks source link

sc.pl.heatmap cannot show different colors for more than 20 cell types #548

Open jhu99 opened 5 years ago

jhu99 commented 5 years ago

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

fidelram commented 5 years ago

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.

jhu99 commented 5 years ago

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.

gokceneraslan commented 5 years ago

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 ?

fidelram commented 5 years ago

@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.

brianpenghe commented 5 years ago

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.

ivirshup commented 5 years ago

@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.