SCENIC icon indicating copy to clipboard operation
SCENIC copied to clipboard

Parallelization of runCorrelation

Open BenjaminDEMAILLE opened this issue 3 years ago • 2 comments

runCorrelation <- function (exprMat_filtered, scenicOptions) 
{
    registerDoParallel(makeCluster(parallel::detectCores()))
    exprMat_filtered <- t(exprMat_filtered)
    print("Do correlation")
    corrMat <- foreach(i = seq_len(ncol(exprMat_filtered)),
                       .combine = rbind,
                       .multicombine = TRUE,
                       .inorder = FALSE) %dopar% {
                         cor(exprMat_filtered[,i], exprMat_filtered, method = 'spearman')
}

    saveRDS(corrMat, file = getIntName(scenicOptions, "corrMat"))
}

Hello ! is it possible to update runCorrelation to this ? mono core when analysing big dataset is very slow

BenjaminDEMAILLE avatar Sep 15 '22 16:09 BenjaminDEMAILLE

I think the idea is good, but I think the posted code is wrong. also, you need to be careful when use all cores to do the calculation, ram will easily overflow when dealing with big data, it's better to use scenicOptions defined ncores to have more control.

Polligator avatar Nov 04 '22 17:11 Polligator

what's wrong for you ? is preferable to use mcmapply ?

BenjaminDEMAILLE avatar Nov 05 '22 11:11 BenjaminDEMAILLE