You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should X become a layer internally, as in Python anndata >= 0.13? #562
The on-disk format did not change (yet?). X is still written at the root and layers/ is written without the None key (h5ad.py#L100-L109, #L134), also on current main.
On our side, X and layers are still separate slots in AbstractAnnData and in every implementation (InMemoryAnnData.R#L55-L89). I'm working on a PR hides the None key in ReticulateAnnData$layers and py_to_r(), so the R API is unchanged for now. The question is whether we should follow Python further and store X as a layer internally too.
Possible solution
Options:
Keep X a separate slot (status quo) and translate at the Python boundary only.
Store X in layers internally and keep adata$X as a shortcut:
under a reserved name (e.g. ".X"): shows up in names(adata$layers) and layers_keys(), clashes with user layers of that name, and layers_mapping in as_Seurat() / as_SingleCellExperiment() has to filter it out
under an attribute or a wrapper object instead of a name: invisible to users, but adata$layers is no longer a plain named list
Go all the way and deprecate adata$X in favour of a default layer.
I'd also prefer option 2. What do we use as the layer name for X, though. I suppose we could use NA as a layer name to align with Python anndata, though it feels a bit weird to me.
I'm noticing a lot of changes are needed to make this happen -- the to SCE and Seurat converters, the different disk formats (which still have the layers + X encoding), the inmemory format. I'll first focus on getting everything to work by just acknowledging that the reticulate interface needs to account for this, and then adapt the anndataR inner workings later.
Activity
lazappi commentedon Nov 2, 2026
I think we should try to match Python, which is currently something like:
Xis stored inlayersNoneis the keyadata$Xis kept as a shortcutHow it's done in {anndatat.claude} might be useful as a reference https://github.com/lazappi/R-anndata-claude/blob/main/R/anndata.R.
rcannood commentedon Nov 2, 2026
I'd also prefer option 2. What do we use as the layer name for X, though. I suppose we could use
NAas a layer name to align with Python anndata, though it feels a bit weird to me.rcannood commentedon Nov 2, 2026
I suppose that's what the claude implementation is also doing; https://github.com/lazappi/R-anndata-claude/blob/2da2526e6abdf20385eff6ca7bd5ad61d62a06bd/R/anndata.R#L869
rcannood commentedon Nov 2, 2026
I'm noticing a lot of changes are needed to make this happen -- the to SCE and Seurat converters, the different disk formats (which still have the layers + X encoding), the inmemory format. I'll first focus on getting everything to work by just acknowledging that the reticulate interface needs to account for this, and then adapt the anndataR inner workings later.