Import Gene Symbol
1
0
Entering edit mode
7.9 years ago
V ▴ 380

Hello,

I'm fairly new to R and I'm having a small issue. I've generated a typical count table where the first column is a list of ensembl identifiers, each one in a different row and every other column is a different sample.

Is there a way now that the table is loaded into R, to switch out the ensembl identifier into the official gene names (e.g , Sox2) ? I'm using the following code but it doesnt seem to be working.

library(biomaRt)
mart <- useMart(biomart = 'ensembl', dataset = 'mmusculus_gene_ensembl')
bm.query <- getBM(values=rownames(counts),attributes=c("ensembl_gene_id", "external_gene_name"),filters=c("ensembl_gene_id"),mart=mart)
genes <- list(ids=rownames(counts),names=bm.query[match(rownames(counts), bm.query$ensembl_gene_id),]$external_gene_id)

I get the following error:

Error in getBM(values = rownames(counts), attributes = c("ensembl_geneid",  : 
  Values argument contains no data.

If anyone could help that would be great.

Thanks!

RNA-Seq • 2.6k views
ADD COMMENT
0
Entering edit mode
7.9 years ago
Denise CS ★ 5.2k

To get gene symbols such as Sox2, you can choose MGI symbols as attributes. BioMart is also available as a web interface in case you want to give it a go as an alternative to biomaRt.

ADD COMMENT
0
Entering edit mode

Hi Denise, thanks for that.

I've modified the code to say the following but it gives me exactly the same error:

library(biomaRt)
    mart <- useMart(biomart = 'ensembl', dataset = 'mmusculus_gene_ensembl')
    bm.query <- getBM(values=rownames(counts),attributes=c("mgi_symbol", "external_gene_name"),filters=c("ensembl_gene_id"),mart=mart)
    genes <- list(ids=rownames(counts),names=bm.query[match(rownames(counts), bm.query$ensembl_gene_id),]$external_gene_id)

Would you be able to clarify what you meant and how that would be written?

I use the Biomart web interface quite often but only to input gene lists for it to convert, the aim of this is to switch it around in the count table so I can avoid having to do that, and for the plots generated in R to have the official gene symbol listed rather than the ensambl ID which essentially isn't that informative or helpful when looking at the plot.

ADD REPLY

Login before adding your answer.

Traffic: 1889 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6