Entering edit mode
5.0 years ago
nattzy94
▴
60
I am trying to convert gene symbols in one column to gene IDs. I am using the following code to achieve this:
for (i in 1:nrow(data_gsea2)){
data_gsea2$ID[i] <- mapIds(org.Hs.eg.db, (data_gsea2$ID[i]), "ENTREZID", "SYMBOL")
}
I have a dataframe of 7386 rows/genes and this is taking forever to complete. I'm sure there is a smarter way to do this but I'm not sure how to. Anyone can help?
Thanks very much!
If you've verified this command works as you expect it to (by, say, running it on ten rows instead of the entire data.frame), you'll probably just have to wait for the process to complete.
Yes, it works but takes a long time.
Try using
apply
(or even better,mclapply
) instead of using a loop.