From 19ec11235171963e72b14d81dd3983ffa53fb3b7 Mon Sep 17 00:00:00 2001 From: Abhishek Sarkar Date: Thu, 28 Mar 2024 10:24:23 -0500 Subject: [PATCH] Reduce memory usage in compute_lfc_stats_multicore --- R/lfc.R | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/R/lfc.R b/R/lfc.R index 1a90cb01..88ebe1a8 100644 --- a/R/lfc.R +++ b/R/lfc.R @@ -104,21 +104,16 @@ compute_lfc_stats_multicore <- function (X, F, L, f0, D, U, M, lfc.stat, # Split the data. nsplit <- min(m,nsplit) cols <- splitIndices(m,nsplit) - dat <- vector("list",nsplit) - for (i in 1:nsplit) { - j <- cols[[i]] - dat[[i]] <- list(X = X[,j,drop = FALSE],F = F[j,,drop = FALSE],f0 = f0[j]) - } # Distribute the calculations using pblapply. - parlapplyf <- function (dat, L, D, U, M, lfc.stat, conf.level, rw, e) - compute_lfc_stats(dat$X,dat$F,L,dat$f0,D,U,M,lfc.stat,conf.level,rw,e, + parlapplyf <- function (c, X, F, L, f0, D, U, M, lfc.stat, conf.level, rw, e) + compute_lfc_stats(X[,c],F[c,],L,f0[c],D,U,M,lfc.stat,conf.level,rw,e, verbose = FALSE) if (verbose) op <- pboptions(type = "txt",txt.width = 70) else op <- pboptions(type = NULL) - ans <- pblapply(cl = nc,dat,parlapplyf,L,D,U,M,lfc.stat,conf.level,rw,e) + ans <- pblapply(cl = nc,cols,parlapplyf,X,F,L,f0,D,U,M,lfc.stat,conf.level,rw,e) pboptions(op) # Combine the individual compute_lfc_stats outputs, and output the