Question: Best way to convert ensembl id to mgi?
gravatar for Jake
4.1 years ago by
United States
Jake60 wrote:

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 • 1.8k views
ADD COMMENTlink modified 4.1 years ago by James W. MacDonald52k • written 4.1 years ago by Jake60
Answer: Best way to convert ensembl id to mgi?
gravatar for James W. MacDonald
4.1 years ago by
United States
James W. MacDonald52k wrote:

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.

ADD COMMENTlink written 4.1 years ago by James W. MacDonald52k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 143 users visited in the last hour