How to convert Entrez ids in a large list into gene symbols and replace entrez ids in list in R?

Viewed 401

I have a large list data with 300 names. For eg:

dput(data$name1)
c("55024", "29126", "3732", "1960", "79368", "115352", "10875", 
"2530", "348654", "3070", "29969", "9124", "10125", "143686", 
"6504", "25992", "26137")

dput(data$name2)
c("323", "836", "9976", "1407", "1840", "2289", "2317", "2739", 
"8337", "10964", "3572", "3693", "4023", "4058", "124540", "4638", 
"5214", "6238", "8115", "7049", "8459", "10791", "55884", "7494", 
"7535")

df <- as.data.frame(data$name1)
colnames(df)[1] <- "ENTREZ_IDs"

library(clusterProfiler)
library(org.Hs.eg.db)
### Convert Entrez to Ensembl ids and Gene names
Ensembl_GeneNames <- bitr(df$ENTREZ_IDs, fromType = "ENTREZID",
                          toType = c("SYMBOL"),
                          OrgDb = org.Hs.eg.db)

This is the output I got:

enter image description here

Now, I want to replace the ENTREZID of name1 in the large list data with SYMBOL from the above output.

Would like to do this for all names in the large list data

1 Answers

We may loop over the list and apply the bitr

out <- lapply(data, \(x) bitr(x, fromType = "ENTREZID",
                          toType = c("SYMBOL"),
                          OrgDb = org.Hs.eg.db)[['SYMBOL']])
Related