What does this test do?
- decides if two (or more) proportions differ significantly
- Example I:
- in group A, 20 out of 40 animals survived (proportion = 0.5)
- in group B, 5 out of 25 animals survived (proportion = 0.2)
- is there a statistically significant difference between these proportions?
- Example II (enrichment analysis, differentially expressed genes):
- in a test group, 10 of 20 genes are up-regulated (proportion = 0.5)
- in a control group, 15 of 20 genes are up-regulated (proportion = 0.75)
- is there a statistically significant difference between these proportions?
- (or, are the up-regulated genes enriched in the control group)
- can also be seen as test of independence:
- is the survival rate independent of the group membership? (example I)
- is the gene regulation independent of the group membership? (example II)
- the test works only for relativly low numbers (high computational workload)
- for larger numbers, use the
prop.test()
function (next chapter)
- \(H_0\) : \(p_1 = p_2\) (equal proportions, independence)
- a small p-value means that the null is rejected, i.e. that the proportions differ significantly
- function:
fisher.test()
- entries should be nonnegative integers
Running the test
x <- matrix(c(2,10,20,13), ncol=2, byrow=T)
x
## [,1] [,2]
## [1,] 2 10
## [2,] 20 13
fisher.test(x)
##
## Fisher's Exact Test for Count Data
##
## data: x
## p-value = 0.01655
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.01256709 0.78740829
## sample estimates:
## odds ratio
## 0.1360765
Reading the output
The point estimate for the odds ratio is calculated as \(\frac{2 \cdot 13}{10 \cdot 20} = 0.13\) in this case. The confidence interval refers to the odds ratio, i.e. the given interval includes the true value with 95% chance. For this example, \(H_0\) is rejected, i.e. the proportions are significantly different (no independence).