Parallelize get_predicted_CNV_regions #350
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running with
HMM_report_by='cell'
, the time spent inget_predicted_CNV_regions
dominates total runtime as each cell is processed sequentially. This pull request parallelizes the bulk of the loop to speed up runtime. When the number of cells is over 10k, this can reduce the runtime from days to hours.The
parallel
framework was used because it is already imported ininferCNV_BayesNet.R
.mclapply
parallelizes the loop over the number of cores specifed bynum_threads
wheninfercnv::run()
is called.Note that parallel refactoring was complicated by the counter variable that ensures unique names for cnv regions. The workaround was to assign the region names in a loop at the end, after parallel execution. This has the same effect as incrementing a counter, but means that the call to
.get_cnv_gene_region_bounds
must be placed outside the parallel loop. The function is simple enough that running it on a single core won't significantly delay overall runtime.