nexprs {scater} | R Documentation

## Count the number of expressed genes per cell

### Description

An efficient internal function that avoids the need to construct 'is_exprs_mat' by counting the number of expressed genes per cell on the fly.

### Usage

    nexprs(object, detection_limit = 0, exprs_values = "counts",
      byrow = FALSE, subset_row = NULL, subset_col = NULL)

### Arguments

`object` | a `SingleCellExperiment` object or a numeric matrix of expression values.
`detection_limit` | numeric scalar providing the value above which observations are deemed to be expressed. Defaults to `object@detection_limit`.
`exprs_values` | character scalar indicating whether the count data (`"counts"`), the log-transformed count data (`"logcounts"`), transcript-per-million (`"tpm"`), counts-per-million (`"cpm"`) or FPKM (`"fpkm"`) should be used to define if an observation is expressed or not. Defaults to the first available value of those options in the order shown. However, if `is_exprs(object)` is present, it will be used directly; `exprs_values` and `detection_limit` are ignored.
`byrow` | logical scalar indicating if `TRUE` to count expressing cells per feature (i.e. gene) and if `FALSE` to count expressing features (i.e. genes) per cell.
`subset_row` | logical, integeror character vector indicating which rows (i.e. features/genes) to use.
`subset_col` | logical, integer or character vector indicating which columns (i.e., cells) to use.

### Details

Setting `subset_row` or `subset_col` is equivalent to subsetting `object` before calling `nexprs`, but more efficient as a new copy of the matrix is not constructed.

### Value

If `byrow=TRUE`, an integer vector containing the number of cells expressing each feature, of the same length as the number of features in `subset_row` (all features in `exprs_mat` if `subset_row=NULL`).

If `byrow=FALSE`, an integer vector containing the number of genes expressed in each cell, of the same length as the number of cells specified in `subset_col` (all cells in `exprs_mat` if `subset_col=NULL`).

### Examples

    data("sc_example_counts")
    data("sc_example_cell_info")
    example_sce <- SingleCellExperiment(
    assays = list(counts = sc_example_counts), colData = sc_example_cell_info)
    nexprs(example_sce)[1:10]
    nexprs(example_sce, byrow = TRUE)[1:10]

[Package scater version 1.8.4 Index]