| Title: | R Bindings to 'zarrs': Zarr V3 Storage for Multidimensional Arrays |
|---|---|
| Description: | R bindings to the 'zarrs' Rust library <https://github.com/zarrs/zarrs> for reading Zarr V3 (and compatible Zarr V2) stores from local disk, HTTP/HTTPS, and S3 by default, with optional GCS and Azure Blob support at source-install time. Supports local '.zarr.zip' VCF Zarr archives, multiple codecs (gzip, zstd, sharding), and the common numeric data types. SIMD-accelerated codec paths are selected automatically at runtime by the underlying Rust dependency crates. |
| Authors: | Sounkou Mahamane Toure [aut, cre], Authors of the dependency Rust crates [cph] (see inst/AUTHORS) |
| Maintainer: | Sounkou Mahamane Toure <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-07-21 19:31:23 UTC |
| Source: | https://github.com/RGenomicsETL/Rzarrs |
With no argument, returns the codecs compiled into this Rzarrs build. When
passed a ZarrArray, returns support status for the codecs declared by that
array, including nested sharding codecs.
codec_capabilities(x = NULL)codec_capabilities(x = NULL)
x |
Optional |
A named list with codec and supported vectors.
Plan R materialization for a Zarr dtype.
dtype_plan(dtype)dtype_plan(dtype)
dtype |
Character scalar dtype name. |
High-precision extension dtypes such as float128, decimal128, and
decimal256 are planned as lossy R double values. Actual reading still
depends on a registered binary-layout data type materializer because these are
extension dtypes, not core built-in zarrs element types.
A named list describing the planned R materialization.
A handle to a single Zarr array within a store. Arrays can be opened
from a local store (ZarrStore) or an object-store backend
(ZarrObjectStore).
Indexing follows R conventions: indices are 1-based and inclusive on both ends.
ZarrArray$open(store, path)Open from a local ZarrStore.
storeA ZarrStore object.
pathCharacter scalar. Array path within the store,
e.g. "/" for the root array.
ZarrArray$open_object_store(store, path)Open from a ZarrObjectStore.
Same arguments as above but store is a ZarrObjectStore.
$ndim()Number of dimensions (integer scalar).
$shape()Array shape (integer vector, one element per dimension).
$chunk_shape()Chunk shape (integer vector), or NULL for
irregular chunk grids.
$dtype()Data type name in Zarr V3 canonical form, e.g.
"float32", "int32", "bool" (character scalar).
$dimension_names()Dimension names (character vector), or
NULL if none are stored.
$metadata_json()Full array metadata as pretty-printed JSON (character scalar).
$retrieve(starts = NULL, ends = NULL)Read array data into R.
startsInteger vector of 1-based start indices
(one per dimension), or NULL to start at the first element.
endsInteger vector of 1-based inclusive end
indices (one per dimension), or NULL to include the last element.
Returns a vector of the appropriate R type (integer,
double, or logical) with a dim attribute set to
the shape of the requested region. Data are returned in R (Fortran /
column-major) order so that standard R array indexing works as expected.
zarr_path <- system.file("testdata", "int32.zarr", package = "Rzarrs") arr <- ZarrArray$open(ZarrStore$open(zarr_path), "/") arr$ndim() # 2 arr$shape() # c(4L, 6L) arr$dtype() # "int32" # Full array full <- arr$retrieve() dim(full) # c(4L, 6L) full[1, 6] # 6 # Subset: rows 1-2, cols 1-3 sub <- arr$retrieve(c(1L, 1L), c(2L, 3L)) dim(sub) # c(2L, 3L)zarr_path <- system.file("testdata", "int32.zarr", package = "Rzarrs") arr <- ZarrArray$open(ZarrStore$open(zarr_path), "/") arr$ndim() # 2 arr$shape() # c(4L, 6L) arr$dtype() # "int32" # Full array full <- arr$retrieve() dim(full) # c(4L, 6L) full[1, 6] # 6 # Subset: rows 1-2, cols 1-3 sub <- arr$retrieve(c(1L, 1L), c(2L, 3L)) dim(sub) # c(2L, 3L)
Groups may contain arrays and/or sub-groups. Use '$attributes()' to read the group's JSON attributes as a native R list, and '$children()' to list the immediate child nodes.
ZarrGroupZarrGroup
An object of class Rzarrs::ZarrGroup__bundle (inherits from savvy_Rzarrs__sealed) of length 2.
A handle to a Zarr store backed by any URL scheme supported by the
object_store crate:
s3://, gs://, az://, https://, or
file:///.
URLs ending in ile.zarr.zip or ile.zip are opened as zip objects
when the Rust ilezip feature is enabled.
Credentials are read automatically from the standard environment
variables for each provider (the same ones used by the AWS CLI,
gsutil, azcopy, etc.). No credentials are ever passed
as R objects.
ZarrObjectStore$open(url)Open an object-store backend.
urlCharacter scalar. Store URL,
e.g. "s3://my-bucket/path/to/store.zarr",
"s3://my-bucket/path/to/store.zarr.zip", or
"https://example.com/store.zarr".
Returns a ZarrObjectStore object.
$url()Return the URL passed to open() as a character scalar.
Set the relevant environment variables before calling open():
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_ENDPOINT_URL
GOOGLE_APPLICATION_CREDENTIALS
AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_ACCESS_KEY
## Not run: store <- ZarrObjectStore$open("s3://my-bucket/my.zarr") arr <- ZarrArray$open_object_store(store, "/") arr$shape() ## End(Not run)## Not run: store <- ZarrObjectStore$open("s3://my-bucket/my.zarr") arr <- ZarrArray$open_object_store(store, "/") arr$shape() ## End(Not run)
A handle to a Zarr store rooted at a local directory.
Use ZarrStore$open(path) to create one, then pass it to
ZarrArray$open(store, path) to open individual arrays.
ZarrStore$open(path)Open a local Zarr store.
pathCharacter scalar. Path to the ‘.zarr’ directory.
Returns a ZarrStore object.
$path()Return the store root path as a character scalar.
zarr_path <- system.file("testdata", "int32.zarr", package = "Rzarrs") store <- ZarrStore$open(zarr_path) store$path()zarr_path <- system.file("testdata", "int32.zarr", package = "Rzarrs") store <- ZarrStore$open(zarr_path) store$path()
'ZarrVcf$open(x)' opens a VCF Zarr store (spec versions 0.1–0.4) and returns an instance with methods to access variant, sample, and genotype data. Genotypes use the VCF Zarr integer encoding: allele indexes are 0-based, '-1' is a missing allele ('.' in VCF), and '-2' is the array fill sentinel.
ZarrVcfZarrVcf
An object of class Rzarrs::ZarrVcf__bundle (inherits from savvy_Rzarrs__sealed) of length 3.
Open a VCF Zarr store from a path, URL, 'ZarrStore', or 'ZarrObjectStore'.
VCF Zarr spec version string.
Number of variants and samples.
Character vectors of sample IDs, contig names, filter IDs.
Available array names.
Per-variant data.
3-D array (variants × samples × ploidy) of integer genotypes using VCF Zarr '-1'/'-2' sentinel values.
Boolean phased matrix.
Generic accessor for 'variant_<name>' / 'call_<name>' arrays.