satijalab / seurat-object

https://satijalab.github.io/seurat-object/
Other
24 stars 25 forks source link

Error when subsetting a joint Seuratobject #195

Open moutazhelal opened 7 months ago

moutazhelal commented 7 months ago

Thank you for getting to my issue

I'm encountering an issue while attempting to subset my Seurat object and subsequently splitting it. The error message I'm encountering is as follows

Splitting ‘counts’, ‘data’ layers. Not splitting ‘scale.data’. If you would like to split other layers, set in layers argument.
Error in split():
! The following layers are already split: ‘counts’, ‘data’ Please join before splitting
Run rlang::last_trace() to see where the error occurred.

When attempting to apply functions such as NormalizeData or ScaleData to the object, I consistently encounter this error, and the code never completes execution.

Normalizing layer: counts
Performing log-normalization
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Error in fn():
! Cannot add new cells with [[<-
Run rlang::last_trace() to see where the error occurred.

When I print the myeloid_cells object, I notice a reduction in the number of cells, indicating a focus on specific cell types or criteria.

An object of class Seurat
36620 features across 21912 samples within 2 assays
Active assay: RNA (36601 features, 2000 variable features)
3 layers present: data, counts, scale.data
1 other assay present: HTO
4 dimensional reductions calculated: pca, umap, harmony, umap.harmony

Upon investigation of my Seurat object, I discovered that myeloid_cells@assays[["RNA"]] contains the same number of cells as the original object, which was 45635

myeloid_cells@assays[["RNA"]]

Assay (v5) data with 36601 features for 45635 cells
Top 10 variable features:
IGHG1, IGHGP, GNLY, IGHG3, JCHAIN, IGKC, CXCL10, IGHA1, CXCL9, SPP1
Layers:
data, counts, scale.data

Upon inspecting the layers of the RNA assay, I observed that the data and counts layers contain a number of cells equal to the subsetted data. However, I noticed that themyeloid_cells@assays[["RNA"]]@cells section in the object still retains the original number

myeloid_cells@assays[["RNA"]]@cells

A logical map for 45635 values across 10 observations

When printing myeloid_cells@assays[["RNA"]]@cells as a matrix I encountered a matrix with scale.data.x columns where x is the same number as the objects I joined

maybe this why it we get this error however I am not sure how to resolve this.

Thank you very much for any help