saezlab / decoupler-py

Python package to perform enrichment analysis from omics data.
https://decoupler-py.readthedocs.io/
GNU General Public License v3.0
157 stars 23 forks source link

Is run_aucell thread-safe to run in a multi-threaded script? #118

Closed pcm32 closed 5 months ago

pcm32 commented 5 months ago

Running AUCell for multiple gene sets can be time consuming, so ideally one would like to run multiple genesets in parallel. Given the current implementation of run_aucell, is this feasible and thread-safe? Or will it only work if the input is not an AnnData object that gets modified at the end? Thanks!

PauBadiaM commented 5 months ago

Hi @pcm32,

The way I coded it is that we run multiple genesets in parallel already using numba, and it does not matter what the input is (AnnData or dataframe). Hope this is helpful!

pcm32 commented 5 months ago

Thanks. Is there a way to control then the number of concurrent processes that would run should you give it various gene sets at the same time in the network? I'm assuming this is how you achieve the parallelisation, correct? Perhaps through a numba max number of processes?

PauBadiaM commented 5 months ago

By default it uses all available cores, but you can control the number of threads by changing this global parameter:

import numba as nb
nb.set_num_threads(n=32)

# Then run decoupler functions here