Mercurial > repos > ethevenot > transformation
view transformation_wrapper.R @ 0:eacea1349a7c draft
planemo upload for repository https://github.com/workflow4metabolomics/transformation.git commit 83f2d1045c0bf086bbe2de5204cd5c1d8354116f
author | ethevenot |
---|---|
date | Fri, 29 Jul 2016 12:11:01 -0400 |
parents | |
children | d9e05021553c |
line wrap: on
line source
#!/usr/bin/Rscript --vanilla --slave --no-site-file library(batch) ## parseCommandArgs source_local <- function(fname){ argv <- commandArgs(trailingOnly = FALSE) base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) source(paste(base_dir, fname, sep="/")) } source_local("transformation_script.R") argVc <- unlist(parseCommandArgs(evaluate=FALSE)) #### Start_of_tested_code <- function() {} ##------------------------------ ## Initializing ##------------------------------ ## options ##-------- strAsFacL <- options()[["stringsAsFactors"]] options(stringsAsFactors=FALSE) ## constants ##---------- modNamC <- "Transformation" ## module name metVc <- c("log2", "log10") ## available methods topEnvC <- environment() flagC <- "\n" ## functions ##---------- flgF <- function(tesC, envC = topEnvC, txtC = NA) { ## management of warning and error messages tesL <- eval(parse(text = tesC), envir = envC) if(!tesL) { sink(NULL) stpTxtC <- ifelse(is.na(txtC), paste0(tesC, " is FALSE"), txtC) stop(stpTxtC, call. = FALSE) } } ## flgF ## log file ##--------- sink(argVc[["information"]]) cat("\nStart of the '", modNamC, "' module: ", format(Sys.time(), "%a %d %b %Y %X"), "\n", sep="") ## loading ##-------- datMN <- t(as.matrix(read.table(argVc[["dataMatrix_in"]], check.names = FALSE, header = TRUE, row.names = 1, sep = "\t"))) metC <- argVc[["method"]] ## checking ##--------- flgF("metC %in% metVc", txtC = paste0("Transformation method must be either '", paste(metVc, collapse = "', '"), "'")) ##------------------------------ ## Computation ##------------------------------ datMN <- transformF(datMN = datMN, ## dataMatrix metC = metC) ## transformation method ##------------------------------ ## Ending ##------------------------------ ## saving ##------- datDF <- cbind.data.frame(dataMatrix = colnames(datMN), as.data.frame(t(datMN))) write.table(datDF, file = argVc[["dataMatrix_out"]], quote = FALSE, row.names = FALSE, sep = "\t") ## ending ##------- cat("\nEnd of the '", modNamC, "' Galaxy module call: ", format(Sys.time(), "%a %d %b %Y %X"), "\n", sep = "") sink() options(stringsAsFactors = strAsFacL) #### End_of_tested_code <- function() {} rm(list = ls())