我有 17 个 filebacked big.matrix 对象(dim 10985 x 52598,每个 4.3GB),我想计算其中的元素平均值。结果可以存储在另一个 big.matrix (gcm.res.outputM) 中。
biganalytics::apply() 不起作用,因为 MARGIN 只能设置为 1 或 2。我尝试使用 2 for 循环,如此处所示
gcm.res.outputM <- filebacked.big.matrix(10958, 52598, separated = FALSE, backingfile = "gcm.res.outputM.bin", backingpath = NULL, descriptorfile = "gcm.res.outputM.desc", binarydescriptor = FALSE)
for(i in 1:10958){
for(j in 1:52598){
t <- rbind(gcm.res.output1[i,j], gcm.res.output2[i,j],gcm.res.output3[i,j], gcm.res.output4[i,j],
gcm.res.output5[i,j], gcm.res.output6[i,j],gcm.res.output7[i,j], gcm.res.output8[i,j],
gcm.res.output9[i,j], gcm.res.output10[i,j],gcm.res.output11[i,j], gcm.res.output12[i,j],
gcm.res.output13[i,j], gcm.res.output14[i,j],gcm.res.output15[i,j], gcm.res.output16[i,j],
gcm.res.output17[i,j])
tM <- apply(t, 2, mean, na.rm = TRUE)
gcm.res.outputM[i,j] <- tM
}
}
每行 i 大约需要 1.5 分钟,因此运行大约 11 天。
有人对如何加快计算速度有任何想法吗?我正在使用具有 16GB RAM 的 64x Windows10 机器。
谢谢!