Thank you, Giovanni. id2eg is part of the pathview package. I ran the conversion with AnnontationDbi and it worked perfectly.
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
1 answer
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
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.
I wanted to convert my gene symbol to entrez id.I have analyzed a GEO dataset and get the DEG .Now i need to convert the gene symbol to entrez id.But the code doesnot work.In my column the first column name is SYMBOL ,second is base mean,third is p.val,fourth log2FC and fifth is adj.p.val.So how can i convert the gene symbol to entrez
Log in to answer this question.
Never used it, but I'd suggest removing the
names(...)
from around 'genes'