使用 parallel 包并行处理 R 脚本:优化微生物组数据
library(parallel) cl <- makeCluster(detectCores()) clusterExport(cl, 'physeq1') physeq1 <- parLapply(cl, 1:ncol(physeq@otu_table), function(i) { sapply(physeq@otu_table[,i], function(x) ifelse(x<=sum(physeq@otu_table[,i])*0.0005, 0, x)) }) stopCluster(cl)
将结果合并为一个数据框
physeq1@otu_table <- as.data.frame(physeq1) colnames(physeq1@otu_table) <- colnames(physeq@otu_table)
原文地址: https://www.cveoy.top/t/topic/oUqj 著作权归作者所有。请勿转载和采集!