text: user4761: 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. 
  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?
  
  user4766: 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.
  
  user5077: 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. 
  
original_text: 4761: <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>
   4766: <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>
   5077: <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>
  