Hello,

I often have data frames where I need to perform ID conversions on one or
more of the columns while preserving the order of the rows, e.g.:

GeneSymbol    Value1    Value2
GS1    2.5    0.1
GS2    3    0.2
..

And I want to obtain:

GeneSymbol    EntrezGeneID    Value1    Value2
GS1    EG1    2.5    0.1
GS2    EG2    3    0.2
..

What I've done so far was to create a function that uses org.Hs.eg.db to
loop over the rows of the column and does the conversion:

library(org.Hs.eg.db)
alias2EG <- function(x) {
for (i in 1:length(x)) {
if (!is.na(x[i])) {
repl <- org.Hs.egALIAS2EG[[x[i]]][1]
if (!is.null(repl)) {
x[i] <- repl
}
else {
x[i] <- NA
}
}
}
return(x)
}

and then call the function like this:

df$EntrezGeneID <- alias2GS(df$GeneSymbol)

This works well, but gets very slow when I need to do multiple conversions
on large datasets.

Is there any way I can achieve the same result but in a quicker, more
efficient way?

Thank you.

-- 
Enrico Ferrero
PhD Student
Department of Genetics
Cambridge Systems Biology Centre
University of Cambridge

	[[alternative HTML version deleted]]

