Skip to contents

Reads only the genes in genes from path, for per-gene work (model fitting, tests) on a gene subset.

Usage

read_genes(path, genes = NULL, chunk_size = 1000L)

Arguments

path

Path to the dataset.

genes

Genes to read: 1-based integer positions or gene names, in any order. NULL reads all genes.

chunk_size

Genes per internal read.

Value

A dgCMatrix, cells x genes: one column per element of genes, in that order, so each gene's counts are contiguous. Use t() for genes x cells.

Details

Gene-major .h5ad / Zarr stores (written with convert(..., gene_major = TRUE)) read just those genes. A Seurat, SingleCellExperiment or SpatialExperiment .rds is inflated once to index it, and the selected genes are then read in parallel; memory is about 12 bytes per kept nonzero plus 4 bytes per nonzero of the whole matrix. Cell-major .h5ad and other formats are refused; convert them with gene_major = TRUE first. To read many blocks of one file, use gene_blocks(), which opens it once.

See also