[0b32b6]: / R-scripts / scripts / log2matrix.R

Download this file

13 lines (13 with data), 515 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Support function to apply log2(+1) to a matrix
log2matrix <- function(folder, file.name){
# Read table
data <- as.matrix(read.table(paste(folder,file.name,sep="/"),sep=" ",row.names=1,header=TRUE))
# Apply transformation
data <- log2(data+1)
# Output file name
output <- paste(folder,paste0("log_",file.name), sep="/")
# Export transformed data
write.table(data,output,sep=" ", col.names=TRUE, row.names=TRUE)
# ?
system(paste("sed -i '1s/^/probe\t/'", output, sep=" "))
}