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?

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like