scvi.data.fields.LayerField#

class scvi.data.fields.LayerField(registry_key, layer, is_count_data=True, correct_data_format=True, check_fragment_counts=False)[source]#

An AnnDataField for layer or X attributes in the AnnData data structure.

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

  • layer (str | None) – Key to access the field in the AnnData layers mapping. If None, uses the data in .X.

  • is_count_data (bool (default: True)) – 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.

  • save_column_names – If True, saves var names to the associated state registry as column_names.

Attributes table#

COLUMN_NAMES_KEY

N_CELLS_KEY

N_OBS_KEY

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

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#

LayerField.COLUMN_NAMES_KEY = 'column_names'#
LayerField.N_CELLS_KEY = 'n_cells'#
LayerField.N_OBS_KEY = 'n_obs'#
LayerField.N_VARS_KEY = 'n_vars'#
LayerField.attr_key[source]#
LayerField.attr_name[source]#
LayerField.is_empty[source]#
LayerField.mod_key[source]#

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

LayerField.registry_key[source]#

Methods#

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

LayerField.get_field_data(adata)[source]#

Returns the requested data as determined by the field.

Return type:

ndarray | DataFrame

LayerField.get_summary_stats(state_registry)[source]#

Get summary stats.

Return type:

dict

LayerField.register_field(adata)[source]#

Register the field.

Return type:

dict

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

Transfer the field.

Return type:

dict

LayerField.validate_field(adata)[source]#

Validate the field.

Return type:

None

LayerField.view_state_registry(_state_registry)[source]#

View the state registry.

Return type:

Table | None