Skip to content

Issue in merging two SCTransformed Seurat objects in version 5 #9802

Open
@KirSha06

Description

@KirSha06

Hi,
I am trying to merge two Seurat objects (C and F) into a single Seurat object. These two objects are SCTransformed, keeping RNA as default assay. But when I am trying to merge them. It is showing me this error and I couldn't solve this.

DefaultAssay(C) <- "RNA"
DefaultAssay(F) <- "RNA"
C.sct <- SCTransform(C, vars.to.regress = "percent.mt", verbose = FALSE)
F.sct <- SCTransform(F, vars.to.regress = "percent.mt", verbose = FALSE)

Warning: Different cells and/or features from existing assay SCTWarning: Different cells and/or features from existing assay SCT
It is showing this warning, but i don't know I have to worry about it or not.

shared_features <- intersect(Features(C), Features(F))
slct_features = head(rownames(C))
    tmp_SCT_features_attributes = slot(object = C[["SCT"]], name = "SCTModel.list")[[1]]@feature.attributes 
    tmp_SCT_features_attributes = tmp_SCT_features_attributes[shared_features, ]
    slot(object = C[["SCT"]], name = "SCTModel.list")[[1]]@feature.attributes = tmp_SCT_features_attributes
    C.NEW = subset(C, features = shared_features)
slct_features = head(rownames(F))
    tmp_SCT_features_attributes = slot(object = F[["SCT"]], name = "SCTModel.list")[[1]]@feature.attributes 
    tmp_SCT_features_attributes = tmp_SCT_features_attributes[shared_features, ]
    slot(object = F[["SCT"]], name = "SCTModel.list")[[1]]@feature.attributes = tmp_SCT_features_attributes
    F.NEW = subset(F, features = shared_features)
merged.new <- merge(cmv.sct_new, y = flu.sct_new,
                 merge.data = TRUE)

Error in rbind(new_residual, old_residuals) :
number of columns of matrices must match (see arg 2)
and after this step; I got this error and unable to merge.
I want not facing any issue in merging datasets in Seurat v4 but once I start working in v5, this error occurs. Can you help me out in fixing this error ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions