GO 数据库提供了层次关系数据库,主要有有向无环图 (DAG) 构建,有父节点和子节点,且子节点可能会属于多个父节点。在最顶部有三个父节点: BP BF CC,层次关系最低端有一些基因或蛋白组成。
表格数据,富集分析就是一种列联表检验的方式。R 提供了一些函数分析列联表数据
prop.test()
可基于比例进行分析
单比例的检验基于二项分布。例如,215名病人的39名被观测到患有哮喘(样本),然后对“随机病人”患有哮喘的概率是0.15这个假设做检验(总体)
prop.test(39,215,0.15)
##
## 1-sample proportions test with continuity correction
##
## data: 39 out of 215, null probability 0.15
## X-squared = 1.425, df = 1, p-value = 0.2326
## alternative hypothesis: true p is not equal to 0.15
## 95 percent confidence interval:
## 0.1335937 0.2408799
## sample estimates:
## p
## 0.1813953
也可以用函数binom.test在二项分布下做检验,这是能得到精确的检验概率
binom.test(39,215,0.15)
##
## Exact binomial test
##
## data: 39 and 215
## number of successes = 39, number of trials = 215, p-value = 0.2135
## alternative hypothesis: true probability of success is not equal to 0.15
## 95 percent confidence interval:
## 0.1322842 0.2395223
## sample estimates:
## probability of success
## 0.1813953
prop.test()也能用于比较两个或多个比例,此时参数应该是向量
lewitt.machin.success <- c(9,4)
lewitt.machin.total <- c(12,13)
prop.test(lewitt.machin.success,lewitt.machin.total)
##
## 2-sample test for equality of proportions with continuity
## correction
##
## data: lewitt.machin.success out of lewitt.machin.total
## X-squared = 3.2793, df = 1, p-value = 0.07016
## alternative hypothesis: two.sided
## 95 percent confidence interval:
## 0.01151032 0.87310506
## sample estimates:
## prop 1 prop 2
## 0.7500000 0.3076923
chisq.test()
可用于卡方检验,接受一个矩阵作为参数
卡方检验思想: H0,行变量和列变量没有关联性; H1,行变量和列变量存在关系。
统计检验思想: 把无效果或不感兴趣的结论作为零假设,然后计算零假设下产生观测数据的概率(p-value),如果这个该路很小(零假设、模型或数据错了),则拒绝零假设
x <- matrix(c(8,1264,88,11279),byrow = T,nrow = 2)
x
## [,1] [,2]
## [1,] 8 1264
## [2,] 88 11279
chisq.test(x)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: x
## X-squared = 0.15645, df = 1, p-value = 0.6924
在零假设下,不同列(结果)在每一行(处理)的比例应该相同,通过定义一个卡方统计量\(\chi^2\),卡方统计量会近似服从卡方分布
\(\chi^2 = \sum\frac{(观测值-期望值)^2}{期望值}\)
\(df = (r-1)\times(c-1)\)
对于 2x2的表来说,使用卡方检验时要注意,每个单元格的期望值要大于等于5
如果任何一个单元格的期望频数小于 5,卡方统计量不近似服从卡方分布,会导致错误 P 值,这里应该使用 Fisher’s exact test,也称为超几何分布检验
a <- data.frame(matrix(c("a","b","a+b","c","d","c+d","a+c","b+d","n"),byrow = F,ncol = 3))
colnames(a) <- c("men","women","total")
rownames(a) <- c("dieting","not dieting","totals")
a
## men women total
## dieting a c a+c
## not dieting b d b+d
## totals a+b c+d n
定义出现这个观测数据服从一个超几何分布,则得到某个观测的概率为
\(\frac{\binom{a+b}{a}\star\binom{c+d}{c}}{\binom{n}{a+c}}\)
x <- matrix(c(1,9,11,3),nrow = 2,byrow = T)
x
## [,1] [,2]
## [1,] 1 9
## [2,] 11 3
# 默认是双侧检验
fisher.test(x)
##
## Fisher's Exact Test for Count Data
##
## data: x
## p-value = 0.002759
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.0006438284 0.4258840381
## sample estimates:
## odds ratio
## 0.03723312
# 单侧检验
fisher.test(x,alternative = "less")
##
## Fisher's Exact Test for Count Data
##
## data: x
## p-value = 0.00138
## alternative hypothesis: true odds ratio is less than 1
## 95 percent confidence interval:
## 0.0000000 0.3260026
## sample estimates:
## odds ratio
## 0.03723312
许多富集的GO term 含义比较广泛,不能帮助更好地聚集研究路线。因为针对 2x2 列联表的统计检验,如Fisher’s test、Chi-square test,如果把列联表的四个数都乘以 10,富集比例不变,但 P-value会变得更显著。这些广义的GO term集合包含的基因数目多,它们更容易得到显著的 P-value
GO term组成一个类似树状的关系图,term从树根到树叶是广义到特异的关系,在树中临近的GO terms含义相关,也包含许多共同的基因,所以富集结果中会看到冗余的 GO term富集
改进1: 把GO term的关系树画出来,富集的程度用颜色表示,很直观地看到相邻 term 富集程度的渐变
改进2: 在感兴趣的或富集分析得到生物通路图,如在KEGG中,用颜色标出表达变化的基因,帮助看到变化的通路节点或分支
改进3: 相比GO terms,生物通路数量少一些,相互也更独立些,所以可以用热图同时展示多个通路在不同条件下差异表达基因的富集情况