Best way to convert ensembl id to mgi?
Entering edit mode
Jake ▴ 90
Last seen 9 months ago
United States

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?


annotation biomart • 2.5k views
Entering edit mode
Last seen 1 day ago
United States

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(
## just get some Ensembl IDs
> ensgns <- sample(keys(, "ENSEMBL"), 500)
> mgis <- mapIds(, 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(, 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.


Login before adding your answer.

Traffic: 139 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6