read_lazy() reads an h5ad file or a zarr store (v3 or v2) into an
AnnData() whose X, layers, obsm, varm, obsp, varp, obs, var
and raw are lazy (see read_elem_lazy()) and whose uns is read into
memory.
It matches Python's read_lazy().
Value
An AnnData().
Details
Like Python it only reads the current encodings, so files from old anndata
releases (such as an unencoded X, a dataframe version 0.1.0 or raw.X)
raise an anndata_error, and uns$neighbors matrices are not moved to
obsp.
Use read_h5ad() or read_zarr() for those files, which raise
anndata_old_format_warning (Python's OldFormatWarning).
Deviations from Python
Arrays inside uns are read into memory (Python keeps them as dask arrays),
t() of a lazy AnnData stays lazy (it fails in Python) and lazy frames are
indexed by row name where Python's Dataset2D has no loc.
See vignette("deviations") for the full list.
Examples
adata <- AnnData(matrix(as.numeric(1:6), nrow = 3))
path <- tempfile(fileext = ".zarr")
write_zarr(adata, path)
read_lazy(path)
#> AnnData object with n_obs × n_vars = 3 × 2
#> layers: None (.X)