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!
Hi Denise, thanks for that.
I've modified the code to say the following but it gives me exactly the same error:
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.