-
Notifications
You must be signed in to change notification settings - Fork 946
ScaleData() fails with “all cells in assays must be present in the Seurat object” error #9860
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
Comments
Can you provide reproducible example (ideally using public object (eg from SeuratData package)? I cannot replicate issues currently in my testing suggesting it may be issue with the Seurat object you are using. Best, |
It don’t happen with seurat 5.2
|
The full code is NeuroProx_sub <- subset(NeuroProx, downsample = 1000)
markers_f
NeuroProx_sub <- ScaleData(NeuroProx_sub, assay = "RNA", features = markers_f$gene)
Centering and scaling data matrix
|===========================================================================================================| 100%
Error in validObject(object = x) :
invalid class “Seurat” object: all cells in assays must be present in the Seurat object |
The problem is due to the subset : > NeuroProx <- NeuroProx[, NeuroProx$Phase == "S"]
> validObject(NeuroProx)
Error in validObject(NeuroProx) :
invalid class “Seurat” object: all cells in assays must be present in the Seurat object
> NeuroProx <- qread("20250401_NeuroProx_velo.qs", nthreads = detectCores())
> validObject(NeuroProx)
[1] TRUE |
Ok thanks. I’ll look into it. |
Title: ScaleData() fails with “all cells in assays must be present in the Seurat object” error
Description:
Calling ScaleData() on a subsetted Seurat object leads to an error about assay cell mismatch, even though the object was previously subsetted and appears valid.
Code to reproduce:
Output:
Troubleshooting attempted:
Verified that markers_f$gene contains genes present in the RNA assay.
Checked that NeuroProx_sub is a valid Seurat object using ValidObject().
Assay "RNA" exists and is the default assay in NeuroProx_sub.
Environment:
Seurat version: 5.3
SeuratObject version: 5.1
R version: 4.5.0
Suggestion:
The error message suggests a mismatch between the cells in the RNA assay and the Seurat object. This might be due to residual cells in the assay slot after subsetting. If so, ScaleData() should better handle such cases or validate the object earlier with a more informative message.
The text was updated successfully, but these errors were encountered: