DatasetSchema
Which column holds each cell-level role, as the project recorded it.
from plexora.api import DatasetSchemaDatasetSchema(
cell_id: str | None = None,
x: str | None = None,
y: str | None = None,
celltype: str | None = None,
image_id: str | None = None,
extra: Mapping[str, str] = dict(),
)A plugin should never hardcode a column name such as "X_centroid" --
that column may not exist, or may be named differently, in the next
dataset. Read the role off the schema instead (schema.x, schema.y,
schema.cell_id, schema.celltype, schema.image_id) and it resolves to
whatever column the project actually recorded for that role, or None
when the project has not recorded one.
Building one is cheap: it reads the project record only, never the
feature table. Which columns are markers is a different question, answered
from the data itself by TableHandle.markers, not by this schema.
Fields
cell_idstr | Nonedefault NoneColumn holding each cell's unique id, or None if not recorded.
xstr | Nonedefault NoneColumn holding each cell's x coordinate, or None if not recorded.
ystr | Nonedefault NoneColumn holding each cell's y coordinate, or None if not recorded.
celltypestr | Nonedefault NoneColumn holding each cell's type/phenotype label, or None if not recorded.
image_idstr | Nonedefault NoneColumn holding the source image id, for a table pooled across several images, or None if not recorded.
extraMapping[str, str]default dict()Roles beyond the five above, keyed by role name. Look one up with
get() rather than indexing this mapping directly.
Methods
from_project
@classmethod
from_project(project: Project) -> 'DatasetSchema | None'Build the schema recorded on a project.
projectProjectrequiredThe project record to read roles from.
DatasetSchema | NoneNone when the project has no feature table, since there are then no columns for a role to name.
get
get(role: str) -> str | NoneLook up a role by name, including one that only exists in extra.
rolestrrequiredThe role name, e.g. "x", or a project-specific role
recorded after this dataclass was written.
str | NoneThe column name for that role, or None if the project never recorded one.