fix the JoinLayers logic inside scVI.R#228
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes scVI integration when using SCTransform by avoiding JoinLayers() on SCTAssay objects (which don’t implement JoinLayers() and are already represented as a single matrix), and by splitting batch labels via SCT model identifiers instead of layers.
Changes:
- Skip
JoinLayers()when the input is anSCTAssay, preventing the reportedJoinLayers.SCTAssaydispatch error. - Refactor batch construction logic by separating SCT-specific batch detection into a new
.FindSCTBatches()helper. - Update internal roxygen describing how batches are computed (StdAssay-by-layer vs SCT-by-model).
Comments suppressed due to low confidence (1)
R/scVI.R:208
- There are multiple trailing blank lines at the end of the file after
.FindSCTBatches(). Please remove the extra empty lines to keep file formatting consistent with the rest of the R sources in this repo.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
940bcca to
d64f6f4
Compare
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 is a bug reported by multiple users (e.g., #209) and have been confirmed. This is caused by the fact that
JoinLayers()does not supportSCTAssay(SCTAssay is already a single matrix, so no need to join), so when performing scVI integration with SCT-corrected assay, users will run into error.To reproduce this error, one can run
This PR proposes a fix which was originally from https://github.com/satijalab/project-management/issues/131. Basically, now when SCTAssay is used for scVI integration, the function will perform a check on the object type, and skip the JoinLayers() if it is SCTAssay.