atlas_protocol_scripts.pp.validate_obs#

atlas_protocol_scripts.pp.validate_obs(adata_obs, ref_meta_dict, keys_to_ignore=None)#

Validates the metadata in the adata.obs or a pandas DataFrame against a reference metadata dictionary.

This function validates the metadata information in the .obs attribute of an AnnData object or a Pandas DataFrame against a reference metadata dictionary ref_meta_dict. The ref_meta_dict should be a dictionary where the keys represent the metadata columns to be validated, and the values are dictionaries with a ‘values’ key containing a list of allowed values for that metadata column. The function raises a ValueError if any missing columns or invalid values are found in the metadata columns of the AnnData object. The keys_to_ignore parameter can be used to specify a list of keys that should be ignored during validation. If missing columns are found, the error message will include the missing columns in the order of the input dictionary. If invalid values are found, the error message will include the invalid values for the corresponding column.

Parameters
  • adata_obs (DataFrame) – Pandas DataFrame or .obs attribute of an AnnData object to be validated.

  • ref_meta_dict (dict[str, dict[str, list]]) – Reference metadata dictionary.

  • keys_to_ignore (Optional[list[str]] (default: None)) – List of keys to ignore during validation. Defaults to None.

Return type

None