我想做几个基因的rna seq数据,测试在控制和治疗。要实现fisher.test,我需要一个针对每个基因的应急表,有没有办法在R中实现这一点,而不是为每个基因计算一个应急表?我是新来的,所以任何建议都是有帮助的。
我有计数数据和样本信息数据,
control1 treated1 control2 treat2 control3 treat3
ENSG00000000003 723 486 904 445 1170 1097
ENSG00000000005 0 0 0 0 0 0
ENSG00000000419 467 523 616 371 582 781 ENSG基因在哪里
发布于 2018-12-10 14:13:30
阅读您的数据:
dd <- read.table(header=TRUE,text="
control1 treated1 control2 treat2 control3 treat3
ENSG00000000003 723 486 904 445 1170 1097
ENSG00000000005 0 0 0 0 0 0
ENSG00000000419 467 523 616 371 582 781
")运行带有一些安全措施的for循环:
results <- list()
for (i in 1:nrow(dd)) {
m <- matrix(unlist(dd[i,]),nrow=2)
if (any(m>0)) {
results[[i]] <- fisher.test(m)
} else {
results[[i]] <- NA
}
}
names(results) <- rownames(dd)https://stackoverflow.com/questions/53706784
复制相似问题