-
Notifications
You must be signed in to change notification settings - Fork 16
feat: Support count_mat as BPCells matrix
#91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This will enable users to use `BPCells` to save RAM.
|
Can you give more of an explanation of what this PR is doing? Can users not use the Just briefly looking at the PR, I don't like all of the duplication and I worry about depending on on a v0.3.0 of a library |
|
Sorry about that my initial PR was a bit minimal in terms of explanation. I should have provided more context on the motivation of this PR. Thanks for pointing it out! The original For example, to create This operation will not actually load the whole matrix. We can then create the The actual logic is Regarding your concerns:
Let me know if you'd be open to including this functionality — I'm happy to make further adjustments if you'd prefer a different direction. Also I completely understand if you’d prefer to avoid adding a dependency on BPCells at this stage. Thanks again for taking the time to review this — really appreciate your work on |
|
After thinking about it, I think adding BPCell support would be a great feature. Seems like it is popular enough - Seurat even has vignettes encouraging using it. Maybe for cleaning up the code we can:
Thanks again |
|
Thanks for the detailed reply — really appreciate the constructive feedback and your willingness to support this feature! Your suggestions on simplifying the logic and separating out the internal One small thing to flag in advance: when using My current workaround is to let BPCells write the matrix part, then manually delete and rewrite the |
Thank you for pointing out the shortcoming of |
|
Just checking in. Any update on this? |
|
Sorry for the delayed response. I finally get back from my full-time job. T^T The current version has merged the logic of For the unit tests, I did not merge the |
esiegel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Fix the lints and I think we can land. Thanks again
R/validate.R
Outdated
| validate_count_mat <- function(count_mat, feature_ids = NULL) { # nolint: cyclocomp_linter. | ||
| if (!is(count_mat, "dgCMatrix")) { | ||
| return(err("count_mat must be a dgCMatrix")) | ||
| if (!is(count_mat, "dgCMatrix") & !inherits(count_mat, "IterableMatrix")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix this lint error
| } | ||
| if (any(is.infinite(count_mat@x))) { | ||
| return(err("matrix values must not be infinite")) | ||
| if (inherits(count_mat, "dgCMatrix")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we avoiding this check because the matrix will be large? Or is this unsupported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, only dgCMatrix has the slot x, while IterableMatrix from BPCells does not.
tests/testthat/helper.R
Outdated
| #' Create a sparse count_mat with BPCells | ||
| #' | ||
| #' @importFrom Matrix rsparsematrix | ||
| create_count_mat_BPCells <- function(rows, cols, valid_barcodes = FALSE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess call this create_count_mat_bpcells to satisfy the linter.
| testthat (>= 3.0.0), | ||
| Matrix, | ||
| SeuratObject (>= 5.0.0) | ||
| SeuratObject (>= 5.0.0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might also need to add a REMOTES section so that the CI knows where/how to download bpcells.
Remotes:
github::bnprks/BPCells/r
Copy Seurat-Object and add an extra R repository to fetch BPCells. Using the REMOTES section within the DESCRIPTION only worked on Windows. On linux and mac it was failing to untar the source.
esiegel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the PR. Everything is building and looks good
| r-version: ${{ matrix.config.r }} | ||
| http-user-agent: ${{ matrix.config.http-user-agent }} | ||
| use-public-rspm: true | ||
| extra-repositories: 'https://bnprks.r-universe.dev' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied what Seurat-Object is doing to unbreak the CI builds
This will enable users to use
BPCellsmatrix to save RAM.