From the Seurat v5 cheat sheet:
Since Seurat v5 object doesn’t require all assays have the same cells, Cells() is designed to get cell names of the default assay and colnames() is deigned to get cell names of the entire object
This operation reorders the default assay only
seurat_obj1 <- seurat_obj1[, common_cells]
This operation gets the colnames of the entire object which are validated and not required to be the same as the default assay
colnames(seurat_obj1)
What you should do:
common_cells <- intersect(Cells(seurat_obj1), Cells(seurat_obj2))
seurat_obj1[["RNA"]] <- subset(seurat_obj1[["RNA"]], cells = common_cells)
seurat_obj2[["RNA"]] <- subset(seurat_obj2[["RNA"]], cells = common_cells)
It's good to get into the habit of working with Seurat Assays inside the main object separately since that is how Seurat v5 operates on its component Assays.
Can you validate that there are even colnames present?
Yeah, I have printed
colnames(seurat_obj1)andcolnames(seurat_obj2), It's ok, I dont know why when I choose cells byseurat_obj1[, common_cells], its seems only choose cells but not order bycommon_cells