Skip to contents

Read data from a Zarr store

Usage

read_zarr(
  path,
  as = c("InMemoryAnnData", "ZarrAnnData", "SingleCellExperiment", "Seurat"),
  mode = c("r", "r+", "a", "w", "w-", "x"),
  ...
)

Arguments

path

Path to the Zarr store to read

as

The type of object to return. One of:

mode

The mode to open the Zarr file.

  • a creates a new file or opens an existing one for read/write.

  • r opens an existing file for reading.

  • r+ opens an existing file for read/write.

  • w creates a file, truncating any existing ones.

  • w-/x are synonyms, creating a file and failing if it already exists.

...

Extra arguments provided to the as_* conversion function for the object specified by as

Value

The object specified by as

See also

Other AnnData creators: AnnData(), as_AnnData(), read_h5ad()

Examples

# Please use "example_v3.zarr.zip" for AnnData stored as Zarr version 3
zarr_dir <- system.file("extdata", "example_v2.zarr.zip", package = "anndataR")
td <- tempdir(check = TRUE)
unzip(zarr_dir, exdir = td)
zarr_store <- file.path(td, "example_v2.zarr")

# Read the Zarr as a SingleCellExperiment object
if (requireNamespace("SingleCellExperiment", quietly = TRUE)) {
  sce <- read_zarr(zarr_store, as = "SingleCellExperiment")
}

# Read the Zarr as a Seurat object
if (requireNamespace("SeuratObject", quietly = TRUE)) {
  seurat <- read_zarr(zarr_store, as = "Seurat")
}