czbenchmarks.cli.resolve_reference
Attributes
Classes
DataRef represents a structured reference to a specific slot or field within an AnnData object. |
Functions
|
|
|
|
|
Module Contents
- czbenchmarks.cli.resolve_reference.ANNDATA_REF_PREFIX = '@'
- class czbenchmarks.cli.resolve_reference.AnnDataReference(/, **data: Any)[source]
Bases:
pydantic.BaseModel
DataRef represents a structured reference to a specific slot or field within an AnnData object. References are denoted by a leading ‘@’ and can point to various AnnData attributes:
‘@X’ → adata.X (main data matrix)
‘@obs’ → adata.obs (entire observations DataFrame)
‘@obs:cell_type’ → adata.obs[“cell_type”] (specific column in obs)
‘@obsm:X_pca’ → adata.obsm[“X_pca”] (specific key in obsm)
‘@layers:counts’ → adata.layers[“counts”] (specific layer)
‘@var:gene_symbols’ → adata.var[“gene_symbols”] (specific column in var)
‘@varm:some_key’ → adata.varm[“some_key”] (specific key in varm)
‘@uns:some_key’ → adata.uns[“some_key”] (specific key in uns)
- space
The AnnData attribute to reference (‘X’, ‘obs’, ‘obsm’, ‘var’, ‘varm’, ‘layers’, ‘uns’).
- Type:
- parse(value
str) -> DataRef: Parse a string reference (e.g., ‘@obs:cell_type’) into a DataRef instance.
- resolve(adata
AnnData) -> Any: Resolve the reference against a given AnnData object, returning the referenced data.
- Raises:
ValueError – If the reference format is invalid or unsupported.
KeyError – If the specified key does not exist in the referenced AnnData attribute.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- static parse(ref_string: str) AnnDataReference [source]
- resolve(anndata: anndata.AnnData) Any [source]
- czbenchmarks.cli.resolve_reference.resolve_value_recursively(value: Any, anndata: anndata.AnnData) Any [source]