heatmapscanpy

Adjust the cluster order of sc.pl.heatmap in scanpy


I am a beginner who is studying bioinformatics with scanpy these days.

In the 'sc.pl.heatmap', I want to show ‘leiden’ in a specific order in heatmap, but I don’t know what to do.

I want to show ‘leiden’ in ascending order.

Is there any related function?


Solution

  • Assuming you have leiden column in the obs dataframe, you can reorder it as:

    adata.obs['leiden'] = adata.obs['leiden'].cat.reorder_categories(['new first', 'new second', ...etc])