I'm trying to convert ensembl gene ids to mgi ids. I know that I can do this in biomart, but I recently noticed there are a number of mouse annotation packages. I was just wondering what is the best/easiest way to do this?
Thanks
I'm trying to convert ensembl gene ids to mgi ids. I know that I can do this in biomart, but I recently noticed there are a number of mouse annotation packages. I was just wondering what is the best/easiest way to do this?
Thanks
How you define 'best' is sort of personal. I personally prefer to use the annotation packages directly, but biomaRt is a perfectly good way to go as well. If you want to use the annotation packages, you can use either select() or mapIds(). The difference being that mapIds() will by default silently choose one result for any one-to-many mappings whereas select() will not.
> library(org.Mm.eg.db)
## just get some Ensembl IDs
> ensgns <- sample(keys(org.Mm.eg.db, "ENSEMBL"), 500)
> mgis <- mapIds(org.Mm.eg.db, ensgns, "MGI","ENSEMBL")
> head(mgis)
ENSMUSG00000074369 ENSMUSG00000040726 ENSMUSG00000072683 ENSMUSG00000059910
"MGI:MGI:2149033" "MGI:MGI:96071" "MGI:MGI:3648132" "MGI:MGI:3031099"
ENSMUSG00000024298 ENSMUSG00000038384
"MGI:MGI:1921793" "MGI:MGI:2652820"
> mgis2 <- select(org.Mm.eg.db, ensgns, "MGI","ENSEMBL")
'select()' returned 1:many mapping between keys and columns
> head(mgis2)
ENSEMBL MGI
1 ENSMUSG00000074369 MGI:MGI:2149033
2 ENSMUSG00000040726 MGI:MGI:96071
3 ENSMUSG00000072683 MGI:MGI:3648132
4 ENSMUSG00000059910 MGI:MGI:3031099
5 ENSMUSG00000024298 MGI:MGI:1921793
6 ENSMUSG00000038384 MGI:MGI:2652820
> sum(duplicated(mgis2[,1]))
[1] 6
The AnnotationDbi package has a couple of vignettes and a video that you can use to get further acquainted.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.