match_label

besca.tl.sig.match_label(vector_label: list, nomenclature_file: str, start_column: str = 'dblabel', match_column: str = 'short_dblabel') DataFrame[source]

Return a table matching values in vector label. It is mean to translate labels , for example for plotting

vector_label: list

initial list of values to match

nomenclature_file: str

location of the nomenclature_file

start_column: str | default = dblabel

column to start within the nomenclature

match_column: str | default = short_dblabel

column to match within the nomenclature

pd.DataFrame

Pandas dataframe containing the matching labels. If matchings labels are not found, the value is kept as is.

>>> import besca as bc
>>> import scanpy as sc
>>> import pkg_resources
>>> adata = bc.datasets.simulated_pbmc3k_processed()
>>> nomenclature_file=pkg_resources.resource_filename('besca', 'datasets/nomenclature/CellTypes_v1.tsv'),
>>> nomenclature_file=''.join(nomenclature_file)
>>> matching_v = bc.tl.sig.match_label(adata.obs.get( ["celltype3"]),  nomenclature_file)
>>> adata.obs['shortlabel'] = adata.obs.get( "celltype3").map( dict(matching_v.values))
>>> sc.pl.umap(adata, color=['shortlabel'])