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.