コードは次のとおりです。問題は、計算が非常に遅いことです。
行列 、gene1
、gene2
およびどちらも同じ長さ (8000) ではありません
pos <- c()
neg <- c()
either <- c()
for(i in 1:ncol(both)){
x <- cbind(both[,i], gene1[,i], gene2[,i], neither[,i])
test <- apply(x, 1, function(s){fisher.test(matrix(s, nrow = 2),
alternative = "greater")$p.value})
pos <- c(test,pos)
test1 <- apply(x, 1, function(s){fisher.test(matrix(s, nrow = 2),
alternative = "less")$p.value})
neg <- c(test1, neg)
test2 <- apply(x, 1, function(s){fisher.test(matrix(s, nrow = 2))$p.value})
either <- c(test2, either)
}