Question: Converting Gene Symbol to EntrezID with id2eg
gravatar for mcaruso314
5.3 years ago by
United States
mcaruso3140 wrote:

Can someone help explain how I can convert a list of gene symbols to entrez IDs? I am trying to use id2eg. I start by reading in a .txt file with a list of mouse gene IDs and then try to use the id2eg( ) function. I don't get how to convert the variable to make it match the data Below is an example:


# Example of first 10 genes 

genes <- c("Sergef", "Zfp949", "Endog", "Gstt3", "Mccc1", 
           "Cndp2", "Cep78", "Tmem147", "Cox6a1", "Tcn2")  

# convert gene symbol IDs to EntrezIDs <- id2eg(ids = names(genes), category = gene.idtype.list[1], org = "Mm")

No matter how I try to change the variable I get the same the following error:

Error in as.vector(x, "character") : 
  cannot coerce type 'environment' to vector of type 'character'


Any help will be greatly appreciated. 





gene ids R • 5.4k views
ADD COMMENTlink modified 5.3 years ago • written 5.3 years ago by mcaruso3140

Never used it, but I'd suggest removing the


from around 'genes'

ADD REPLYlink written 5.3 years ago by russhh5.5k

Thank you, Giovanni. id2eg is part of the pathview package. I ran the conversion with AnnontationDbi and it worked perfectly.

ADD REPLYlink modified 15 months ago by Ram32k • written 5.3 years ago by mcaruso3140

You are welcome. After the conversion, remember to check if there are any NAs (symbols not converted), or any duplicated entrez (symbols matching to the same id).

p.s. biostar works differently from other forums. You should use the "add comment" function to answer to a reply, instead of adding a new reply like you did here.

ADD REPLYlink written 5.3 years ago by Giovanni M Dall'Olio27k
gravatar for Giovanni M Dall'Olio
5.3 years ago by
London, UK
Giovanni M Dall'Olio27k wrote:

I am not familiar with id2eg (from which package?).

I think the most standard way to do this in R is to use the Annotation packages:

> source("")
> library(AnnotationDbi)
> library(
> AnnotationDbi::select(, keys=genes, columns='ENTREZID', keytype='SYMBOL')
1   Sergef    27414
2   Zfp949    71640
3    Endog    13804
4    Gstt3   103140
5    Mccc1    72039
6    Cndp2    66054
7    Cep78   208518
8  Tmem147    69804
9   Cox6a1    12861
10    Tcn2    21452
ADD COMMENTlink modified 15 months ago by Ram32k • written 5.3 years ago by Giovanni M Dall'Olio27k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1718 users visited in the last hour