scvi.data.fields.ProteinObsmField#
- class scvi.data.fields.ProteinObsmField(registry_key, obsm_key, use_batch_mask=True, batch_key=None, colnames_uns_key=None, is_count_data=False, correct_data_format=True)[source]#
An AnnDataField for an protein data stored in an .obsm field of an AnnData object.
For usage with the TotalVI model. Computes an additional mask which indicates where batches are missing protein data.
- 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.
- use_batch_mask :
bool
(default:True
) If True, computes a batch mask over the data for missing protein data. Requires
batch_key
to be not None.- batch_key :
str
|None
Optional
[str
] (default:None
) Key corresponding to the .obs field where batch indices are stored. Used for computing a batch mask over the data for missing protein data.
- colnames_uns_key :
str
|None
Optional
[str
] (default:None
) Key to access column names corresponding to each column of the .obsm field in the AnnData .uns mapping. Only used when .obsm data is a np.ndarray, not a pd.DataFrame.
- 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.
- registry_key :
Attributes table#
The key of the data field within the relevant AnnData attribute. |
|
The name of the AnnData attribute where the data is stored. |
|
Returns True if the field is empty as a function of its kwargs. |
|
The key that is referenced by models via a data loader. |
Methods table#
Returns a nested dictionary which describes the mapping to the AnnData data field. |
|
|
Returns the requested data as determined by the field for a given AnnData object. |
|
Returns a dictionary comprising of summary statistics relevant to the field. |
|
Sets up the AnnData object and creates a mapping for scvi-tools models to use. |
|
Takes an existing scvi-tools setup dictionary and transfers the same setup to the target AnnData. |
|
Validates whether an AnnData object is compatible with this field definition. |
|
Returns a |
Attributes#
COLUMN_NAMES_KEY#
- ProteinObsmField.COLUMN_NAMES_KEY = 'column_names'#
PROTEIN_BATCH_MASK#
- ProteinObsmField.PROTEIN_BATCH_MASK = 'protein_batch_mask'#
attr_key#
attr_name#
is_empty#
registry_key#
Methods#
get_data_registry#
- ProteinObsmField.get_data_registry()#
Returns a nested dictionary which describes the mapping to the AnnData data field.
The dictionary is of the form {“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
get_field_data#
get_summary_stats#
- ProteinObsmField.get_summary_stats(state_registry)#
Returns a dictionary comprising of summary statistics relevant to the field.
- Parameters
- state_registry :
dict
Dictionary returned by
register_field()
. Summary stats should always be a function of information stored in this dictionary.
- state_registry :
- Return type
- Returns
summary_stats_dict The dictionary is of the form {summary_stat_name: summary_stat_value}. This mapping is then combined with the mappings of other fields to make up the summary stats mapping.
register_field#
transfer_field#
- ProteinObsmField.transfer_field(state_registry, adata_target, **kwargs)[source]#
Takes an existing scvi-tools setup dictionary and transfers the same setup to the target AnnData.
Used when one is running a pretrained model on a new AnnData object, which requires the mapping from the original data to be applied to the new AnnData object.
- Parameters
- state_registry :
dict
state_registry dictionary created after registering an AnnData using an
AnnDataManager
object.- adata_target :
AnnData
AnnData object that is being registered.
- **kwargs
Keyword arguments to modify transfer behavior.
- state_registry :
- Return type
- Returns
dict A dictionary containing any additional state required for scvi-tools models not stored directly on the AnnData object.
validate_field#
view_state_registry#
- ProteinObsmField.view_state_registry(state_registry)#
Returns a
rich.table.Table
summarizing a state registry produced by this field.- Parameters
- state_registry :
dict
Dictionary returned by
register_field()
. Printed summary should always be a function of information stored in this dictionary.
- state_registry :
- Return type
- Returns
state_registry_summary Optional
rich.table.Table
summarizing thestate_registry
.