spac.data_utils.add_pin_color_rules(adata, label_color_dict: dict, color_map_name: str = '_spac_colors', overwrite: bool = True) Tuple[dict, str][source]

Adds pin color rules to the AnnData object and scans for matching labels.

This function scans unique labels in each adata.obs and column names in all adata tables, to find the labels defined by the pin color rule.

Parameters:
  • adata – The anndata object containing upstream analysis.

  • label_color_dict (dict) – Dictionary of pin color rules with label as key and color as value.

  • color_map_name (str) – The name to use for storing pin color rules in adata.uns.

  • overwrite (bool, optional) – Whether to overwrite existing pin color rules in adata.uns with the same name, by default True.

Returns:

  • label_matches (dict) – Dictionary with the matching labels in each section (obs, var, X, etc.).

  • result_str (str) – Summary string with the matching labels in each section (obs, var, X, etc.).

Raises:

ValueError – If color_map_name already exists in adata.uns and overwrite is False.