How to do for rank genes, and only the top 25 genes from the ranked gene list


I did ranked_gene_groups for a cluster and filtered with adj_pval < 0.05 and log2FC >2, I got a long list that when I used to show the genes, due to too many gene numbers, the gene’s names can’t show up and I only want to do this heatmap for the top 25 genes.

I’m wondering if you have any great ideas.

Thank you in advance!

Here’s the code I used:,groupby=‘batch’,var_names=df_ranked_genes_m1[‘2_n’].tolist(),use_raw=True,swap_axes=True,standard_scale=‘var’, cmap=‘coolwarm’)

Stay well!

you can try (notice the added [:25]):,groupby=‘batch’,var_names=df_ranked_genes_m1[‘2_n’].tolist()[:25],use_raw=True,swap_axes=True,standard_scale=‘var’, cmap=‘coolwarm’)