# Finding marker genes in scanpy

**URL:** <https://discourse.scverse.org/t/finding-marker-genes-in-scanpy/477>\
**Category:** scanpy\
**Created:** [May 23, 2022, 6:13am UTC](https://discourse.scverse.org/t/finding-marker-genes-in-scanpy/477 "2022-05-23T06:13:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![J1205](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/j1205/32/245_2.png) [@J1205](https://discourse.scverse.org/u/J1205)\
**Post date:** [May 23, 2022, 6:13am UTC](https://discourse.scverse.org/t/finding-marker-genes-in-scanpy/477/1 "2022-05-23T06:13:31Z")

</div>

Hi,

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  
pd.DataFrame(  
{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…!

---

<div class="post-metadata">

**Author:** ![ivirshup](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/ivirshup/32/160_2.png) [@ivirshup](https://discourse.scverse.org/u/ivirshup)\
**Post date:** [May 23, 2022, 9:50am UTC](https://discourse.scverse.org/t/finding-marker-genes-in-scanpy/477/2 "2022-05-23T09:50:48Z")

</div>

I’d recommend using the function [`sc.get.rank_genes_groups_df`](https://scanpy.readthedocs.io/en/stable/generated/scanpy.get.rank_genes_groups_df.html), 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`.

---

<div class="post-metadata">

**Author:** ![J1205](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/j1205/32/245_2.png) [@J1205](https://discourse.scverse.org/u/J1205)\
**Post date:** [May 24, 2022, 12:11pm UTC](https://discourse.scverse.org/t/finding-marker-genes-in-scanpy/477/3 "2022-05-24T12:11:03Z")

</div>

Hi, @ivirshup

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