Skip to content

Instantly share code, notes, and snippets.

@svigneau
Last active August 29, 2015 13:57
Show Gist options
  • Save svigneau/9689396 to your computer and use it in GitHub Desktop.
Save svigneau/9689396 to your computer and use it in GitHub Desktop.
Example snippet showing how to query BioMart from R, to find mRNA Refseq Ids associated with mouse gene symbols.
# This snippet queries BioMart to find mRNA Refseq Ids associated with mouse gene symbols.
# Load biomaRt.
library(biomaRt)
# Get vector of gene symbols from a table loaded in R.
genes <- mytable$Gene
# Choose BioMart database and dataset.
mart <- useMart("ensembl", dataset="mmusculus_gene_ensembl")
# Specify filter used to read input values.
# A list of possible filters can be retrieved using listFilters.
filters=c("mgi_symbol")
# Specify attributes to be returned.
# A list of possible attributes can be retrieved using listAttributes.
attributes <- c("chromosome_name", "start_position", "end_position", "mgi_symbol", "refseq_mrna")
# Retrieve attributes for submitted genes.
mynewtable <- getBM(attributes=attributes, filters=filters, values=genes, mart=mart, uniqueRows=T)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment