Question: Converting Gene Symbol to EntrezID with id2eg
0
gravatar for mcaruso314
3.4 years ago by
mcaruso3140
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:

library(pathview)

# Example of first 10 genes 

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

# convert gene symbol IDs to EntrezIDs

id.map.symbol <- 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. 

 

Mike

 

 

gene ids R • 3.0k views
ADD COMMENTlink modified 3.4 years ago • written 3.4 years ago by mcaruso3140

Never used it, but I'd suggest removing the

names(...)

from around 'genes'

ADD REPLYlink written 3.4 years ago by russhh4.3k
0
gravatar for Giovanni M Dall'Olio
3.4 years ago by
London, UK
Giovanni M Dall'Olio26k 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("https://bioconductor.org/biocLite.R")
>biocLite("org.Mm.eg.db")
> library(AnnotationDbi)
> library(org.Mm.eg.db)
> AnnotationDbi::select(org.Mm.eg.db, keys=genes, columns='ENTREZID', keytype='SYMBOL')
    SYMBOL ENTREZID
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 written 3.4 years ago by Giovanni M Dall'Olio26k
0
gravatar for mcaruso314
3.4 years ago by
mcaruso3140
United States
mcaruso3140 wrote:

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

 

 

ADD COMMENTlink written 3.4 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 3.4 years ago by Giovanni M Dall'Olio26k
Please log in to add an answer.

Help
Access

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