Question: select keys from
gravatar for Assa Yeroslaviz
4.2 years ago by
Assa Yeroslaviz1.4k
Munich, Germany
Assa Yeroslaviz1.4k wrote:



I have a list of pathways with their gene symbols in a list structure.

> my_list

 [1] "Abca1"  "Abca2"  "Abca3"  "Abca17" "Abca4"  "Abca7" "Abca12" "Abca13" "Abca5"  "Abca6"
[11] "Pik3cd"   ...

 [1] "Atm"      "Chek2"    "Atr"      "Chek1"    "Cdkn2a"   "Mdm2"     "Mdm4"     "Trp53"    "Cdkn1a"   "Ccnd1"   
[11] "Ccnd2"    ...

I would like to convert the gene symbols into entrez IDs.

I know it is possible to do with the select command from the at least for one character vector.

> head(select(, keys = my_list[[1]], columns = "ENTREZID", keytype = "SYMBOL"))
1  Abca1    11303
2  Abca2    11305
3  Abca3    27410
4 Abca17   381072
5  Abca4    11304
6  Abca7    27403

But I would like to do it for the complete list and still be able to keep the list structure

thanks in advance

Assa list select • 1.6k views
ADD COMMENTlink modified 4.2 years ago by James W. MacDonald51k • written 4.2 years ago by Assa Yeroslaviz1.4k
Answer: select keys from
gravatar for James W. MacDonald
4.2 years ago by
United States
James W. MacDonald51k wrote:

If you are going to be working with lists, then you should learn to use the *apply family of functions. You can do the same thing that Hans-Rudolph suggests in one line.

my_new_list <- lapply(seq(along = my_list), function(x) select(, my_list[[x]], "ENTREZID","SYMBOL"))

ADD COMMENTlink written 4.2 years ago by James W. MacDonald51k
Answer: select keys from
gravatar for Hotz, Hans-Rudolf
4.2 years ago by
Hotz, Hans-Rudolf400 wrote:

Hi Assa

As a suggestion, here is a quick and dirty way to do it:


my_list <- list(PW1=c("Abca1","Abca2","Abca3","Abca17","Abca4","Abca7"),PW2=c("Abca12","Abca13","Abca5","Abca6"),PW3=c("Atm","Chek2","Atr","Chek1","Cdkn2a","Mdm2","Mdm4","Trp53","Cdkn1a","Ccnd1"))

my_new_list <- list()


for (name in names(my_list)) {my_new_list[[length(my_new_list)+1]] <- select(, keys = my_list[[name]], columns = "ENTREZID", keytype = "SYMBOL")$ENTREZID }



> my_list
[1] "Abca1"  "Abca2"  "Abca3"  "Abca17" "Abca4"  "Abca7"

[1] "Abca12" "Abca13" "Abca5"  "Abca6"

 [1] "Atm"    "Chek2"  "Atr"    "Chek1"  "Cdkn2a" "Mdm2"   "Mdm4"   "Trp53"
 [9] "Cdkn1a" "Ccnd1"

> my_new_list
[1] "11303"  "11305"  "27410"  "381072" "11304"  "27403"

[1] "74591"  "268379" "217265" "76184"

 [1] "11920"  "50883"  "245000" "12649"  "12578"  "17246"  "17248"  "22059"
 [9] "12575"  "12443"




Hope this helps, Hans-Rudolf



ADD COMMENTlink written 4.2 years ago by Hotz, Hans-Rudolf400
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 174 users visited in the last hour