scviva.data.SpatialCoordsField#

class scviva.data.SpatialCoordsField(obsm_key)[source]#

AnnData obsm field for 2D/3D spatial coordinates.

Wraps scvi’s ObsmField with coordinate dimensionality validation. Stores coordinates as-is (no normalization) — callers may normalize before registration if needed.

Parameters:
obsm_key str

Key to access the spatial coordinates in adata.obsm.

Attributes table

COLUMN_NAMES_KEY

attr_key

The key of the data field within the relevant AnnData attribute.

attr_name

The name of the AnnData attribute where the data is stored.

is_empty

Returns True if the field is empty as a function of its kwargs.

mod_key

The modality key of the data field within the MuData (if applicable).

registry_key

The key that is referenced by models via a data loader.

Methods table

get_data_registry()

Returns a nested dictionary which describes the mapping to the data field.

get_field_data(adata)

Get the spatial coordinates from adata.obsm and validate their dimensionality.

get_summary_stats(state_registry)

Get summary stats.

register_field(adata)

Register the field.

transfer_field(state_registry, adata_target, ...)

Transfer the field.

validate_field(adata)

Validate the field.

view_state_registry(state_registry)

View the state registry.

Attributes

SpatialCoordsField.COLUMN_NAMES_KEY = 'column_names'#
SpatialCoordsField.attr_key#
SpatialCoordsField.attr_name#
SpatialCoordsField.is_empty#
SpatialCoordsField.mod_key#

The modality key of the data field within the MuData (if applicable).

SpatialCoordsField.registry_key#

Methods

SpatialCoordsField.get_data_registry()[source]#

Returns a nested dictionary which describes the mapping to the data field.

The dictionary is of the form {“mod_key”: mod_key, “attr_name”: attr_name, “attr_key”: attr_key}. This mapping is then combined with the mappings of other fields to make up the data registry.

Return type:

dict

SpatialCoordsField.get_field_data(adata)[source]#

Get the spatial coordinates from adata.obsm and validate their dimensionality.

Parameters:
adata

AnnData object containing the coordinates in adata.obsm[obsm_key].

Returns:

The coordinate array, with shape (n_obs, 2) or (n_obs, 3).

Raises:

ValueError – If the coordinates do not have 2 or 3 columns.

SpatialCoordsField.get_summary_stats(state_registry)[source]#

Get summary stats.

Return type:

dict

SpatialCoordsField.register_field(adata)[source]#

Register the field.

Return type:

dict

SpatialCoordsField.transfer_field(state_registry, adata_target, **kwargs)[source]#

Transfer the field.

Return type:

dict

SpatialCoordsField.validate_field(adata)[source]#

Validate the field.

Return type:

None

SpatialCoordsField.view_state_registry(state_registry)[source]#

View the state registry.

Return type:

Table | None