How to order genes in a matrix plot using levels of expression?

Hello everyone,

I would like to ask for your kind help. I have matrix plot that shows the expression of several genes. As example you can see the picture below.

I would like to have the same matrix plot, but I would prefer that the genes have an order in the plot. For instance, the genes with greater expression in the majority of the clusters should be at the top of the plot and the ones with lower expression in the bottom of the matrix plot. Could anyone give me some feedback?

Thanks in advance!

Can you change the order of the genes that you pass to the function? How are you currently generating the plot? Do you have a code example?


The aforementioned code reproduces the plot. I have a list of genes in a random order, which I can plot in a matrix-plot without problem. If I manually change the order of the genes in the list I can generate the plot that I want (genes ordered by expression). The problem is that the matrix plot I want to create includes at least 500 genes, and I do not think ordering the genes manually is a good idea.

I would like to create a matrix plot where genes with similar expression are grouped. Something like the clustering produced by seaborn.clustermap or this picture:

I see. I think you should find a solution to this using ( — Scanpy 1.7.1 documentation), whic his a wrapper around the seaborn function. You may have to subset your adata object to the relevant genes though.