This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Seurat merge and batch correction

Hello.

I want to merge 7 Seurat objects and do batch correction. How can I do this?

I'm going to use the merge() function to merge seurat objects. If there is another better way, please let me know.

seurat

1 answer

You can merge your seven Seurat objects and perform integration using Seurat V5 to remove the batch effect-

library(Seurat)
library(ggplot2)
library(patchwork)

#first merge your seven Seurat objects:
SeuratObj <- merge(SeuratObj1, y = c(SeuratObj2, SeuratObj3, SeuratObj4,SeuratObj5, SeuratObj6, SeuratObj7), add.cell.ids = c("subj1", "subj2", "subj3","subj4", "subj5", "subj6", "subj7"), project = "test_project")

#Perform these before integration 
SeuratObj <- NormalizeData(SeuratObj)
SeuratObj <- FindVariableFeatures(SeuratObj)
SeuratObj <- ScaleData(SeuratObj)
SeuratObj <- RunPCA(SeuratObj)

SeuratObj <- FindNeighbors(SeuratObj, dims = 1:30, reduction = "pca")
SeuratObj <- FindClusters(SeuratObj, resolution = 1.5, cluster.name = "unintegrated_clusters")

SeuratObj <- RunUMAP(obj, dims = 1:30, reduction = "pca", reduction.name = "umap.unintegrated")

#Data Integration using Harmony
SeuratObj_Integrated <- IntegrateLayers(object = SeuratObj, method = HarmonyIntegration, orig.reduction = "pca", new.reduction = harmony", verbose = FALSE)

SeuratObj_Integrated <- FindNeighbors(SeuratObj_Integrated, reduction = "integrated.harmony", dims = 1:30)
SeuratObj_Integrated <- FindClusters(SeuratObj_Integrated, resolution = 1.5, cluster.name = "harmony_clusters")

SeuratObj_Integrated <- RunUMAP(SeuratObj_Integrated, reduction = "integrated.harmony", dims = 1:30, reduction.name = "umap.harmony")

p1 <- DimPlot(SeuratObj, reduction = "umap.unintegrated", group.by = c("unintegrated_clusters"))
p2 <- DimPlot(SeuratObj_Integrated, reduction = "umap.harmony", group.by = c("harmony_clusters"))

p1|p2

Log in to answer this question.