lamindb.curators.SpatialDataCurator¶
- class lamindb.curators.SpatialDataCurator(dataset, schema, *, sample_metadata_key='sample')¶
Bases:
SlotsCurator
Curator for
SpatialData
.Added in version 1.3.0.
- Parameters:
Example:
import lamindb as ln import bionty as bt # define sample schema sample_schema = ln.Schema( name="blobs_sample_level_metadata", features=[ ln.Feature(name="assay", dtype=bt.ExperimentalFactor).save(), ln.Feature(name="disease", dtype=bt.Disease).save(), ln.Feature(name="development_stage", dtype=bt.DevelopmentalStage).save(), ], coerce_dtype=True ).save() # define table obs schema blobs_obs_schema = ln.Schema( name="blobs_obs_level_metadata", features=[ ln.Feature(name="sample_region", dtype="str").save(), ], coerce_dtype=True ).save() # define table var schema blobs_var_schema = ln.Schema( name="blobs_var_schema", itype=bt.Gene.ensembl_gene_id, dtype=int ).save() # define composite schema spatialdata_schema = ln.Schema( name="blobs_spatialdata_schema", otype="SpatialData", components={ "sample": sample_schema, "table:obs": blobs_obs_schema, "table:var": blobs_var_schema, }).save() # curate a SpatialData spatialdata = ln.core.datasets.spatialdata_blobs() curator = ln.curators.SpatialDataCurator(spatialdata, spatialdata_schema) try: curator.validate() except ln.errors.ValidationError as error: print(error) # validate again (must pass now) and save artifact artifact = curator.save_artifact(key="example_datasets/spatialdata1.zarr") assert artifact.schema == spatialdata_schema
Attributes¶
- property slots: dict[str, DataFrameCurator]¶
Curator objects by slot.
Added in version 1.1.1.
Methods¶
- save_artifact(*, key=None, description=None, revises=None, run=None)¶
Save an annotated artifact.
- Parameters:
key (
str
|None
, default:None
) – A path-like key to reference artifact in default storage, e.g.,"myfolder/myfile.fcs"
. Artifacts with the same key form a version family.description (
str
|None
, default:None
) – A description.revises (
Artifact
|None
, default:None
) – Previous version of the artifact. Is an alternative way to passingkey
to trigger a new version.run (
Run
|None
, default:None
) – The run that creates the artifact.
- Return type:
- Returns:
A saved artifact record.
- validate()¶
Validate dataset against Schema.
- Raises:
lamindb.errors.ValidationError – If validation fails.
- Return type:
None