Skip to content

Commit 939aec8

Browse files
committed
Refactor documentation for mappings in HDF5 and Zarr formats to improve clarity and consistency
1 parent de0d5cf commit 939aec8

2 files changed

Lines changed: 44 additions & 20 deletions

File tree

‎docs/ELEMENTS_h5ad.md‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ It is intended to be GitHub-renderable Markdown (no Sphinx/MyST directives).
1818
- [DataFrame v0.2.0](#dataframe-v020)
1919
- [DataFrame v0.1.0 (legacy: anndata 0.7.x)](#dataframe-v010-legacy-anndata-07x)
2020
- [Legacy categorical columns (Series-level)](#legacy-categorical-columns-series-level)
21-
- [Mappings / dict](#mappings--dict)
21+
- [Mappings](#mappings)
22+
- [Legacy mapping encoding (`dict` v0.1.0)](#legacy-mapping-encoding-dict-v010)
2223
- [Scalars](#scalars)
2324
- [Categorical arrays](#categorical-arrays)
2425
- [String arrays](#string-arrays)
@@ -152,26 +153,37 @@ In v0.1.0 DataFrames, a categorical column dataset (e.g. `obs/cell_type`) can be
152153

153154
- `categories`: an **HDF5 object reference** pointing to the corresponding `__categories/<colname>` dataset.
154155

155-
## Mappings / dict
156+
## Mappings
156157

157-
### `encoding-type: dict`, `encoding-version: 0.1.0`
158+
Mappings are stored as HDF5 **groups** on disk.
158159

159-
- A mapping **MUST** be stored as an HDF5 **group**.
160-
- Group attributes:
161-
- `encoding-type: "dict"`
162-
- `encoding-version: "0.1.0"`
163-
- Each entry in the group is another element (recursively).
160+
- This includes standard AnnData mappings such as `layers`, `obsm`, `varm`, `obsp`, `varp`, and `uns`.
161+
- Mappings are distinct from DataFrames and sparse arrays and do not require special mapping-specific attributes.
162+
- Mapping semantics are recursive: entries in `uns` can themselves be groups containing additional encoded elements.
164163

165-
> **Legacy note**
164+
> **Legacy compatibility note**
166165
>
167-
> In anndata 0.7.x, groups used as mappings often had **no special attributes**.
166+
> In earlier conventions (commonly seen in older docs and some files), mappings could carry
167+
> `encoding-type: "dict"` and `encoding-version: "0.1.0"`.
168+
> Readers should still accept this legacy metadata when encountered.
169+
170+
### Legacy mapping encoding (`dict` v0.1.0)
171+
172+
For backward compatibility, older files may encode mappings with explicit mapping metadata:
173+
174+
- `encoding-type: "dict"`
175+
- `encoding-version: "0.1.0"`
176+
177+
This historical convention existed in earlier AnnData docs and files and should still be accepted by readers.
168178

169179
## Scalars
170180

171181
### `encoding-version: 0.2.0`
172182

173183
Scalars are stored as **0-dimensional datasets**.
174184

185+
These should typically only occur inside `uns` and are commonly used for saved parameters.
186+
175187
- Numeric scalars:
176188
- `encoding-type: "numeric-scalar"`
177189
- `encoding-version: "0.2.0"`

‎docs/ELEMENTS_zarr.md‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ It is intended to be GitHub-renderable Markdown (no Sphinx/MyST directives).
1818
- [DataFrame v0.2.0](#dataframe-v020)
1919
- [DataFrame v0.1.0 (legacy: anndata 0.7.x)](#dataframe-v010-legacy-anndata-07x)
2020
- [Legacy categorical columns (Series-level)](#legacy-categorical-columns-series-level)
21-
- [Mappings / dict](#mappings--dict)
21+
- [Mappings](#mappings)
22+
- [Legacy mapping encoding (`dict` v0.1.0)](#legacy-mapping-encoding-dict-v010)
2223
- [Scalars](#scalars)
2324
- [Categorical arrays](#categorical-arrays)
2425
- [String arrays](#string-arrays)
@@ -154,26 +155,37 @@ In v0.1.0 DataFrames, a categorical column array (e.g. `obs/cell_type`) can be i
154155

155156
(This differs from HDF5, which can store an object reference.)
156157

157-
## Mappings / dict
158+
## Mappings
158159

159-
### `encoding-type: dict`, `encoding-version: 0.1.0`
160+
Mappings are stored as Zarr **groups** on disk.
160161

161-
- A mapping **MUST** be stored as a Zarr **group**.
162-
- Group attributes:
163-
- `encoding-type: "dict"`
164-
- `encoding-version: "0.1.0"`
165-
- Each entry in the group is another element (recursively).
162+
- This includes standard AnnData mappings such as `layers`, `obsm`, `varm`, `obsp`, `varp`, and `uns`.
163+
- Mappings are distinct from DataFrames and sparse arrays and do not require special mapping-specific attributes.
164+
- Mapping semantics are recursive: entries in `uns` can themselves be groups containing additional encoded elements.
166165

167-
> **Legacy note**
166+
> **Legacy compatibility note**
168167
>
169-
> In anndata 0.7.x, groups used as mappings often had **no special attributes**.
168+
> In earlier conventions (commonly seen in older docs and some files), mappings could carry
169+
> `encoding-type: "dict"` and `encoding-version: "0.1.0"`.
170+
> Readers should still accept this legacy metadata when encountered.
171+
172+
### Legacy mapping encoding (`dict` v0.1.0)
173+
174+
For backward compatibility, older files may encode mappings with explicit mapping metadata:
175+
176+
- `encoding-type: "dict"`
177+
- `encoding-version: "0.1.0"`
178+
179+
This historical convention existed in earlier AnnData docs and files and should still be accepted by readers.
170180

171181
## Scalars
172182

173183
### `encoding-version: 0.2.0`
174184

175185
Scalars are stored as **0-dimensional Zarr arrays**.
176186

187+
These should typically only occur inside `uns` and are commonly used for saved parameters.
188+
177189
- Numeric scalars:
178190
- `encoding-type: "numeric-scalar"`
179191
- `encoding-version: "0.2.0"`

0 commit comments

Comments
 (0)