sddb.Catalog#
- class sddb.Catalog(url: str | None = None, *, cache_dir: str | Path | None = None, version: str | None = None, refresh: bool = False)#
The dataset catalog: fetched, cached and validated on construction.
Attributes table#
Cross-dataset multi-modal feature index bound to this catalog (loaded lazily).
Generation timestamp from the parquet metadata, if present.
Cross-dataset gene index bound to this catalog (loaded lazily).
Methods table#
cohort(*[, uids, study_ids])Build a cohort from an explicit set of
uidsorstudy_ids(exactly one).collection(slug)The members of one collection as a cohort, by its slug (the last part of its web page URL).
dataset(uid)The catalog row for one dataset, by full
uid, its 16-character stem or itscanonical_key.facets([name])List the facet columns, or the values of one facet.
from_file(path, *[, cache_dir])Load a catalog from a local
catalog.parquet(absolute or relative path, orfile://URL).query(*[, validation, license_set, ...])Filter the catalog.
search(text)Deterministic text search over facet values.
to_df()Return the full catalog as a DataFrame copy.
Attributes#
- property features: FeatureIndex#
Cross-dataset multi-modal feature index bound to this catalog (loaded lazily).
- property genes: GeneIndex#
Cross-dataset gene index bound to this catalog (loaded lazily).
Methods#
- cohort(*, uids: list[str] | None = None, study_ids: list[str] | None = None) SpatialDataCohort#
Build a cohort from an explicit set of
uidsorstudy_ids(exactly one).Raises
KeyErrornaming any id not in the catalog; a valid but empty result warns.
- collection(slug: str) SpatialDataCohort#
The members of one collection as a cohort, by its slug (the last part of its web page URL).
Members are the catalog rows listing
slugin theircollectionscolumn, in catalog order. RaisesKeyErrorif no row lists it.
- dataset(uid: str) Dataset#
The catalog row for one dataset, by full
uid, its 16-character stem or itscanonical_key.A uid pins one version. A stem resolves to the latest version. A
canonical_keysuch as"geo:GSM9778330"is unique where it is set and usually survives a re-version of the dataset; datasets without one (null in the column) cannot be looked up this way. RaisesKeyErrorif absent or ambiguous.
- facets(name: str | None = None) list[str]#
List the facet columns, or the values of one facet.
These are the names and values that
query()accepts, and the list that the "did you mean" hint of an unknown value points to. It is the same list assddb-cli facetsand the MCPfacetstool.- Parameters:
- name
A facet column such as
"organism".Nonelists the facet columns in this catalog.
- Returns:
list[str] The facet columns, or the sorted distinct non-null values of
name. A list-valued facet (modalities) gives each element once.- Raises:
ValueError -- If
nameis not a facet of this catalog.
- classmethod from_file(path: str | Path, *, cache_dir: str | Path | None = None) Catalog#
Load a catalog from a local
catalog.parquet(absolute or relative path, orfile://URL).- Parameters:
- path
Local parquet path; validated against the catalog schema like any other catalog.
- cache_dir
Cache directory override.
- query(*, validation: str | None = 'pass', license_set: bool | None = None, noncommercial: bool | None = None, redistributable: bool | None = None, search: str | None = None, expressing: str | list[str] | None = None, mode: str = 'all', min_fraction: float | None = None, **facets: str | float | list[str] | tuple[str, ...] | set[str]) SpatialDataCohort#
Filter the catalog.
To start from known uids or study ids, use
Catalog.cohort().- Parameters:
- validation
Keep rows with this
validation_status(default"pass");Nonedisables. In the current catalog every dataset passes validation, so this filter changes nothing yet. Filter ontier(silver,bronze) for quality.- license_set
If True, keep only rows with a known license (
license_unknownis False); False behaves like None.- noncommercial
If False, keep only data cleared for commercial use:
license_noncommercialis False and the license is known (license_unknownis False), the same set the website counts as "Commercial use OK". Rows with an unknown license are excluded because their terms are not known. If True, keep only NonCommercial data;Nonedisables.- redistributable
If True, keep only data whose license allows redistribution:
license_redistributableis True and the license is known (license_unknownis False). If False, keep the rest, which includes every row with an unknown license.Nonedisables. Every dataset is served. The defaultNoneapplies no license filter, so rows with an unknown license stay in the result; check the license before you reuse data.- search
Free text, as in
search(); the result is intersected with the other filters and carries thematchedfacet values. Withvalidation=None(or"all"),searchstill imposes its ownvalidation_status == "pass"filter unlessvalidation_statuswas itself matched, so failed rows do not survive asearch.- expressing
Gene symbol or Ensembl id, or a list of them; keep datasets where they are expressed (see
genes.where_expressed). The first use downloads the gene index (~900 MB, cached).- mode
With several
expressinggenes:"all"(default, AND) or"any"(union).- min_fraction
Minimum fraction of expressing cells for
expressing; requiresexpressing.- **facets
Facet column -> value (equality) or list/tuple/set of values (isin).
licenseandlicense_noncommercialare facets, so you can also filter by exact license id. String facets compare a value against that column of the whole catalog first. A value that is not there resolves through aliases: case, spaces, hyphens and underscores are ignored, and atechnologyvalue may be anassaydisplay value (technology="10x Xenium"keeps"Xenium"). A value that still does not resolve raisesValueErrorwith a "did you mean" hint. A known value that matches nothing after the other filters gives an empty cohort.hne_imageandif_imagetake True or False. Null means unknown and matches neither.sourceis derived on load as the lowercasedstudy_idprefix before":"; rows without astudy_idhave a null source. In the 2026-10-28 catalog (6087 rows) it isgeo4113,hest1070,10x175,abc115,bia4,metaspace3,bruker3,doi2,figshare2, and null 600.<col>__gte/__gt/__lte/__ltapply a numeric range on a column inRANGE_COLUMNS(e.g.n_obs__gte=50_000); missing values never match.
- Raises:
ValueError -- If a keyword is not a facet or range column, a facet column is absent from the loaded catalog, a facet value is not in the catalog and has no alias, a boolean facet gets a non-bool value, a range value is not numeric, or
min_fractionis given withoutexpressing.
- search(text: str) SpatialDataCohort#
Deterministic text search over facet values.
Each token is fuzzy/substring-matched against the distinct values of each facet. A row matches a token when any of its facet values matches it, in any facet, so "liver" finds rows whose tissue is liver as well as rows whose study_id contains "liver". Tokens are AND-ed: "breast xenium" keeps rows that match both. A token that matches no facet value is ignored, with one warning that names it; if no token matches anything, the result is an empty SpatialDataCohort with a warning.
matchedmaps each facet to the values that matched any token. Rows that failed validation are excluded unlessvalidation_statusitself was matched.