以下是代码:问题是计算很慢。
矩阵 ,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)
}