我有以下 pvalues 列表
pval.list <- list(list(a=c(0.05, 0.0001, 0.32, 0.45), b=c(0.1,0.12,0.01,0.06), c=c(0.1,0.12,0.01,0.06), d=c(0.01,0.02,0.03,0.04)),
list(e=c(0.04, NA, 0.232, 0.245), f=c(0.05, 0.01, 0.22, 0.54), g=c(0.005, 0.1, 0.032, 0.045)),
list(h=c(0.03, 0.01, NA, 0.4), i=c(0.5, 0.0001, 0.132, 0.045), j=c(0.005, 0.0001, 0.0032, 0.045), k=c(0.5, 0.1, 0.932, 0.545)),
list(l=c(0.022, NA, 0.32, 0.45), m=c(0.0589, 0.0001, NA, 0.0045)),
list(n=c(0.051, 0.01, 0.32, 0.45), o=c(0.05, 0.0001, 0.32, 0.45), p=c(0.05, 0.0001, 0.32, 0.45), q=c(0.05, 0.0001, NA, 0.45)),
list(r=c(NA, 0.001, 0.32, 0.45), s=c(0.05, 0.0001, NA, 0.45), t=c(0.05, 0.0001, 0.32, 0.45)))
我正在尝试将一个函数(见下文)应用于此列表:
Fisher.test <- function(p) {
Xsq <- -2*sum(log(p))
p.val <- 1-pchisq(Xsq, df = 2*length(p))
return(p.val)
}
按照@G.Grothendieck 的指示,我使用了这个命令:lapply(lapply(pval.list, Reduce, f = cbind), apply, 1, Fisher.test)
但是当列表中缺少值时,该方法不起作用。我尝试将其合并na.omit
为参数,lapply
但它不能解决问题。
我应该在函数中添加na.omit
作为参数吗?Fisher.test
谢谢