title: Calculate venn diagram hypergeometric p value using R
body: <p>Hi，I saw someone calculate venn diagram overlap p-value as in the following example. They use hypergeometric distribution and R. When I apply their function in R, I just cannot get the same results. Can anyone help me about this?</p>
  
  <p>The sample I saw in someone else's publication:</p>
  
  <p>From 15220 genes, set A is 1850+195 genes, set B is 195+596 genes, overlap is 195 genes. Their p value is 2e-26. </p>
  
  <p>Their method is: given a total of N genes, if gene sets A and B contain m and n genes, respectively, and k of them are in common, then the p-value of enrichment is calculated by:</p>
  
  <pre><code>p = Σ (m,i)(N-m,n-i)/(N,n)
  </code></pre>
  
  <p>for <code>i</code> from <code>k</code> to <code>min(m,n)</code>, where "<code>(m,i)</code>" represent a  binomial form.</p>
  
  <p>And the way I'm using R is:</p>
  
  <p><code>sum(choose(596+195,195:(195+596))*choose(15220-596-195,(1850+195)-195:(195+596)))/choose(15220,1850+195)</code>. </p>
  
  <p>I got <code>NaN</code>.</p>
  
  <p>Or using: <code>phyper(195,1850+195,15220-1850-195,596+195)</code>, I got 1.</p>
  
  <p>I also refer from link <a href="http://www.pangloss.com/wiki/VennSignificance" rel="nofollow">http://www.pangloss.com/wiki/VennSignificance</a>
  but when I caculate </p>
  
  <p><code>1 - phyper(448,1000,13800,2872)</code> in R, I got 0 instead 1.906314e-81 of the link.</p>
  
  <p>I am completely new to R and statistic, sorry for post many mistakes here.</p>