<p>What I would personally do is run a Χ<sup>2</sup></p>
<pre><code>from scipy.stats import chisquare
import numpy as np

pan = [11, 39, 4 ....]
core = [29, 50, 7 ... ]
f_exp = np.array(pan)
f_obs = np. array(core)
print (chisquare(f_obs=f_obs, f_exp=f_exp))
</code></pre>
<p>This will output the total statistic and whether its above or below the critical probability.</p>
<p>Fisher's Exact test is essentially Χ<sup>2</sup> for a small number of observations, which is not the case with your data.</p>
<p>Looking at your data Χ<sup>2</sup> is not likely to be &quot;significant&quot; (which is the result you are looking for), i.e. the pan genome is the core genome across all COGs.</p>

CC BY-SA 4.0
2024-03-05T05:56:13.493Z
Thank you very much for all your efforts @M__ ! Hopefully, this works.
K_081
CC BY-SA 4.0
2024-03-05T03:20:46.687Z
2024-03-05T03:26:13.437Z
2024-03-05T03:26:13.437Z
M__
<p>This is a continuation of the following question -</p>
<p><a href="https://bioinformatics.stackexchange.com/questions/22104/fishers-exact-test-for-cog-categories-in-pan-core-genome-analysis/22108">Fisher&#39;s exact test for COG categories in pan, core genome analysis</a></p>
<p>Also, the dataset -</p>
<p><a href="https://i.sstatic.net/7dJra.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7dJra.png" alt="COG categories dataset" /></a></p>
<p>How do I perform a Fisher's exact test on this data to show that a COG category is significantly more or less in the pan/core/accessory/species specific genomes?</p>

CC BY-SA 4.0
2024-03-01T14:11:55.737Z
I'll post a response late Monday, sorry really busy. Basically you can do spot checks via Fishers Exact test or go the whole hog and do a Chi2 test. The matrix you have is pan/core vs cogs.
M__
CC BY-SA 4.0
2024-03-01T14:29:42.767Z
Hi @M__, good to know. Thanks a lot!
K_081
<r><eggnog><pangenome>
Calculating Fisher's exact test for COG categories
# Calculating Fisher's exact test for COG categories

(Asked by: username_0 on 2024-02-23)

This is a continuation of the following question -

[Fisher's exact test for COG categories in pan, core genome analysis](https://bioinformatics.stackexchange.com/questions/22104/fishers-exact-test-for-cog-categories-in-pan-core-genome-analysis/22108)

Also, the dataset -

[![COG categories dataset](https://i.sstatic.net/7dJra.png)](https://i.sstatic.net/7dJra.png)

How do I perform a Fisher's exact test on this data to show that a COG category is significantly more or less in the pan/core/accessory/species specific genomes?

**Tags:** r, eggnog, pangenome
> **Comments:**
> **username_1**: I'll post a response late Monday, sorry really busy. Basically you can do spot checks via Fishers Exact test or go the whole hog and do a Chi2 test. The matrix you have is pan/core vs cogs.  
> **username_0**: Hi @M__, good to know. Thanks a lot!  

---

## 1 answers

### Answer by username_1 on 2024-03-05. Score: 1 | Accepted answer

What I would personally do is run a Χ2
from scipy.stats import chisquare
import numpy as np

pan = [11, 39, 4 ....]
core = [29, 50, 7 ... ]
f_exp = np.array(pan)
f_obs = np. array(core)
print (chisquare(f_obs=f_obs, f_exp=f_exp))

This will output the total statistic and whether its above or below the critical probability.
Fisher's Exact test is essentially Χ2 for a small number of observations, which is not the case with your data.
Looking at your data Χ2 is not likely to be "significant" (which is the result you are looking for), i.e. the pan genome is the core genome across all COGs.

> **Comments:**
> **username_0**: Thank you very much for all your efforts @M__ ! Hopefully, this works.  

---

