merge_sce_coldata: Function for merging the ColData of two SCE objects, matching...

Description Usage Arguments Details Value Examples

View source: R/convenience_funcs.R

Description

merge_sce_coldata returns the original SCE object with additional ColData merged from another SCE object with overlapping cells. If there are columns with the same name, the columns from the cmp_SCE will be suffixed with "_cmp".

Usage

1
merge_sce_coldata(orig_sce, cmp_sce)

Arguments

orig_sce

SCE object that is to be retained.

cmp_sce

SCE object with overlapping cells (cells must have the same names) and additional ColData to incorporate.

Details

This function is useful for example when analyzing the same dataset with Seurat and the DropletUtils/scater/scran pipeline and then needing to visualize column data from the two analyses on the same embedding. It seems easier to convert Seurat to SCE than from SCE to Seurat.

Value

The original SCE object with additional ColData from the second SCE object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# load example dataset from Seurat
data("pbmc_small", package="Seurat")

pbmc_small_sce <- Seurat::as.SingleCellExperiment(pbmc_small)
pbmc_small_sce2 <- pbmc_small_sce

# remove some cells from pbmc_small_sce
pbmc_small_sce <- pbmc_small_sce[, c(-78:-80)]

# remove different cells from pbmc_small_sce2
pbmc_small_sce2 <- pbmc_small_sce2[, c(-7,-77)]

# add a fake ColData column to pbmc_small_sce2
pbmc_small_sce2$fake_col <- sample(x=7, size=ncol(pbmc_small_sce2), replace=TRUE)

merge_sce_coldata(pbmc_small_sce, pbmc_small_sce2)

genomics-kl/seurathelpeR documentation built on Nov. 4, 2019, 1:04 p.m.