Subsetting SCEs {SingleCellExperiment} | R Documentation |
Methods to subset SingleCellExperiment objects.
## S4 method for signature 'SingleCellExperiment,ANY,ANY' x[i, j, ..., drop=TRUE] ## S4 replacement method for signature 'SingleCellExperiment,ANY,ANY,SingleCellExperiment' x[i, j] <- value
x |
A SingleCellExperiment object. |
i, j |
A vector of logical or integer subscripts, indicating the rows and columns to be subsetted for |
... |
Extra arguments to be passed to |
drop |
A logical scalar that is ignored. |
value |
A SingleCellExperiment object with number of rows equal to length of |
Subsetting yields a SingleCellExperiment object containing the specified rows (features) and columns (cells).
Internal row and column metadata fields will also be subsetted so that methods such as isSpike
are still valid.
If column subsetting is performed, values of the reducedDims
will be modified to retain only the selected cells.
Subset assignment will replace the assay values and metadata of the specified rows or columns in x
with those in value
.
If both i
and j
are set, the relevant block of assay values will be replaced, along with the metadata for the affected rows and columns.
If neither i
or j
are set, x
will be turned into value
.
For [
and subset
, a subsetted SingleCellExperiment object is returned.
For [<-
, a modified SingleCellExperiment object is returned.
Aaron Lun
example(SingleCellExperiment, echo=FALSE) # using the class example sce[1:10,] sce[,1:5] sce2 <- sce sce2[1:10,] <- sce[11:20,] # Can also use subset() sce$WHEE <- sample(LETTERS, ncol(sce), replace=TRUE) subset(sce, , WHEE=="A") # Can also use split() split(sce, sample(LETTERS, nrow(sce), replace=TRUE))