pvalue for go kegg enrichment

 

Simple, fast implementation of Fisher’s exact test. . For example, for the following table:

oHaving the propertyNot having the property
Selected125
Not selected292

Perhaps we are interested in whether there is any difference of property in selected vs. non-selected groups, then we can do the Fisher’s exact test.

def fish_test(sample_hit, pop_hit, sample_count, root_count):
### sample_hit: 该样本中基因属于该term下面的个数
### pop_hit: 该物种的所有基因属于该term下面的个数
### sample_count: 样本中基因的个数
### root_count: 该物种在bp/cc/mf root 下基因的个数
sample_hit = int(sample_hit)
pop_hit = int(pop_hit)
sample_count = int(sample_count)
root_count = int(root_count)
sample_nhit = sample_count - sample_hit
pop_nhit = root_count - pop_hit
n1,n2,n3,n4 = (sample_hit, pop_hit - sample_hit,
sample_nhit, pop_nhit - sample_nhit)
p = abs(pvalue(n1,n2,n3,n4).right_tail)
return p

 

使用公式 phyper(k-1,M, N-M, n, lower.tail=FALSE)
     那么做为背景,总体基因为N,属于“化学刺激响应”这个分类的基因有M个。
     现在抽了n个基因,里面有k个基于这个分类,p值为
针对下面这个通路我做了计算, 和 用Python 包算的一致.
> phyper(16-1,45,7057-45,98,lower.tail=FALSE)
[1] 2.503033e-19
> phyper(11-1,48,7057-48,98,lower.tail=FALSE)
[1] 3.09068e-11
 
 
IndexPathway NamePathway IDPvaluePvalue_adjustedGenesCountPop HitList_TotalBackground GenesClass
1ABC transportershsa020102.50e-194.71e-17                                             ABCA6|1.00                                            ABCC8|1.00                                            ABCG2|1.00                                            ABCG8|1.00                                            ABCB5|1.00                                            ABCB6|1.00                                            ABCC9|1.00                                            ABCC11|1.00                                            ABCA1|1.00                                            ABCA7|1.00                                            ABCA9|1.00                                            ABCA12|1.00                                            ABCB8|1.00                                            ABCB9|1.00                                            ABCG4|1.00                                            ABCG5|1.00                                         1645987057Environmental Information Processing
2Fatty acid metabolismhsa012123.09e-112.91e-09                                             ACADSB|1.00                                            SCD|1.00                                            ACOX1|1.00                                            ACSL3|1.00                                            ACSL4|1.00                                            ACSL1|1.00                                            ACSL5|1.00                                            ACACA|1.00                                            ACADL|1.00                                            ACADM|1.00                                            ACSBG1|1.00                                         1148987057Metabolism

转载于:https://www.cnblogs.com/xiaojikuaipao/p/7922792.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值