Skip to contents

Combine multiple objects

Usage

combine(x, y, ...)

# S4 method for SingleCellExperiment,SingleCellExperiment
combine(x, y)

Arguments

x

Object.

y

Object.

...

Additional arguments.

Value

SingleCellExperiment.

Details

We're attempting to make this as strict as possible, requiring:

  • Rows (genes) across objects must be identical.

  • rowRanges and/or rowData metadata must be identical.

  • colData must contain the same columns.

  • Specific metadata must be identical (see metadata argument).

Note

Updated 2022-03-21.

See also

  • help("merge.Matrix", "Matrix.utils").

Examples

data(SingleCellExperiment_splatter, package = "AcidTest")

## SingleCellExperiment ====
x <- SingleCellExperiment_splatter
colnames(x) <- paste0(
    "cell",
    AcidBase::strPad(
        x = as.character(seq_len(ncol(x))),
        width = 4L,
        side = "left",
        pad = "0"
    )
)
y <- x
colnames(y) <- paste0(
    "cell",
    AcidBase::strPad(
        x = as.character(seq_len(ncol(y)) + ncol(y)),
        width = 4L,
        side = "left",
        pad = "0"
    )
)
## Combine the two objects.
c <- combine(x, y)
#> → Combining objects into `RangedSummarizedExperiment`.
#> → Binding columns in `assays()`: "counts".
#> → Checking row data.
#> → Updating column data.
#> → Updating metadata.
sampleData(c)
#> DataFrame with 4 rows and 2 columns
#>         sampleName interestingGroups
#>           <factor>          <factor>
#> sample3    sample3           sample3
#> sample4    sample4           sample4
#> sample1    sample1           sample1
#> sample2    sample2           sample2
print(c)
#> class: SingleCellExperiment 
#> dim: 100 800 
#> metadata(2): date combine
#> assays(1): counts
#> rownames(100): gene001 gene002 ... gene099 gene100
#> rowData names(10): broadClass description ... ncbiGeneId seqCoordSystem
#> colnames(800): cell0001 cell0002 ... cell0799 cell0800
#> colData names(1): sampleId
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):