Skip to contents

Method permits slicing of ReducedExperiment objects.

Usage

# S4 method for class 'FactorisedExperiment,ANY,ANY,ANY'
x[i, j, k, ..., drop = FALSE]

# S4 method for class 'FactorisedExperiment,ANY,ANY,FactorisedExperiment'
x[i, j, k, ...] <- value

# S4 method for class 'ModularExperiment,ANY,ANY,ANY'
x[i, j, k, ..., drop = FALSE]

# S4 method for class 'ModularExperiment,ANY,ANY,ModularExperiment'
x[i, j, k, ...] <- value

# S4 method for class 'ReducedExperiment,ANY,ANY,ANY'
x[i, j, k, ..., drop = FALSE]

# S4 method for class 'ReducedExperiment,ANY,ANY,ReducedExperiment'
x[i, j, k, ...] <- value

Arguments

x

ReducedExperiment object.

i

Slicing by rows (features, usually genes).

j

Slicing by columns (samples/observations).

k

Slicing by reduced dimensions.

...

Additional arguments to be passed to the parent method.

drop

Included for consistency with other slicing methods.

value

Value to be used to replace part of the object.

Value

A ReducedExperiment object, potentially sliced by rows (i), columns (j) and components (k).

Author

Jack Gisby

Examples

# Create randomised data with the following dimensions
i <- 300 # Number of features
j <- 100 # Number of samples
k <- 10 # Number of components (i.e., factors/modules)

rand_assay_data <- ReducedExperiment:::.makeRandomData(i, j, "gene", "sample")
rand_reduced_data <- ReducedExperiment:::.makeRandomData(j, k, "sample", "component")

# Create a randomised ReducedExperiment container
re <- ReducedExperiment(
    assays = list("normal" = rand_assay_data),
    reduced = rand_reduced_data
)

# Slice our object by rows (1:50), columns (1:20) and components (1:5)
# re[i, j, k, ...]
sliced_re <- re[1:50, 1:20, 1:5]
sliced_re
#> class: ReducedExperiment 
#> dim: 50 20 5 
#> metadata(0):
#> assays(1): normal
#> rownames(50): gene_1 gene_2 ... gene_49 gene_50
#> rowData names(0):
#> colnames(20): sample_1 sample_2 ... sample_19 sample_20
#> colData names(0):
#> 5 components

# We can also assign our subsetted object back to the original
re[1:50, 1:20, 1:5] <- sliced_re
re
#> class: ReducedExperiment 
#> dim: 300 100 10 
#> metadata(0):
#> assays(1): normal
#> rownames(300): gene_1 gene_2 ... gene_299 gene_300
#> rowData names(0):
#> colnames(100): sample_1 sample_2 ... sample_99 sample_100
#> colData names(0):
#> 10 components