Skip to contents

Calculate the sparsity (as a count or proportion) of a gene expression count matrix.

Usage

getSparsity(
  seu_obj = NULL,
  features = NULL,
  expMat = "path_to_expMat",
  platform = NULL
)

Arguments

seu_obj

A Seurat object.

features

An optional vector of feature names (e.g., gene symbols) to include in the calculation. Defaults to NULL, in which case the calculation uses all available features in the RNA assay of the Seurat object.

expMat

Path to exprMatrix file.

platform

The platform from which the data originates. Valid options are 'Xenium', 'CosMx', and 'Merscope'.

Value

A data frame.

Details

For example, .99 sparsity means 99% of the values are zero. Similarly, a sparsity of 0 means the matrix is fully dense.