retrieveFeatureIndex {celda} | 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

    retrieveFeatureIndex(
      features,
      x,
      by = "rownames",
      exactMatch = TRUE,
      removeNA = FALSE
    )

### Arguments

`features` | Character vector of feature names to find in the rows of `x`.
`x` | A data.frame, matrix, or SingleCellExperiment object to search.
`by` | Character. Where to search for features in `x`. If set to `"rownames"` then the features will be searched for among `rownames(x)`. If `x` inherits from class SummarizedExperiment, then `by` can be one of the fields in the row annotation data.frame (i.e. one of `colnames(rowData(x))`).
`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 `x` 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`.

### Value

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

### Author(s)

Yusuke Koga, Joshua Campbell

### See Also

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

### Examples

    data(celdaCGSim)
    retrieveFeatureIndex(c("Gene_1", "Gene_5"), celdaCGSim$counts)
    retrieveFeatureIndex(c("Gene_1", "Gene_5"), celdaCGSim$counts,
                                                exactMatch = FALSE)

[Package celda version 1.8.1 Index]