This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Getting ensembl ID from gene symbol for rat(rn6) in biomart

Hi I am trying to get ensembl ID from official gene symbol of rat (rn6) using biomart and below is the code but the last line has error.

library("biomaRt")
listMarts()
ensembl <- useMart("ensembl")
datasets <- listDatasets(ensembl)
ensembl = useDataset("rnorvegicus_gene_ensembl",mart=ensembl)
Gene <- read.csv("TMM-normalizedcounts-ANOVA-8-30-19.csv",header=T)
final <- getBM(attributes=c('external_gene_name','ensembl_gene_id'), filters = 'external_gene_name', values = Gene$Gene Symbol, mart = ensembl)

Can anyone help me in correcting the code.

Thanks in advance.

r

1 answer

Hello,

What is the error? What is the output of str(Gene)?

The error is likely caused by this:

getBM(..., values = Gene$Gene Symbol, ...)

This will cause an error (the space): Gene$Gene Symbol

Just to confirm, you are already using the correct attributes:

library('biomaRt')
listMarts()
ensembl <- useMart("ensembl")
datasets <- listDatasets(ensembl)
ensembl = useDataset("rnorvegicus_gene_ensembl",mart=ensembl)
annot <- getBM(attributes=c('external_gene_name','ensembl_gene_id'), mart = ensembl)

head(annot)
  external_gene_name    ensembl_gene_id
1        AY172581.13 ENSRNOG00000031780
2         AY172581.9 ENSRNOG00000030478
3         AY172581.3 ENSRNOG00000029171
4        AY172581.24 ENSRNOG00000043866
5        AY172581.14 ENSRNOG00000032112
6             Mt-nd1 ENSRNOG00000030644

tail(annot)
      external_gene_name    ensembl_gene_id
32878     AABR07020983.1 ENSRNOG00000051347
32879     AABR07038690.1 ENSRNOG00000003345
32880             Pou5f1 ENSRNOG00000046487
32881               Sox5 ENSRNOG00000027869
32882              Eda2r ENSRNOG00000013018
32883            Ccdc88b ENSRNOG00000024931

Kevin

A minor addition - Kevin already solved your problem, I think. Try

Gene$`Gene Symbol` #notice the back-ticks

instead of

Gene$Gene Symbol

Please accept Kevin's answer to mark this question as resolved.

Log in to answer this question.