mantispy.io.read#

mantispy.io.read(path, backed=None, migrate_schema=True, lazy=False)[source]#

Read a mantispy h5ad or zarr store, checking its schema version.

Parameters:
path str | Path

File to read. A .zarr suffix selects the zarr reader.

backed Literal['r', 'r+'] | None (default: None)

"r" leaves X on disk and reads it a group at a time. obs and var are always in memory, so QC, feature flags and metadata work unchanged, but a function that rewrites X needs copy=True or key_added=. h5ad only; zarr stores are read whole.

migrate_schema bool (default: True)

Bring an older but known schema up to the current one on read. Set it to False to see the version the file carries.

lazy bool (default: False)

Hold X, every layer and raw.X as dask arrays read in row chunks, for a screen that does not fit in memory. obs, var, obsm and uns are read into memory. The matrices must be stored dense, and the object keeps reading from the file, so write() refuses to overwrite it. normalize(), tvn() and aggregate() stream it and give the same numbers as in memory, as does scanpy.pp.pca() with svd_solver="covariance_eigh"; a function that needs the whole matrix warns before it reads it. Needs dask, from mantispy[lazy], and cannot be combined with backed.

Return type:

AnnData

Returns:

The object, backed, lazy or in memory. adata.to_memory() loads a backed one into memory.

Raises:
  • ImportError – lazy was given and dask is not installed.

  • ValueError – backed was given for a zarr store or together with lazy, lazy was given for a sparse matrix, or the file carries a schema version this build cannot migrate from or was told not to migrate.