简体   繁体   中英

log2 transform ff objects

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)可以工作,但是sapply(df[,2:length(df)],log2)如果数据帧较大sapply(df[,2:length(df)],log2)可能会更好。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM