2012年7月18日 星期三

[R] Hypergeometric Relationship to Fisher's exact test


通常用來做Enrichment analysis的方法不外乎是
(1) 
Binomial distribution probability

(2) Hypergeometric probability  P[X ≥ x] 的機率
ex. We have total 38574 probes, significance have 14558, then we take 53 probes and get 33 probes significance
[R code ]:   
P[X ≥ 33] P[X = 33]+P[X > 33] = 1-P[X ≤ 32]
dhyper(33, 14558, (38574-14558), 53 ) +
phyper(33, 14558, (38574-14558), 53, lower.tail = FALSE)
= 1 - phyper(32, 14558, (38574-14558), 53)

而此
Hypergeometric 機率又與Fisher's Exact Test 單尾檢定相同:
x <- matrix( c(33,20,14525,23996), ncol=2)
out <- fisher.test(x, alternative = "greater")
out$p.val = P[X ≥ 33]



+
-

+
33
14558-33
14558
-
20
24016-56
24016

53
38574-53
38574

沒有留言: