Wednesday, 11 June 2014

Using biomaRt...

This is a powerful R package for downloading data from mart enabled databases.

First download and enable the package:

source("http://bioconductor.org/biocLite.R")
biocLite("biomaRt")
library("biomaRt", lib.loc="/Library/Frameworks/R.framework/Versions/3.0/Resources/library")


Then
> listMarts()
This gives a list of the Mart (databases) that can be queried. Examples include ensembl, vega, unimart

Uniprot database is unimart

>ensembl = useMart("ensembl")

Then we have Datasets
> listDatasets(ensembl)

> ensembl = useDataset("hsapiens_gene_ensembl", mart=ensembl)

Give a subset of the data.

> filters = listFilters(ensembl)
gives a list of filters

Key command: getBM

  • attributes - vector of attributes on wants to get from the database
  • filters - vector of filters one will use as input for the query (e.g. affy_hg_u133_plus_2) 
  • values - values for the filters (e.g. Affy IDs)
  • mart - the database to be queried (e.g. ensembl)
eg:
> affyids=c("202763_at","209310_s_at","207500_at")
> getBM(attributes=c('affy_hg_u133_plus_2', 'entrezgene'), filters='affy_hg_u133_plus_2', vaulues= affyids, mart=ensembl)

Results:

  affy_hg_u133_plus_2 entrezgene
1         209310_s_at        837
2           207500_at        838
3           202763_at        836

This has the potential to be very useful. 



No comments:

Post a Comment