featureIndex {singleCellTK} | R Documentation

## Retrieve row index for a set of features

### Description

This will return indices of features among the rownames or rowData of a data.frame, matrix, or a SummarizedExperiment object including a SingleCellExperiment. Partial matching (i.e. grepping) can be used by setting `exactMatch = FALSE`.

### Usage

    featureIndex(
      features,
      inSCE,
      by = "rownames",
      exactMatch = TRUE,
      removeNA = FALSE,
      errorOnNoMatch = TRUE,
      warningOnPartialMatch = TRUE
    )

### Arguments

`features` | Character vector of feature names to find in the rows of `inSCE`.
`inSCE` | A data.frame, matrix, or SingleCellExperiment object to search.
`by` | Character. Where to search for features in `inSCE`. If set to `"rownames"` then the features will be searched for among `rownames(inSCE)`. If `inSCE` inherits from class SummarizedExperiment, then `by` can be one of the fields in the row annotation data.frame (i.e. one of `colnames(rowData(inSCE))`).
`exactMatch` | Boolean. Whether to only identify exact matches or to identify partial matches using `grep`.
`removeNA` | Boolean. If set to `FALSE`, features not found in `inSCE` will be given `NA` and the returned vector will be the same length as `features`. If set to `TRUE`, then the `NA` values will be removed from the returned vector. Default `FALSE`.
`errorOnNoMatch` | Boolean. If `TRUE`, an error will be given if no matches are found. If `FALSE`, an empty vector will be returned if `removeNA` is set to `TRUE` or a vector of `NA` if `removeNA` is set to `FALSE`. Default `TRUE`.
`warningOnPartialMatch` | Boolean. If `TRUE`, a warning will be given if some of the entries in `features` were not found in `inSCE`. The warning will list the features not found. Default `TRUE`.

### Value

A vector of row indices for the matching features in `inSCE`.

### Author(s)

Yusuke Koga, Joshua D. Campbell

### See Also

'retrieveFeatureInfo' from package `'scater'` and `link{regex}` for how to use regular expressions when `exactMatch = FALSE`.

### Examples

    data(scExample)
    ix <- featureIndex(features = c("MT-CYB", "MT-ND2"),
                                 inSCE = sce,
                                 by = "feature_name")

[Package singleCellTK version 2.0.0 Index]