Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

How can I convert Ensembl ID to gene symbol in R?

$
0
0

I have a data.frame containing Ensembl IDs in one column; I would like to find corresponding gene symbols for the values of that column and add them to a new column in my data frame. I used bioMaRt but It couldn't find any of the Ensembl IDs!

Here is my sample data (df[1:2,]):

row.names organism    gene
41  Homo-Sapiens ENSP00000335357
115 Homo-Sapiens ENSP00000227378

and I want to get something like this

row.names organism    gene         id
41  Homo-Sapiens ENSP00000335357   CDKN3
115 Homo-Sapiens ENSP00000227378   HSPA8

and here is my code:

library('biomaRt')
mart <- useDataset("hsapiens_gene_ensembl", useMart("ensembl"))
genes <- df$genes
df$id <- NA
G_list <- getBM(filters= "ensembl_gene_id", attributes= c("ensembl_gene_id",
"entrezgene", "description"),values=genes,mart= mart)

Then I get this when I check the G_list

[1] ensembl_gene_id entrezgene      description  <0 rows> (or 0-length row.names)

So I couldn't add G_list to my df! because there is nothing to add!

Thanks in Advance,


Viewing all articles
Browse latest Browse all 201867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>