Probability of gene list overlap
3
19
Entering edit mode
12.9 years ago
Nasir ▴ 170

Is this the correct way to calculate the probability of overlap occurring by chance between two lists of unregulated genes generated from two independent experiments on the same tissue using the same platform?

I am using R phyper.

phyper(q, m, n, k, lower.tail = FALSE, log.p = FALSE)

where:
q=size of overlap-1;
m=number of upregulated genes in experiment #1;
n=(total number of genes on platform-m);
k=number of upregulated genes in experiment #2.

r gene overlap • 21k views
ADD COMMENT
2
Entering edit mode

Here is a good post on the stackexchange stats Q&A about hypergeometric for list overlap.

ADD REPLY
0
Entering edit mode

yes this is the correct way to do this.

ADD REPLY
0
Entering edit mode

Hello,

I just have a similar question: Can I use R phyper in the above way to calculate the probability of overlap occurring by chance between two lists of hit genes identified by two different algorithmsg on the same tissue?

Thank you very much!

ADD REPLY
0
Entering edit mode

I think yes, as long as the total number of genes is identical between both tries. Note that the probability is those of two independent random draws ('totally random'), that is maybe not such a good benchmark for a comparison of two algorithms.

ADD REPLY
0
Entering edit mode

are the 2 lists from the same cell type?

ADD REPLY
3
Entering edit mode
12.9 years ago
Michael 55k

Yes, this seems correct to me. Imagine an urn model with black an white balls in an urn from which balls are drawn without replacement. If the two experiments are independent, you can use either experiment to label the balls in the urn: m = number of white balls in the urn, n the number of black balls. Then repeat the drawing. What is the probability of drawing q or more of the same genes (hence q-1, the distribution includes q only for lower.tail = TRUE) (hence lower.tail = FALSE) white balls (significant in exp. A, gene-set size) in k draws(number of significant genes in experiment B, gene-set size).

ADD COMMENT
1
Entering edit mode
12.9 years ago
brentp 24k

I think that is mostly correct except that you probably want 1 - phyper(...).

Examples

The probability of out of ~20K genes (not accounting for -m). Having 10 shared out of 2 random subsets of 100 should be very small.

> 1 - phyper(10, 100, 20000, 100, log.p=F)
[1] 2.582823e-12

The number probability of having only 1 shared should be a bit larger:

> 1 - phyper(1, 100, 20000, 100, log.p=F)
[1] 0.08868589

Also search for hypergeometric here on biostar.

EDIT: you actually need to use:

> phyper(9, 100, 20000 - 100, 100, lower.tail=F)
ADD COMMENT
1
Entering edit mode

Michael, thanks! I missed that. :)

ADD REPLY
0
Entering edit mode

instead of using 1-phyper you could also set lower.tail=F, that's what OP did, thus this is both correct.

ADD REPLY
0
Entering edit mode

Yes, just double checked, both phyper with lower-tail=false and (1-phyper) give same results as Michael mentioned. Thank you all.

ADD REPLY
0
Entering edit mode

Hi Brent, I am bit confused, in the querry q=overlap -1 while in your answer you assume 10 shared out of 2 random subsets. You put 10 as it is and does not make q=9?

who is right here?

ADD REPLY
1
Entering edit mode
9.1 years ago

If you want to know what the chance is for exactly q+1 number of overlapping genes, you should subtract the the phyper function like this:

phyper(q, m, n, k, lower.tail = F) - phyper(q+1, m, n, k, lower.tail = F)

(with q the number of overlaps -1)

This is because phyper gives the chance for q+1 overlaps OR MORE. So subtracting q+2 will give you the probabability of EXACTLY q+1 overlaps.
I checked it with the following script which prints the probability distribution. The total sum of probabilities is exactly 1 here.

tot = 0
cat('o','p',sep=' ')
for (hits in 0:100){tot = tot + (phyper(q=hits-1,m=100,n=20000-100,k=100, lower.tail=F)-phyper(q=hits,m=100,n=20000-100,k=100, lower.tail=F))
cat(hits,phyper(q=hits-1,m=100,n=20000-100,k=100, lower.tail=F)-phyper(q=hits,m=100,n=20000-100,k=100, lower.tail=F),'\n',sep=' ')}
tot

I thought I'd mention this, because while I was reading this I was under the impression that the original answer asked for the chance for an EXACT number of overlaps.

ADD COMMENT

Login before adding your answer.

Traffic: 1152 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6