Improve parallel processing with BiocParallel - #163
Open
dimalvovs wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors distributed CoGAPS execution to reduce per-worker memory usage by subsetting in-memory data before dispatching to BiocParallel workers, and introduces a skipInternalSubset flag to avoid redundant subsetting inside workers. It also updates the internal API documentation, adds tests covering the new subsetting behavior, and bumps the package version/date.
Changes:
- Subset in-memory
data/uncertaintyper subset before callingcallInternalCoGAPS, usingskipInternalSubset=TRUEto bypass internal subsetting. - Adjust default worker count selection to depend on available CPU cores rather than
nSets. - Add tests verifying subsetting behavior and a new “nSets > workers” scenario; update Rd docs; bump DESCRIPTION version/date.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| R/DistributedCogaps.R | Implements per-worker in-memory subsetting and adds skipInternalSubset; adjusts default BiocParallel worker selection. |
| tests/testthat/test_DistributedCogaps.R | Adds tests asserting workers receive subsetted data and that runs succeed when nSets exceeds workers. |
| man/callInternalCoGAPS.Rd | Documents the new skipInternalSubset argument in the internal wrapper API. |
| DESCRIPTION | Bumps package version and updates release date. |
Files not reviewed (1)
- man/callInternalCoGAPS.Rd: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
83
to
+87
| if (is.null(allParams$BPPARAM)) | ||
| allParams$BPPARAM <- BiocParallel::MulticoreParam(workers=length(sets)) | ||
|
|
||
| { | ||
| cores <- min(length(sets), parallel::detectCores()) | ||
| allParams$BPPARAM <- BiocParallel::MulticoreParam(workers=max(1, cores-2)) | ||
| } |
|
|
||
| cg <- CoGAPS(mat, | ||
| params = params, | ||
| BPPARAM = BiocParallel::MulticoreParam(workers=1), |
Contributor
Author
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


This pull request introduces improvements to how distributed CoGAPS handles in-memory data partitioning for parallel workers, ensuring that each worker receives only the relevant subset of the data, which reduces memory usage and improves efficiency. It also adds a new parameter to control internal subsetting, updates documentation, and adds comprehensive tests to verify the new behavior.
Test results
Below are the test results of the memory footprint and execution speed (project - this branch, bau - master branch).
Enhancements to distributed data handling:
R/DistributedCogaps.R: Refactored the distributed execution logic so that, when data is in-memory, each worker receives only the subset it needs, and a newskipInternalSubsetparameter is used to bypass redundant subsetting within the worker. [1] [2] [3]Parallel processing:
R/DistributedCogaps.R(https://github.com/Improve parallel processing with BiocParallel #163/commits/3ae5dbff7e939b65a64aad6ffcf6c22a4affe71e): Now number of workers depends on available cpus rather than nSets. This avoids spawning too many workers when there are little CPUs available.API and documentation updates:
R/DistributedCogaps.R,man/callInternalCoGAPS.Rd: Added theskipInternalSubsetargument tocallInternalCoGAPS, updated function signatures, and improved documentation to reflect the new parameter and its usage. [1] [2] [3]Testing improvements:
tests/testthat/test_DistributedCogaps.R: Added new tests to ensure that distributed workers receive only the relevant subset of data, that memory usage is reduced, and that the new logic works for both "genome-wide" and "single-cell" modes as well as when there are more data subsets than workers.Version update:
DESCRIPTION: Bumped the package version to 3.33.3 and updated the release date.