cont.table <- matrix(c(5, 1, 2, 12), nrow = 2, ncol = 2)
fisher.test(cont.table, alternative = "greater")
##
## Fisher's Exact Test for Count Data
##
## data: cont.table
## p-value = 0.007224
## alternative hypothesis: true odds ratio is greater than 1
## 95 percent confidence interval:
## 2.138 Inf
## sample estimates:
## odds ratio
## 22.96
load("/Users/tobias/Dropbox/Uni/Master/HT_Course/Module_8_EnrichmentAnalysis/toyFisher.RData")
rownames(toyExpr)
## [1] "gene_1" "gene_2" "gene_3" "gene_4" "gene_5" "gene_6" "gene_7"
## [8] "gene_8" "gene_9" "gene_10" "gene_11" "gene_12" "gene_13" "gene_14"
## [15] "gene_15" "gene_16" "gene_17" "gene_18" "gene_19" "gene_20" "gene_21"
## [22] "gene_22" "gene_23" "gene_24" "gene_25" "gene_26" "gene_27" "gene_28"
## [29] "gene_29" "gene_30" "gene_31" "gene_32" "gene_33" "gene_34" "gene_35"
## [36] "gene_36" "gene_37" "gene_38" "gene_39" "gene_40" "gene_41" "gene_42"
## [43] "gene_43" "gene_44" "gene_45" "gene_46" "gene_47" "gene_48" "gene_49"
## [50] "gene_50"
colnames(toyExpr)
## [1] "normal_1" "normal_2" "normal_3" "normal_4" "normal_5"
## [6] "normal_6" "normal_7" "normal_8" "normal_9" "normal_10"
## [11] "cancer_1" "cancer_2" "cancer_3" "cancer_4" "cancer_5"
## [16] "cancer_6" "cancer_7" "cancer_8" "cancer_9" "cancer_10"
givesP <- function(x) {
x$p.value
}
t_Parted <- function(x) {
t.test(x[1:10], x[11:20], var.equal = T)
}
result <- apply(toyExpr, 1, t_Parted)
x <- lapply(result, givesP)
pvalue <- unlist(x)
fdr_v <- p.adjust(pvalue, method = "fdr")
table(names(which(fdr_v < 0.01)) %in% toyGOterm$GO_1)
##
## FALSE TRUE
## 1 9
table(names(which(fdr_v > 0.01)) %in% toyGOterm$GO_1)
##
## FALSE TRUE
## 38 2
# for GO_1
ct.go1 <- matrix(c(9, 1, 2, 38), 2, 2)
fisher.test(ct.go1)
##
## Fisher's Exact Test for Count Data
##
## data: ct.go1
## p-value = 2.099e-07
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 11.11 7143.45
## sample estimates:
## odds ratio
## 126.6
Man sollte hier der alternativhypothese folgen
table(names(which(fdr_v < 0.01)) %in% toyGOterm$GO_2)
##
## FALSE TRUE
## 8 2
table(names(which(fdr_v > 0.01)) %in% toyGOterm$GO_2)
##
## FALSE TRUE
## 29 11
# for GO_2
ct.go2 <- matrix(c(2, 8, 11, 29), 2, 2)
fisher.test(ct.go2)
##
## Fisher's Exact Test for Count Data
##
## data: ct.go2
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.0598 4.1269
## sample estimates:
## odds ratio
## 0.6643
Es ist zufall -> Go-Term sollte für die verschiedenen Gene abgehlehnt werden