obtain_new_label

besca.tl.sig.obtain_new_label(nomenclature_file: str, cnames: DataFrame, reference_label: str = 'short_dblabel', new_label: str = 'dblabel', new_level: Optional[int] = None) DataFrame[source]

Matches the cnames obtained by the make_annot function or a list of label names to the db label (standardized label from a nomenclature file).

Parameters:
  • nomenclature_file ('str') – path to the nomenclature file (one available in besca/datasets)

  • cnames (panda.DataFrame or list) – a dataframe with cluster to cell type attribution per distinct levels or a list of names

  • reference_label ('str') – column in nomenclature file that corresponds to the names in cnames (short_dblabel if from make_annot function)

  • new_label ('str') – column in nomenclature file that is used for the translation (e.g. ‘dblabel’ or ‘EFO’)

  • new_level (int) – Keep the level if None or translate to a lower level e.g. 0, 1, 2, 3, 4

Returns:

  • panda.DataFrame containing the different levels of the nomenclature indexed by cluster

  • (based on cnames index)

Example

>>> import besca as bc
>>> import pkg_resources
>>> adata = bc.datasets.simulated_pbmc3k_processed()
>>> new_cnames = bc.tl.sig.obtain_new_label(
...     nomenclature_file=pkg_resources.resource_filename('besca', 'datasets/nomenclature/CellTypes_v1.tsv'),
...     cnames=list(adata.obs['dblabel'].cat.categories),
...     reference_label='dblabel',
...     new_label = 'dblabel',
...     new_level = 2)