This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error: unexpected symbol using BiomaRt in R

I'm trying to use biomaRt in R to make a table containing HGNC symbols and UnitProt/SwissProt IDs. Here is my code:

ensembl = useMart("ENSEMBL_MART_ENSEMBL", dataset="hsapiens_gene_ensembl")

hgncswissprot <- getBM(attributes=c("hgnc_symbol", "uniprotswissprot"), filters="with_hgnc", values=list(c("ACMSD", "ATP13A2"), TRUE, mart=ensembl)

However, I get this error:

Error: unexpected symbol in: "hgncswissprot <- getBM(attributes=c("hgnc_symbol", "uniprotswissprot"), filters="with_hgnc", values=list(c("ACMSD", "ATP13A2"), TRUE, mart=ensembl) hgncswissprot"

I've been trying to solve this for days but have no idea what I'm doing wrong. I would greatly appreciate any pointers! (:

ensembl r biomart biomart r

1 answer

Hi,

You almost had it. Here is a working example:

ensembl <- useMart(
  'ENSEMBL_MART_ENSEMBL',
  dataset = 'hsapiens_gene_ensembl')

hgncswissprot <- getBM(
  attributes = c('hgnc_symbol', 'uniprotswissprot'),
  filters = c('hgnc_symbol', 'with_hgnc'),
  values = list(c('ACMSD', 'ATP13A2'), TRUE),
  mart = ensembl)

hgncswissprot
  hgnc_symbol uniprotswissprot
1       ACMSD           Q8TDX5
2     ATP13A2           Q9NQ11
3     ATP13A2

Note that we can also have returned to us an entire annotation table, by running this:

annotTable <- getBM(
  attributes = c('hgnc_symbol', 'uniprotswissprot'),
  mart = ensembl)

dim(annotTable)
[1] 33651     2

head(annotTable)
  hgnc_symbol uniprotswissprot
1      MT-ND1           P03886
2      MT-ND2           P03891
3      MT-CO1           P00395
4      MT-CO2           P00403
5     MT-ATP8           P03928
6     MT-ATP6           P00846

Kevin

Log in to answer this question.