scvi.data.fields.LabelsWithUnlabeledObsField#

class scvi.data.fields.LabelsWithUnlabeledObsField(registry_key, obs_key, unlabeled_category)[source]#

An AnnDataField for labels which include explicitly unlabeled cells.

Remaps the unlabeled category to the final index if present in labels. The unlabeled category is a specific category name specified by the user.

Parameters:
  • registry_key (str) – Key to register field under in data registry.

  • obs_key (str | None) – Key to access the field in the AnnData obs mapping. If None, defaults to registry_key.

  • unlabeled_category (str | int | float) – Value assigned to unlabeled cells.

Attributes table#

CATEGORICAL_MAPPING_KEY

ORIGINAL_ATTR_KEY

UNLABELED_CATEGORY

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)

Returns the requested data as determined by the field.

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 field.

view_state_registry(state_registry)

View state registry.

Attributes#

LabelsWithUnlabeledObsField.CATEGORICAL_MAPPING_KEY = 'categorical_mapping'#
LabelsWithUnlabeledObsField.ORIGINAL_ATTR_KEY = 'original_key'#
LabelsWithUnlabeledObsField.UNLABELED_CATEGORY = 'unlabeled_category'#
LabelsWithUnlabeledObsField.attr_key[source]#
LabelsWithUnlabeledObsField.attr_name[source]#
LabelsWithUnlabeledObsField.is_empty[source]#
LabelsWithUnlabeledObsField.mod_key[source]#

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

LabelsWithUnlabeledObsField.registry_key[source]#

Methods#

LabelsWithUnlabeledObsField.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

LabelsWithUnlabeledObsField.get_field_data(adata)[source]#

Returns the requested data as determined by the field.

Return type:

ndarray | DataFrame

LabelsWithUnlabeledObsField.get_summary_stats(state_registry)[source]#

Get summary stats.

Return type:

dict

LabelsWithUnlabeledObsField.register_field(adata)[source]#

Register the field.

Return type:

dict

LabelsWithUnlabeledObsField.transfer_field(state_registry, adata_target, allow_missing_labels=False, **kwargs)[source]#

Transfer the field.

Return type:

dict

LabelsWithUnlabeledObsField.validate_field(adata)[source]#

Validate field.

Return type:

None

LabelsWithUnlabeledObsField.view_state_registry(state_registry)[source]#

View state registry.

Return type:

Table | None