gprofiler output ENSG to gene name I would like to ask if there is any tool or R script that translates Ensembl IDs to gene names in a gprofiler GO output. An example of this file is the following one:
This is usually done using AnnotationDbi in combination with the annotation database for human org.Hs.eg.db.
library(org.Hs.eg.db)
genes &lt;- c(&quot;ENSG00000102055&quot;, &quot;ENSG00000232605&quot;, &quot;ENSG00000136828&quot;,
           &quot;ENSG00000159197&quot;, &quot;ENSG00000201394&quot;, &quot;ENSG00000278580&quot;,
           &quot;ENSG00000213440&quot;, &quot;ENSG00000166816&quot;, &quot;ENSG00000275895&quot;,
           &quot;ENSG00000105723&quot;)
select(org.Hs.eg.db, genes, c(&quot;ENSEMBL&quot;, &quot;ALIAS&quot;), &quot;ENSEMBL&quot;)

This returns:
           ENSEMBL     ALIAS
1  ENSG00000102055       I-4
2  ENSG00000102055  PPP1R2P9
3  ENSG00000102055   PPP1R2C
4  ENSG00000232605      &lt;NA&gt;
5  ENSG00000136828   RALGEF2
6  ENSG00000136828  RALGPS1A
7  ENSG00000136828   RALGPS1
8  ENSG00000159197     ATFB4
9  ENSG00000159197      LQT5
10 ENSG00000159197      LQT6
11 ENSG00000159197     MIRP1
12 ENSG00000159197     KCNE2
13 ENSG00000201394   RN5S140
14 ENSG00000201394 RNA5SP140
15 ENSG00000278580      &lt;NA&gt;
16 ENSG00000213440      &lt;NA&gt;
17 ENSG00000166816     DLACD
18 ENSG00000166816       DLD
19 ENSG00000166816      LDHD
20 ENSG00000275895   U2AF1L5
21 ENSG00000105723     GSK3A

If you want to apply a 1:1 mapping of gene IDs to common names, you can use the &quot;SYMBOL&quot; column. In a data.frame, you can do something like this:
ensembl_to_symbol &lt;- function(e) {
  hits &lt;- select(org.Hs.eg.db, e, &quot;SYMBOL&quot;, &quot;ENSEMBL&quot;)$SYMBOL
  # Gene IDs without symbols should just stay as IDs
  no_hit &lt;- is.na(hits)
  hits[no_hit] &lt;- e[no_hit]
  hits
}

recode_symbols &lt;- function(s) {
  e &lt;- ensembl_to_symbol(unlist(strsplit(s, split = &quot;,&quot;)))
  paste(e, collapse = &quot;,&quot;)
}

df &lt;- data.frame(
  genes = c(paste(genes[1:5], collapse = &quot;,&quot;),
            paste(genes[6:10], collapse = &quot;,&quot;)
  )
)

df$genes &lt;- sapply(df$genes, recode_symbols)

This isn't the most vectorized (fast) solution, but it's probably easier to understand this way.