Used to peform subsetting of a SingleCellExperiment object using a variety of methods that indicate the correct rows to keep. The various methods, index, bool, and rowData, can be used in conjunction with one another. If returnAsAltExp is set to TRUE, then the returned object will have the same number of rows as the input inSCE as the subsetted object will be stored in the altExp slot.

subsetSCERows(
  inSCE,
  index = NULL,
  bool = NULL,
  rowData = NULL,
  returnAsAltExp = TRUE,
  altExpName = "subset",
  prependAltExpName = TRUE
)

Arguments

inSCE

Input SingleCellExperiment object.

index

Integer vector. Vector of indicies indicating which rows to keep. If NULL, this will not be used for subsetting. Default NULL.

bool

Boolean vector. Vector of TRUE or FALSE indicating which rows should be kept. Needs to be the same length as the number of rows in inSCE. If NULL, this will not be used for subsetting. Default NULL.

rowData

Character. An expression that will identify a subset of rows using variables found in the rowData of inSCE. For example, if x is a numeric vector in rowData, then "x < 5" will return all rows with x less than 5. Single quotes should be used for character strings. For example, "y == 'yes'" will return all rows where y is "yes". Multiple expressions can be evaluated by placing them in a vector. For example c("x < 5", "y =='yes'") will apply both operations for subsetting. If NULL, this will not be used for subsetting. Default NULL.

returnAsAltExp

Boolean. If TRUE, the subsetted SingleCellExperiment object will be returned in the altExp slot of inSCE. If FALSE, the subsetted SingleCellExperiment object will be directly returned.

altExpName

Character. Name of the alternative experiment object to add if returnAsAltExp = TRUE. Default subset.

prependAltExpName

Boolean. If TRUE, altExpName will be added to the beginning of the assay names in the altExp object. This is only utilized if returnAsAltExp = TRUE. Default TRUE.

Value

A SingleCellExperiment object that has been subsetted by rowData.

Author

Joshua D. Campbell

Examples

data(scExample)

# Set a variable up in the rowData indicating mitochondrial genes
rowData(sce)$isMito <- ifelse(grepl("^MT-", rowData(sce)$feature_name),
                              "yes", "no")
sce <- subsetSCERows(sce, rowData = "isMito == 'yes'")