This is a test version of Biostars. For the public version, visit https://www.biostars.org.
diferentially expressed ensembl ID to gene symbol conversion

Hi, I am trying to convert my whole list of deferentially expressed genes (DEG) to their respective HGNC symbols against ensembl ID that I have pre-defined in my table.

I referred to some biomart scripts, but seems I could only retrieve all genes mentioned in the ensembl and not according to my requirements.

dim(df)
[1] 56804     7

dim(G_list)
[1] 67180     3

Here's the code I am using-

library('biomaRt')
ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl")
genes = df$Ensembl_ID
G_list <- getBM(filters= "ensembl_gene_id", attributes= c("ensembl_gene_id",
                            "entrezgene_id", "hgnc_symbol"), values=genes, mart=ensembl)

I have my first column as Ensembl ID for DEG, against which I want to add gene symbols. How can I achieve this?

Thanks in advance!

deg ensembl hgnc_symbol biomart

1 answer

I've tried this and works:

library(biomaRt)
ensembl <- useEnsembl(biomart = "genes", dataset = "hsapiens_gene_ensembl")
genes <- "ENSG00000139618"
G_list <- getBM(filters= "ensembl_gene_id", attributes= c("ensembl_gene_id",
                            "entrezgene_id", "hgnc_symbol"), values=genes, mart=ensembl)

Thanks a lot for your response. But, what I am trying to achieve here is, I want to specify a specific column of my data frame (in my case, df) as input, how can I do that?

Exactly the same. This function is vectorized so it'll work on every element of the vector you supply with df$Ensembl_ID

library(biomaRt)
ensembl <- useEnsembl(biomart = "genes", dataset = "hsapiens_gene_ensembl")
genes <- df$Ensembl_ID
G_list <- getBM(filters= "ensembl_gene_id", attributes= c("ensembl_gene_id",
                            "entrezgene_id", "hgnc_symbol"), values=genes, mart=ensembl)

I could finally solve this issue, all the syntax and steps given above are correct. I could not get desired results earlier due to Ensembl version issue in my Ensembl_IDs. I could correct that, by changing values to-

values=substr(genes, 1, 15)

Log in to answer this question.