omicverse.utils.convert2symbol¶
- omicverse.utils.convert2symbol(adata, scopes=None, subset=True)[source]¶
Convert Ensembl IDs in
adata.var_namesto official gene symbols.- Parameters:
adata (AnnData) – Input AnnData object whose
var_namescontain Ensembl gene or transcript IDs (e.g.ENSG*,ENSMUSG*,ENST*).scopes (str, iterable, or None, optional) –
Identifier type passed to
convert2gene_symbol(). Common values are'ensembl.gene'and'ensembl.transcript'. IfNone, the scope is inferred from the first entry ofadata.var_names:ENSG*/ENSMUSG*→'ensembl.gene'ENST*/ENSMUST*→'ensembl.transcript'
subset (bool, optional) – If
True(default), genes that could not be converted are dropped fromadata. IfFalse, unconverted genes retain their original Ensembl ID.
- Returns:
Updated AnnData with
var_namesreplaced by official gene symbols. The original Ensembl IDs are preserved inadata.var['query'].- Return type:
AnnData
- Raises:
Exception – If
scopesisNoneand the gene IDs cannot be recognised asensembl.geneorensembl.transcript.
Examples
>>> adata = ov.utils.convert2symbol(adata) >>> adata = ov.utils.convert2symbol(adata, subset=False)