nexprs {scater} | R Documentation

## Count the number of non-zero counts per cell or feature

### Description

An efficient internal function that counts the number of non-zero counts in each row (per feature) or column (per cell). This avoids the need to construct an intermediate logical matrix.

### Usage

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

### 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.
`exprs_values` | String or integer specifying the assay of `object` to obtain the count matrix from, if `object` is a SingleCellExperiment.
`byrow` | Logical scalar indicating whether to count the number of detected cells per feature. If `FALSE`, the function will count the number of detected features per cell.
`subset_row` | Logical, integer or character vector indicating which rows (i.e. features) to use.
`subset_col` | Logical, integer or character vector indicating which columns (i.e., cells) to use.
`BPPARAM` | A BiocParallelParam object specifying whether the calculations should be parallelized.

### 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

An integer vector containing counts per gene or cell, depending on the provided arguments.

### 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.12.2 Index]