Hi all, I have a Seurat object from which I removed the data from the image slot before I performed an integration (by splitting the object):
# Save the spatial information to an object
spatial_information <- breast_cancer_patients_no_rbc@images
# Remove the spatial information from the new Seurat object
breast_cancer_patients_no_rbc_no_spatial@images <- list()
# Split the global Seurat object by patient
breast_cancer_patients_split <- SplitObject(breast_cancer_patients_no_rbc_no_spatial, split.by = "Patient.ID")
After performing the integration, merging all the subsets and other operations I added back the spatial data:
# Add back the spatial data
breast_cancer_patients_all_cells@images <- spatial_information
The problem is that setting the default boundary throws a warning:
DefaultBoundary(patient_data[[patient_image]]) <- "segmentation"
Warning message:
Adding image with unordered cells
This seems to be because the order of the cells in the metadata is not the same as the order of the cells in the image slot. I tried to change the order in the metadata but then Seurat complains about a misalignment between the metadata and the assays. Reordering the centroids in the image slot also does not solve the problem. Do you know how I can fix this warning? The cells are the same because:
> identical(patient_data@images$LU001FFP03@boundaries$centroids@cells, rownames(patient_data@meta.data))
[1] TRUE
Thank you!
Have you tried reordering your cells in your
spatial_information
before importing it intobreast_cancer_patients_all_cells
?spatial_information (SeuratObject::FOV) is a rather complicated object which contains many other objects (like SeuratObject::Centroids and SeuratObject::Segmentation) and I can not find a way to sort it properly, this is what I tried (it does not work):
But honestly I do not fell like this is the right approach :(
It is hard to say what is "not working" without an overview of what your data look like, or the architecture of your spatial objects.
Do you have to integrate, maybe just SCTransform is enough ? What is your experimental design ? Do you have controls ?
I guess you sequenced your patient independently, did you merge your expression matrices ? what did you do with the spatial context ?
I started my analysis with a single Seurat object and used
SplitObject(object, split.by = "ident")
to split by Patient ID. The problem with this approach is that when merging back the objects the spatial data is not correctly handled. I solved the problem by splitting as explained by the integration vignette of Seurat 5, it differs in that you can choose which assays to split and the split is done by creating separated layers instead of separated objects.