This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Converting Entrez gene ids to Ensembl gene ids

I want a map a set of Entrez gene ids to Ensembl gene ids. I came across some posts that mention about mapping Ensembl ids to Entrez ids using Biomart. I am not sure how to do the mapping the other way round.

I would like to do this programmatically. Any suggestions on how the mapping can be done?

gene entrez ensembl

1 answer

You can use Ensembl Biomart for this. Follow previous instructions just swapping the IDs, i.e. use Entrez gene IDs as filter and retrieve Ensembl IDs as attribute. Programmatically, you can use the Ensembl perl API or the Bioconductor R package biomaRt. With the Ensembl API, this could be something along the lines of:

my $registry = "Bio::EnsEMBL::Registry";
$registry->load_all(".ensembl_init");
my $gene_adaptor = $registry->get_adaptor('Homo sapiens', 'core', 'gene');
my $extID = 5347;
my @genes = @{$gene_adaptor->fetch_all_by_external_name($extID)};
library("biomaRt")                                                                                                                   
listMarts()                                                                                                                           
ensembl <- useMart("ensembl",dataset="hsapiens_gene_ensembl")                                                                         
filters = listFilters(ensembl)                                                                                                        
entrezgene = ("3098","728642|982")             
genes <- getBM(filters="entrezgene_id", attributes=c("ensembl_gene_id","entrezgene_id"), values=entrezgene, mart=ensembl)                                                                                                                 
print(genes)

Thanks a lot for the response. I have tired the above in R. When entrezgene = ("3098") the code works fine.

When the input is changed to entrezgene = ("3098","728642|982") , the following error occurs

Error: unexpected ',' in "entrezgene = ("3098","                                                                                      
Execution halted

Also, I am not sure how to map cases like this ""728642|982" which is present in my input data containing list of entrez gene ids.

Any suggestions?

I don't know where your data is coming from but a pipe symbol i.e. |, is often used to delimit two pieces of data related to the same item, here two IDs relating to the same gene. The error you're getting is because you have a syntax error. In R, a vector is specified with c(), i.e. entrezgene = c("3098","728642|982").

Log in to answer this question.