Created
October 5, 2012 04:36
-
-
Save dritoshi/3838123 to your computer and use it in GitHub Desktop.
Convert EnsEMBL Gene ID to NCBI Entrez Gene ID in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
R> my.eg
ENSMUSG00000000275 ENSMUSG00000002844 ENSMUSG00000003868
"217069" "11544" "20174"