<p>Just to make sure, I took a quick look at chippeakanno, and it uses a hypergeometric test for gene enrichment, not necessarily overlap of two chip-seq results.</p>

<p>As you mentioned, you can imagine in your set of genes, you have those that overlap with your peaks, and those that do not. Hypergeometric distribution calculates the probability of getting a certain number of genes that overlap with your peaks (which is the same as sampling some balls and calculate the p-value of some balls with one color). The hypergeometric test calculates a p-value to see whether this number of overlapping genes is more than expected.</p>

<p>I also read on Wikipedia that the P-value of hypergeometric test times 2 is exactly the P-value for Fisher's exact test. Fisher's exact test tests whether your overlap is more than (or less than) expectation. Hypergeometric tests just feel like a one-tailed version of Fisher's exact tests.</p>

CC BY-SA 4.0
2020-05-15T22:57:29.573Z
2020-05-15T22:57:29.573Z
Phoenix Mu
<p>There is no such thing as a hypergeometric test, at least in statistical textbooks. It's a fisher test based on hypergeometric distribution.</p>

<p>If it is chip-seq for the same target, i.e biological replicates, significance of overlap is not quite meaningful. You get more information by for example checking the correlation of the coverage between your replicates <a href="https://deeptools.readthedocs.io/en/develop/content/example_usage.html" rel="noreferrer">using deeptools</a> or anything else.</p>

<p>If you are comparing between two different targets, for example, chip for two different histone marks, you can use the fisher test or chi-square this way. </p>

<ol>
<li>Partition the genome in X bp bins, these are all your marbles</li>
<li>Identity those that overlap with peaks from target 1 and those that don't</li>
<li>Do 2. for target2 </li>
<li>construct a contingency table using 2 and 3.</li>
</ol>

<p>So you should end up with something like this (purely made up): </p>

<pre><code>                      no_overlap_target2 overlap_target2
  no_overlap_target1               9799             112
  overlap_target1                    88               1
</code></pre>

<p>And if there is overlap, the bottom diagonal with be higher.. less on the off-diagonal, and you can test it with a fisher.test. </p>

CC BY-SA 4.0
2020-05-18T15:23:40.213Z
So in your table, top left is the sum of the number of intervals in target1 and target2 that are not overlapping each other? Also the off-diagonal is the the number of target 1 that is not overlapping with target2 and vice versa?
skc
CC BY-SA 4.0
2020-05-18T15:27:20.873Z
sorry.. not very clear, this table is for example, we partition the genome into 10000 bins.. 9799 don't have target 1 or target 2, off diagonal is found in target2 but not in target1
StupidWolf
CC BY-SA 4.0
2020-05-18T15:42:32.607Z
Ah, I see. Thanks! Now I think I know how to do.
skc
CC BY-SA 4.0
2020-05-18T15:44:47.237Z
Yes, I have two targets. I think I'll just go ahead and use Granges package in R to do this task.
skc
CC BY-SA 4.0
2020-05-18T20:39:03.053Z
Do you mind if you could explain why this is corresponds to the hypergeometric distribution in this setting? In particular, why does "drawing the blue ball" from the urn corresponds to X-bp bins that are not in target1 nor target2?
skc
CC BY-SA 4.0
2020-05-18T22:29:02.173Z
https://en.wikipedia.org/wiki/Hypergeometric_distribution, look under working example, you are looking for the association between drawn and color
StupidWolf
CC BY-SA 4.0
2020-05-16T00:31:48.073Z
2020-05-16T00:31:48.073Z
StupidWolf
<p>Suppose I have done two Chip-seq experiments. Now after the bias correction step such as MACS2, I get two set of genomic intervals (or peaks, as what is usually called) that corresponds to each of the experiment. I want to test the significance of the overlap of these two set genomic intervals that corresponds to each experiment.</p>

<p>The common test employed seemed to me is the Hypergeometic test. There's even a package specifically aim for this task: <a href="https://www.bioconductor.org/packages/release/bioc/vignettes/ChIPpeakAnno/inst/doc/ChIPpeakAnno.html" rel="nofollow noreferrer" title="ChiPpeakAnno">ChiPpeakAnno</a>. </p>

<p>Recall from the Hypergeometric distrbition -- the analogy is that we have a bag of marbles with two different colors, say one blue and another red. A sample from such distribution consists of marbles drawn from this bag, and a probability measure for this distribution is the number of blue marbles in the sample. </p>

