Skip to content

Instantly share code, notes, and snippets.

@dritoshi
Created October 5, 2012 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dritoshi/3838123 to your computer and use it in GitHub Desktop.
Save dritoshi/3838123 to your computer and use it in GitHub Desktop.
Convert EnsEMBL Gene ID to NCBI Entrez Gene ID in R
library("org.Mm.eg.db")
my.ensmusg <- c("ENSMUSG00000000275", "ENSMUSG00000002844", "ENSMUSG00000003868", "ENSMUSG00000091821", "HOGE")
a <- sapply(my.ensmusg, function(x) exists(x, org.Mm.egENSEMBL2EG))
my.ensmusg.existed <- my.ensmusg[a]
my.ensmusg.existed
@dritoshi
Copy link
Author

dritoshi commented Oct 5, 2012

R> my.eg
ENSMUSG00000000275 ENSMUSG00000002844 ENSMUSG00000003868
"217069" "11544" "20174"

@sudevschiz
Copy link

The my.ensmusg.existed in the last line would only print the the EnsEMBL Gene ID,
Had to change the code a little bit to give the desired output :


# source("https://bioconductor.org/biocLite.R")
# biocLite("org.Mm.eg.db")

library("org.Mm.eg.db")

my.ensmusg <- c("ENSMUSG00000000275", "ENSMUSG00000002844", "ENSMUSG00000003868", "ENSMUSG00000091821", "HOGE")

a <- sapply(my.ensmusg, function(x) exists(x, org.Mm.egENSEMBL2EG))
my.ensmusg.existed <- my.ensmusg[a]

xx <- as.list(org.Mm.egENSEMBL2EG)
xx[my.ensmusg.existed]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment