A light AnnData handle
Description
read_h5ad(as = "AnnData") returns one of these instead of a SingleCellExperiment. It holds what the Rust reader produced and builds R objects only when a component is actually touched.
Usage
## S3 method for class 'picklerick_anndata'
x$name
## S3 method for class 'picklerick_anndata'
dim(x)
## S3 method for class 'picklerick_anndata'
dimnames(x)
## S3 method for class 'picklerick_anndata'
print(x, ...)Arguments
x |
A light AnnData handle, from read_h5ad(as = "AnnData"). |
name |
The field to get; see Details. |
... |
Unused. |
Details
The reason this exists is measured, not aesthetic. Building a SingleCellExperiment costs a constant ~3.3 seconds on this machine regardless of dataset size — 0.05s vs 3.19s for a thousand cells, 3.72s vs 7.09s for a hundred thousand. That cost is S4 method-table and Bioconductor namespace warm-up, not work proportional to the data, so it cannot be optimised away inside the conversion; it can only be deferred until someone asks for an SingleCellExperiment.
Fields are reached with $, and each is built on first access and cached: $X, $obs, $var, $obsm, $layers, $obs_names, $var_names, $n_obs, $n_vars. Convert with as_sce() or as_seurat().
dim() and dimnames() answer from what the reader already returned, genes by cells as in a SingleCellExperiment, without building anything. print() lists the components and which of them have been built so far.
Value
$ returns the field; dim() the number of genes and cells; dimnames() a list of gene and cell names; print() returns x invisibly.
Examples
a <- read_h5ad("pbmc.h5ad", as = "AnnData")
dim(a) # cheap: shape comes from the reader, nothing is built
a$obs$cell_type # builds and caches obs only
sce <- as_sce(a) # pays the S4 cost, once, when it is actually wanted