# How to check average gene expression for each of 2 conditions within a cluster in scanpy?

**URL:** <https://discourse.scverse.org/t/how-to-check-average-gene-expression-for-each-of-2-conditions-within-a-cluster-in-scanpy/1277>\
**Category:** Help\
**Created:** [March 30, 2023, 7:21am UTC](https://discourse.scverse.org/t/how-to-check-average-gene-expression-for-each-of-2-conditions-within-a-cluster-in-scanpy/1277 "2023-03-30T07:21:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bioinf](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@bioinf](https://discourse.scverse.org/u/bioinf)\
**Post date:** [March 30, 2023, 7:21am UTC](https://discourse.scverse.org/t/how-to-check-average-gene-expression-for-each-of-2-conditions-within-a-cluster-in-scanpy/1277/1 "2023-03-30T07:21:18Z")

</div>

Hello,

I used scanpy to do DE analysis for 2 conditions within a cluster. I set it up like shown here:

```auto
sc.tl.rank_genes_groups(adata, 'type', method='wilcoxon', groups=["A"], reference='B')

```

I want to confirm the directionality of the log fold change of the results so I would like to plot the average expression of a specific gene for group A and B within a specific cluster. How can I do that?

I think that the way I set up the rank\_genes\_groups means that a positive log fold change for a gene indicates that A has higher expression of that gene compared to B.

Thank you
