Subsetting LEMs {SingleCellExperiment} | R Documentation

## LEM subsetting methods

### Description

Methods to subset LinearEmbeddingMatrix objects.

### Usage

    ## 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

### Arguments

`x` | 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.
`drop` | A logical scalar indicating whether the result should be coerced to the lowest possible dimension.
`value` | 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).

### Details

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.

### Value

For `[`, a subsetted LinearEmbeddingMatrix object is returned.

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

### Author(s)

Aaron Lun

### See Also

`LinearEmbeddingMatrix-class`

### Examples

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

    lem[1:10,]
    lem[,1:5]

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

[Package SingleCellExperiment version 1.9.3 Index]