create_odm_from_r_matrix: Create 'odm' object from R matrix

View source: R/import_data_from_r_matrices.R

create_odm_from_r_matrixR Documentation

Create odm object from R matrix

Description

create_odm_from_r_matrix() converts an R matrix (stored in standard dense format or sparse format) into an odm object.

Usage

create_odm_from_r_matrix(
  mat,
  file_to_write,
  chunk_size = 1000L,
  compression_level = 3L
)

Arguments

mat

an R matrix of class "matrix", "dgCMatrix", "dgRMatrix", or "dgTMatrix".

file_to_write

a fully-qualified file path specifying the location in which to write the backing .odm file.

chunk_size

(optional; default 1000L) a positive integer specifying the chunk size to use to store the data in the backing HDF5 file.

compression_level

(optional; default 3L) an integer in the inveral [0, 9] specifying the compression level to use to store the data in the backing HDF5 file.

Value

an odm object

Examples

set.seed(4)
x <- rpois(100, lambda = 1)
gene_matrix <- matrix(
  x,
  nrow = 5L,
  dimnames = list(paste0("gene_", seq_len(5L)), paste0("cell_", seq_len(20L)))
)
file_to_write <- paste0(tempdir(), "/gene.odm")
odm_object <- create_odm_from_r_matrix(
  mat = gene_matrix,
  file_to_write = file_to_write,
  chunk_size = 5L
)

ondisc documentation built on June 17, 2026, 5:06 p.m.