<p>Could someone explain what is the correspondence between the hypergeometric test and the significance overlap between two different set of genomic intervals?</p>

CC BY-SA 4.0
2020-05-17T12:41:50.480Z
Interesting dicussion, its about sampling error in minority populations and whether this sampling error can throw a spurious "they are different result", when in fact its a sampling bias.
M__
<r><chip-seq><peak-calling>
Hypergeometic test for the overlap of two set of genomic intervals (e.g. from Chip-seq data)
# Hypergeometic test for the overlap of two set of genomic intervals (e.g. from Chip-seq data)

(Asked by: username_0 on 2020-05-15)

Suppose I have done two Chip-seq experiments. Now after the bias correction step such as MACS2, I get two set of genomic intervals (or peaks, as what is usually called) that corresponds to each of the experiment. I want to test the significance of the overlap of these two set genomic intervals that corresponds to each experiment.

The common test employed seemed to me is the Hypergeometic test. There's even a package specifically aim for this task: [ChiPpeakAnno](https://www.bioconductor.org/packages/release/bioc/vignettes/ChIPpeakAnno/inst/doc/ChIPpeakAnno.html "ChiPpeakAnno").

Recall from the Hypergeometric distrbition -- the analogy is that we have a bag of marbles with two different colors, say one blue and another red. A sample from such distribution consists of marbles drawn from this bag, and a probability measure for this distribution is the number of blue marbles in the sample.

Could someone explain what is the correspondence between the hypergeometric test and the significance overlap between two different set of genomic intervals?

**Tags:** r, chip-seq, peak-calling
> **Comments:**
> **username_1**: Interesting dicussion, its about sampling error in minority populations and whether this sampling error can throw a spurious "they are different result", when in fact its a sampling bias.  

---

## 2 answers

### Answer by username_3 on 2020-05-16. Score: 6 | Accepted answer

There is no such thing as a hypergeometric test, at least in statistical textbooks. It's a fisher test based on hypergeometric distribution.
If it is chip-seq for the same target, i.e biological replicates, significance of overlap is not quite meaningful. You get more information by for example checking the correlation of the coverage between your replicates using deeptools or anything else.
If you are comparing between two different targets, for example, chip for two different histone marks, you can use the fisher test or chi-square this way. 

Partition the genome in X bp bins, these are all your marbles
Identity those that overlap with peaks from target 1 and those that don't
Do 2. for target2 
construct a contingency table using 2 and 3.

So you should end up with something like this (purely made up): 
                      no_overlap_target2 overlap_target2
  no_overlap_target1               9799             112
  overlap_target1                    88               1

And if there is overlap, the bottom diagonal with be higher.. less on the off-diagonal, and you can test it with a fisher.test.

> **Comments:**
> **username_0**: So in your table, top left is the sum of the number of intervals in target1 and target2 that are not overlapping each other? Also the off-diagonal is the the number of target 1 that is not overlapping with target2 and vice versa?  
> **username_3**: sorry.. not very clear, this table is for example, we partition the genome into 10000 bins.. 9799 don't have target 1 or target 2, off diagonal is found in target2 but not in target1  
> **username_0**: Ah, I see. Thanks! Now I think I know how to do.  
> **username_0**: Yes, I have two targets. I think I'll just go ahead and use Granges package in R to do this task.  
> **username_0**: Do you mind if you could explain why this is corresponds to the hypergeometric distribution in this setting? In particular, why does "drawing the blue ball" from the urn corresponds to X-bp bins that are not in target1 nor target2?  
> **username_3**: https://en.wikipedia.org/wiki/Hypergeometric_distribution, look under working example, you are looking for the association between drawn and color  

---

### Answer by username_2 on 2020-05-15. Score: 1

Just to make sure, I took a quick look at chippeakanno, and it uses a hypergeometric test for gene enrichment, not necessarily overlap of two chip-seq results.

As you mentioned, you can imagine in your set of genes, you have those that overlap with your peaks, and those that do not. Hypergeometric distribution calculates the probability of getting a certain number of genes that overlap with your peaks (which is the same as sampling some balls and calculate the p-value of some balls with one color). The hypergeometric test calculates a p-value to see whether this number of overlapping genes is more than expected.

I also read on Wikipedia that the P-value of hypergeometric test times 2 is exactly the P-value for Fisher's exact test. Fisher's exact test tests whether your overlap is more than (or less than) expectation. Hypergeometric tests just feel like a one-tailed version of Fisher's exact tests.


---

