Fix SCTransform umi.assay incorrect source assay labels#10330
Open
YoukaiFromAccounting wants to merge 4 commits intomainfrom
Open
Fix SCTransform umi.assay incorrect source assay labels#10330YoukaiFromAccounting wants to merge 4 commits intomainfrom
YoukaiFromAccounting wants to merge 4 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect umi.assay provenance recorded in SCTModel.list after running SCTransform.Seurat() on non-RNA assays when multiple SCT models are present, preventing downstream failures/misbehavior (e.g., in PrepSCTFindMarkers).
Changes:
- Update
SCTransform.Seurat()to setumi.assayfor every model inSCTModel.list, not just the first. - Reassign the updated model list back into the resulting
SCTassay so all models consistently track the source assay.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+4292
to
+4299
| # Extract all SCT models stored in assay | ||
| sct_models <- slot(object = assay.data, name = "SCTModel.list") | ||
|
|
||
| # Update umi.assay field for every SCT model | ||
| for (i in seq_along(sct_models)) { | ||
| slot(object = sct_models[[i]], name = "umi.assay") <- assay | ||
| } | ||
| slot(object = assay.data, name = "SCTModel.list") <- sct_models |
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.
Fixes: #10323
Previously, SCTransform.Seurat() was hard-coded to only updated the umi.assay field for the first entry in SCTModel.list:
For objects with multiple SCT models, such as those created from multiple samples or layers, the remaining models did not have their source assay updated correctly, which would remain at the default "RNA" source assay. This would cause issues with downstream functions such as PrepSCTFindMarkers.
This simple change updates umi.assay for every model in SCTModel.list, so all SCT models consistently record the assay used to run SCTransform(). With these changes, individual SCT models should now correctly have their source assay assigned following SCTransform().
Reproducible example: