Computation‎ > ‎R‎ > ‎

biomaRt

We are constantly moving things back and forth based on the ensembl annotations we use by default.  If you are using R, you can use the "biomaRt" application for many of these processes.

Thanks to Dave Tang as much of this is adapted from his website (http://davetang.org/muse/2012/04/27/learning-to-use-biomart/)

library(biomaRt)
listMarts()

#Load the generic/current? version
ensembl=useMart("ensembl")

##Load archived versions of ensembl

#GRCh37 based annotations
ensembl_74 = useMart(biomart="ENSEMBL_MART_ENSEMBL", host="dec2013.archive.ensembl.org", path="/biomart/martservice", dataset="hsapiens_gene_ensembl")
ensembl_75 = useMart(biomart="ENSEMBL_MART_ENSEMBL", host="feb2014.archive.ensembl.org", path="/biomart/martservice", dataset="hsapiens_gene_ensembl")

#GRCh38 based annotations
ensemble_76 = useMart(biomart="ENSEMBL_MART_ENSEMBL", host="mar2015.archive.ensembl.org", path="/biomart/martservice", dataset="hsapiens_gene_ensembl")


listDatasets(ensembl)
listDatasets(ensembl)$dataset
ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl")
filters = listFilters(ensembl)
head(filters)
attributes = listAttributes(ensembl)
head(attributes)

#Extract the ENSG identifier and the HUGO identifier
test <- 'ENSG00000118473'
getBM(attributes=c('ensembl_gene_id', "hgnc_symbol"), filters = "ensembl_gene_id", values=test, mart=ensembl)
test2 <- 'TRAF3'
getBM(attributes=c('ensembl_gene_id', "hgnc_symbol"), filters = "external_gene_name", values=test2, mart=ensembl)
#OR
getBM(attributes=c('ensembl_gene_id', "hgnc_symbol"), filters = "hgnc_symbol", values=test2, mart=ensembl)
Comments