The combine generic function handles methods for combining or merging different Bioconductor data structures. It should, given an arbitrary number of arguments of the same class (possibly by inheritance), combine them into a single instance in a sensible way (some methods may only combine 2 objects, ignoring ... in the argument list; because Bioconductor data structures are complicated, check carefully that combine does as you intend).

combine(x, y, ...)

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

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

Arguments

x

One of the values.

y

A second value.

...

Additional arguments.

Value

SummarizedExperiment.

Details

There are two basic combine strategies. One is an intersection strategy. The returned value should only have rows (or columns) that are found in all input data objects. The union strategy says that the return value will have all rows (or columns) found in any one of the input data objects (in which case some indication of what to use for missing values will need to be provided).

These functions and methods are currently under construction. Please let us know if there are features that you require.

Note

Updated 2019-08-11.

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).

Methods

The following methods are defined in the BiocGenerics package:

combine(x=ANY, missing)

Return the first (x) argument unchanged.

combine(data.frame, data.frame)

Combines two data.frame objects so that the resulting data.frame contains all rows and columns of the original objects. Rows and columns in the returned value are unique, that is, a row or column represented in both arguments is represented only once in the result. To perform this operation, combine makes sure that data in shared rows and columns are identical in the two data.frames. Data differences in shared rows and columns usually cause an error. combine issues a warning when a column is a factor and the levels of the factor in the two data.frames are different.

combine(matrix, matrix)

Combined two matrix objects so that the resulting matrix contains all rows and columns of the original objects. Both matricies must have dimnames. Rows and columns in the returned value are unique, that is, a row or column represented in both arguments is represented only once in the result. To perform this operation, combine makes sure that data in shared rows and columns are all equal in the two matricies.

Additional combine methods are defined in the Biobase package for AnnotatedDataFrame, AssayData, MIAME, and eSet objects.

See also

Examples

data( RangedSummarizedExperiment, SingleCellExperiment, package = "acidtest" ) rse <- RangedSummarizedExperiment sce <- SingleCellExperiment str_pad <- stringr::str_pad ## SummarizedExperiment ==== x <- rse colnames(x) <- paste0( "sample", str_pad( string = seq_len(ncol(x)), width = 2L, pad = "0" ) ) y <- x colnames(y) <- paste0( "sample", str_pad( string = seq(from = ncol(y) + 1L, to = ncol(y) * 2L), width = 2L, 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.
#> DataFrame with 24 rows and 3 columns #> condition sampleName interestingGroups #> <factor> <factor> <factor> #> sample01 A sample01 A #> sample02 A sample02 A #> sample03 A sample03 A #> sample04 A sample04 A #> sample05 A sample05 A #> ... ... ... ... #> sample20 B sample20 B #> sample21 B sample21 B #> sample22 B sample22 B #> sample23 B sample23 B #> sample24 B sample24 B
#> class: RangedSummarizedExperiment #> dim: 500 24 #> metadata(6): combine date ... version wd #> assays(1): counts #> rownames(500): gene001 gene002 ... gene499 gene500 #> rowData names(8): broadClass description ... geneName seqCoordSystem #> colnames(24): sample01 sample02 ... sample23 sample24 #> colData names(1): condition
## SingleCellExperiment ==== x <- sce colnames(x) <- paste0( "cell", str_pad( string = seq_len(ncol(x)), width = 4L, pad = "0" ) ) y <- x colnames(y) <- paste0( "cell", str_pad( string = seq_len(ncol(y)) + ncol(y), width = 4L, 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.
#> DataFrame with 2 rows and 2 columns #> sampleName interestingGroups #> <factor> <factor> #> sample1 sample1 sample1 #> sample2 sample2 sample2
#> class: SingleCellExperiment #> dim: 500 200 #> metadata(4): combine date sessionInfo wd #> assays(1): counts #> rownames(500): gene001 gene002 ... gene499 gene500 #> rowData names(8): broadClass description ... geneName seqCoordSystem #> colnames(200): cell0001 cell0002 ... cell0199 cell0200 #> colData names(1): sampleID #> reducedDimNames(0): #> spikeNames(0):