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

621 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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])