I would like to log2 transform all numeric values in a ff
object from ff
package.
Using my df
:
library(ff)
df <- 'probeset_id sample1 sample2 sample3
probe_1 1834.2 1743.4 1384
probe_2 4711 4922 4650
probe_3 4555 1387 4650.8
probe_4 2588 1325 3258'
df <- read.table(text=df, header=T)
write.table(df, "del.txt", col.names=T, row.names=F, quote=F, sep="\t")
df <- read.table.ffdf(file="del.txt", header=T)
I tried the below code but I got an error:
df[, 2:length(df)] <- log(df[2:length(df)], 2)
Error in log(df[2:length(df)], 2) :
non-numeric argument to mathematical function
There exist a way to apply this funtion to ff
objects?
log(df[,2:length(df)],2)
works but sapply(df[,2:length(df)],log2)
might work better if you've a big dataframe.