scvi.data.fields.ObsmField#

class scvi.data.fields.ObsmField(registry_key, obsm_key, colnames_uns_key=None, is_count_data=False, correct_data_format=True)[source]#

An AnnDataField for an .obsm field in the AnnData data structure.

In addition to creating a reference to the .obsm field, stores the column keys for the obsm field in a more accessible .uns attribute.

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

  • obsm_key (str) – Key to access the field in the AnnData .obsm mapping.

  • colnames_uns_key (Optional[str] (default: None)) – Key to access column names corresponding to each column of the .obsm field in the AnnData .uns mapping. If None, checks if the field is stored as a dataframe. If so, uses the dataframe’s colnames. Otherwise, generates sequential column names (e.g. 1, 2, 3, etc.).

  • is_count_data (bool (default: False)) – If True, checks if the data are counts during validation.

  • correct_data_format (bool (default: True)) – If True, checks and corrects that the AnnData field is C_CONTIGUOUS and csr if it is dense numpy or sparse respectively.

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)

Returns the requested data as determined by the field for a given AnnData/MuData object.

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#

COLUMN_NAMES_KEY

ObsmField.COLUMN_NAMES_KEY = 'column_names'#

attr_key

ObsmField.attr_key[source]#
Return type:

str

attr_name

ObsmField.attr_name[source]#
Return type:

str

is_empty

ObsmField.is_empty[source]#
Return type:

bool

mod_key

ObsmField.mod_key[source]#

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

Return type:

Optional[str]

registry_key

ObsmField.registry_key[source]#
Return type:

str

Methods#

get_data_registry

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

get_field_data

ObsmField.get_field_data(adata)[source]#

Returns the requested data as determined by the field for a given AnnData/MuData object.

Return type:

Union[ndarray, DataFrame]

get_summary_stats

ObsmField.get_summary_stats(state_registry)[source]#

Get summary stats.

Return type:

dict

register_field

ObsmField.register_field(adata)[source]#

Register the field.

Return type:

dict

transfer_field

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

Transfer the field.

Return type:

dict

validate_field

ObsmField.validate_field(adata)[source]#

Validate the field.

Return type:

None

view_state_registry

ObsmField.view_state_registry(state_registry)[source]#

View the state registry.

Return type:

Optional[Table]