About Install Get Started Frequently Asked Questions Frequently Requested Vignettes Contact
Seurat - Combining Two 10X Runs

In this vignette, we will combine two 10X PBMC datasets: one containing 4K cells and one containing 8k cells. The datasets can be found here.

Merging Two Seurat Objects

To start, we read in the data and create two Seurat objects.

pbmc4k.data <- Read10X(data.dir = "~/Projects/datasets/10X/pbmc4k/filtered_gene_bc_matrices/GRCh38/")
pbmc4k <- CreateSeuratObject(raw.data = pbmc4k.data, project = "PBMC4K")

pbmc8k.data <- Read10X(data.dir = "~/Projects/datasets/10X/pbmc8k/filtered_gene_bc_matrices/GRCh38/")
pbmc8k <- CreateSeuratObject(raw.data = pbmc8k.data, project = "PBMC8K")

MergeSeurat merges the raw.data matrices of two Seurat objects and creates a new Seurat object with the resulting combined raw.data matrix. To easily tell which original object any particular cell came from, you can set the add.cell.id1(2) parameters which will append the given identifier to the beginning of each cell name. The original project ID will remain stored in object@meta.data$orig.ident

pbmc.combined <- MergeSeurat(object1 = pbmc4k, object2 = pbmc8k, add.cell.id1 = "4K", 
    add.cell.id2 = "8K", project = "PBMC12K")
# notice the cell names now have an added identifier
head(x = pbmc.combined@cell.names)
##   4340   8381

Adding additional samples into an existing Seurat object

AddSamples takes an existing Seurat object, and adds samples based on an additional raw.data matrix from a new dataset. This is essentially a shortcut compared to MergeSeurat, so that you don’t need to create a Seurat object for the new data. The add.cell.id field is added to objectmeta.data$orig.ident for the new cells.

pbmc.combined <- AddSamples(object = pbmc4k, new.data = pbmc8k.data, add.cell.id = "8K")
## PBMC4K     8K 
##   4340   8381