rowSubset: Get or set the row subset

rowSubsetR Documentation

Get or set the row subset


Get or set the row subset in an instance of a SingleCellExperiment class. This is assumed to specify some interesting subset of genes to be favored in downstream analyses.


## S4 method for signature 'SingleCellExperiment'
rowSubset(x, field = "subset", onAbsence = "none")

## S4 replacement method for signature 'SingleCellExperiment'
rowSubset(x, field = "subset", ...) <- value



A SingleCellExperiment object.


String containing the name of the field in the rowData to get or set subsetting data.


String indicating an additional action to take when labels are absent: nothing ("none"), a warning ("warn") or an error ("error").


Additional arguments, currently ignored.


Any character, logical or numeric vector specifying rows of x to include in the subset. Alternatively NULL, in which case existing subsetting information is removed.


A frequent task in single-cell data analyses is to focus on a subset of genes of interest, e.g., highly variable genes, derived marker genes for clusters, known markers for cell types. A related task is to filter out uninteresting genes such as ribosomal protein genes or mitochondrial transcripts, in which case we want to subset to exclude those genes.

These functions store a set of genes of interest inside a SingleCellExperiment for later retrieval and use in downstream functions. Character and numeric value are converted to logical vectors that are parallel to the rows of x, allowing them to be added to the rowData for synchronized row-level operations.

For developers, onAbsence is provided to make it easier to mandate that x actually has labels. This avoids silent NULL values that flow to the rest of the function and make debugging difficult.


For rowSubset, a logical vector is returned specifying the rows to retain in the subset of interest. If no subset is available, a NULL is returned (and/or a warning or error, depending on onAbsence).

For rowSubset<-, a modified x is returned a subsetting vector in its rowData.


Aaron Lun

See Also

SingleCellExperiment, for the underlying class definition.


example(SingleCellExperiment, echo=FALSE) # Using the class example

rowSubset(sce, "hvgs") <- 1:10
rowSubset(sce, "hvgs")

rowSubset(sce) <- rbinom(nrow(sce), 1, 0.5)==1

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