Skip to contents

Calculate the number of cells present in a given dataset, supporting both Seurat object input(seu_obj) and direct matrix file paths for imaging based spatial transcriptomic platforms such as Xenium and CosMx.

Usage

getNcells(seu_obj = NULL, expMat = "path_to_expMat", platform = NULL)

Arguments

seu_obj

Optional; a Seurat object from which to calculate the number of cells. If not provided, expMat must be specified.

expMat

A character string specifying the path to the expression matrix if seu_obj is not provided. This parameter is used in conjunction with platform to determine the method for reading the data.

platform

Optional; specifies the platform ('Xenium' or 'CosMx') if expMat is used. Required if expMat is provided without seu_obj.

Value

An integer indicating the total number of cells in the dataset.

Details

The function getNcells offers flexibility in determining cell counts, catering to different types of input. For Xenium platform datasets, it expects the path to a 'matrix.mtx.gz' file within the specified expMat directory and calculates the number of cells by reading the column count of this sparse matrix. For CosMx datasets, it reads a CSV file specified by expMat, calculating cell count based on the number of rows. This approach allows for integration into workflows that may start with raw data files or pre-processed Seurat objects, facilitating versatile data handling practices in transcriptomic analyses.