aertslab / SCENIC

SCENIC is an R package to infer Gene Regulatory Networks and cell types from single-cell RNA-seq data.
http://scenic.aertslab.org
GNU General Public License v3.0
394 stars 94 forks source link

Parallelization of runCorrelation #337

Open BenjaminDEMAILLE opened 1 year ago

BenjaminDEMAILLE commented 1 year ago
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

Polligator commented 1 year ago

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.

BenjaminDEMAILLE commented 1 year ago

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