gravatar for Filippo Grazioli

2 hours ago by

I'd like to convert the genes identifiers from the following format to ensembl with mygene:

'RP11.27G24.3', 'CTD.2035E11.4', 'CTD.2515C13.2', 'RP11.366M4.18'

This is the function:

import mygene
def get_ensembl_gene_mapping(ensembl_gene_ids):
    mg = mygene.MyGeneInfo()

    records = mg.querymany(
        ensembl_gene_ids,
        scopes='symbol',
        fields='ensembl.gene',
        species='human'
    )

    symbol_to_ensembl = dict()
    ensembl_to_symbol = dict()
    for record in records:
        if 'ensembl' in record:
            if 'gene' in record['ensembl']:
                symbol_to_ensembl[record['query']] = record['ensembl']['gene']
                ensembl_to_symbol[record['ensembl']['gene']] = record['query']
    return symbol_to_ensembl, ensembl_to_symbol

With scopes='symbol', the gene symbols above cannot be found. Does anybody know what the correct scope is?



Source link