Skip to contents

Combines ReducedExperiment objects by columns (samples) or rows (features).

Usage

# S4 method for class 'FactorisedExperiment'
cbind(..., deparse.level = 1)

# S4 method for class 'FactorisedExperiment'
rbind(..., deparse.level = 1)

# S4 method for class 'ModularExperiment'
cbind(..., deparse.level = 1)

# S4 method for class 'ModularExperiment'
rbind(..., deparse.level = 1)

# S4 method for class 'ReducedExperiment'
cbind(..., deparse.level = 1)

# S4 method for class 'ReducedExperiment'
rbind(..., deparse.level = 1)

Arguments

...

A series of ReducedExperiment objects to be combined. See cbind,SummarizedExperiment-method for further details.

deparse.level

Integer, see cbind.

Value

Returns a single ReducedExperiment object containing all of the columns in the objects passed to cbind.

Details

cbind assumes that objects have identical features and components (i.e., factors or modules). If they are not, an error is returned.

So, this means that the feature-level slots should be equivalent, for example the assay rownames and values of the loadings available in FactorisedExperiment and ModularExperimentobjects. The component slots should also be equivalent, such as the column names of the reduced matrix or the column names of the aformentioned factor loadings matrix.

rbind assumes that objects have identical samples and components. If they are not, an error is returned. This means that the sample-level slots should be equivalent, including for example the assay column names.

The SummarizedExperiment package includes separate methods for cbind (cbind,SummarizedExperiment-method) and (combineRows). The latter is supposed to be more flexible, permitting differences in the number and identity of the rows. For ReducedExperiment objects we only implement a single, less flexible, method that assumes the rows and components (i.e., factors or modules) are identical across objects. Attempting to apply combineRows to a ReducedExperiment object will result in the objects being treated as if they were SummarizedExperiments, and a single SummarizedExperiment object will be returned.

Author

Jack Gisby

Examples

# Create randomised containers with different numbers of samples
i <- 300 # Number of features
k <- 10 # Number of components (i.e., factors/modules)

# Same features and components, different samples (30 vs. 50 columns)
re_1 <- ReducedExperiment:::.createRandomisedReducedExperiment(i, 50, k)
re_2 <- ReducedExperiment:::.createRandomisedReducedExperiment(i, 30, k)

# Make a new object with 80 columns
cbind(re_1, re_2)
#> class: ReducedExperiment 
#> dim: 300 80 10 
#> metadata(0):
#> assays(1): normal
#> rownames(300): gene_1 gene_2 ... gene_299 gene_300
#> rowData names(0):
#> colnames(80): sample_1 sample_2 ... sample_29 sample_30
#> colData names(0):
#> 10 components

# Create randomised containers with different numbers of features
j <- 100 # Number of samples
k <- 10 # Number of components (i.e., factors/modules)

# Same features and components, different samples (30 vs. 50 columns)
re_3 <- ReducedExperiment:::.createRandomisedReducedExperiment(200, j, k)
re_4 <- ReducedExperiment:::.createRandomisedReducedExperiment(150, j, k)
reduced(re_3) <- reduced(re_4) # rbind assumes identical reduced data

# Make a new object with 80 columns
rbind(re_3, re_4)
#> class: ReducedExperiment 
#> dim: 350 100 10 
#> metadata(0):
#> assays(1): normal
#> rownames(350): gene_1 gene_2 ... gene_149 gene_150
#> rowData names(0):
#> colnames(100): sample_1 sample_2 ... sample_99 sample_100
#> colData names(0):
#> 10 components

# We can apply combineRows and combineCols to `ReducedExperiment` objects
# but the resulting object will be a `SummarizedExperiment`
combineCols(re_1, re_2)
#> class: SummarizedExperiment 
#> dim: 300 80 
#> metadata(0):
#> assays(1): normal
#> rownames(300): gene_1 gene_2 ... gene_299 gene_300
#> rowData names(0):
#> colnames(80): sample_1 sample_2 ... sample_29 sample_30
#> colData names(0):
combineRows(re_3, re_4)
#> class: SummarizedExperiment 
#> dim: 350 100 
#> metadata(0):
#> assays(1): normal
#> rownames(350): gene_1 gene_2 ... gene_149 gene_150
#> rowData names(0):
#> colnames(100): sample_1 sample_2 ... sample_99 sample_100
#> colData names(0):