Finding marker genes in scanpy


I wonder if I will be able to arrange (i.e. descending order) the feature genes based on either ‘logfoldchanges’ or ‘pvals_adj’ instead of ‘pvals’. Could you please give me a piece of advice?

result = adata.uns[‘rank_genes_groups’]
groups = result[‘names’].dtype.names
{group + ‘_’ + key[:1]: result[key][group]
for group in groups for key in [‘names’, ‘logfoldchanges’, ‘pvals_adj’]}).head(30)

Thank you in advance for your kind help…!

I’d recommend using the function sc.get.rank_genes_groups_df, and then to sort the resulting dataframe however you’d like.

I believe the ordering of pvals should be the same as the ordering of pvals_adj.

1 Like

Hi, @ivirshup

Thank you so much for your response. It helps me a lot. Many thanks to you🍉…!