Last active
December 12, 2015 10:39
-
-
Save sirusb/4761150 to your computer and use it in GitHub Desktop.
These R code snippets are used to convert between Entrez and Ensembl IDs using biomart web-service. it just exploits the functionalities offered by the biomaRt package.
The code is implemented to call the Biomart web-service each time. you can make it more general by calling the first four lines separatly and just passing the "hsp" variable to f…
This file contains hidden or 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
#Usage example: | |
#EntrezID<-c("2114","9757","5886","9373","6921","4088","7006","6196","10054","10945") | |
#EnsemblID<-EntrezToEnsembl(EntrezID) | |
EntrezToEnsembl<-function(EntrezID){ | |
require(biomaRt); | |
ensemble<-useMart("ensembl"); | |
hsp<-useDataset(mart=ensemble,dataset="hsapiens_gene_ensembl"); | |
ids<-getBM(filters= "entrezgene", | |
attributes= c("entrezgene","ensembl_gene_id", "external_gene_id","description"), | |
values= EntrezID, mart= hsp); | |
return(ids); | |
} |
This file contains hidden or 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
#Usage example: | |
#EnsemblID<-c("ENSG00000164548","ENSG00000118515","ENSG00000105705","ENSG00000177414","ENSG00000108179") | |
#EntrezID<-EnsemblToEntrez(EnsemblID) | |
EnsemblToEntrez<-function(EnsemblIDs){ | |
require(biomaRt) | |
ensemble<-useMart("ensembl") | |
hsp<-useDataset(mart=ensemble,dataset="hsapiens_gene_ensembl") | |
ids<-getBM(filters= "ensembl_gene_id", | |
attributes= c("ensembl_gene_id", "external_gene_id", "entrezgene", "description"), | |
values= EnsemblIDs, mart= hsp) | |
return(ids) | |
} |
This file contains hidden or 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
EntrezToHGNC<-function(EntrezID){ | |
require(biomaRt); | |
ensemble<-useMart("ensembl"); | |
hsp<-useDataset(mart=ensemble,dataset="hsapiens_gene_ensembl"); | |
ids<-getBM(filters= "entrezgene", | |
attributes= c("entrezgene","hgnc_id", "hgnc_symbol","description"), | |
values= EntrezID, mart= hsp); | |
return(ids); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment