LEM-subset: LEM subsetting methods

Subsetting LEMsR Documentation

LEM subsetting methods


Methods to subset LinearEmbeddingMatrix objects.


## S4 method for signature 'LinearEmbeddingMatrix,ANY,ANY'
x[i, j, ..., drop=TRUE]

## S4 replacement method for signature 
## 'LinearEmbeddingMatrix,ANY,ANY,LinearEmbeddingMatrix'
x[i, j] <- value



A LinearEmbeddingMatrix object.

i, j

A vector of logical or integer subscripts, indicating the rows and columns to be subsetted for i and j, respectively.


Extra arguments that are ignored.


A logical scalar indicating whether the result should be coerced to the lowest possible dimension.


A LinearEmbeddingMatrix object with number of rows equal to length of i (or that of x, if i is not specified). The number of columns must be equal to the length of j (or number of columns in x, if j is not specified).


Subsetting yields a LinearEmbeddingMatrix object containing the specified rows (samples) and columns (factors). If column subsetting is performed, values of featureLoadings and factorData will be modified to retain only the selected factors.

If drop=TRUE and the subsetting would produce dimensions of length 1, those dimensions are dropped and a vector is returned directly from sampleFactors. This mimics the expected behaviour from a matrix-like object. Users should set drop=FALSE to ensure that a LinearEmbeddingMatrix is returned.

For subset replacement, if neither i or j are set, x will be effectively replaced by value. However, row and column names will not change, consistent with replacement in ordinary matrices.


For [, a subsetted LinearEmbeddingMatrix object is returned.

For [<-, a modified LinearEmbeddingMatrix object is returned.


Aaron Lun

See Also



example(LinearEmbeddingMatrix, echo=FALSE) # using the class example


lem2 <- lem
lem2[1:10,] <- lem[11:20,]

LTLA/SingleCellExperiment documentation built on March 24, 2023, 4:07 a.m.