Mercurial > repos > lecorguille > xcms_retcor
comparison xcms_retcor.r @ 50:0bc08f128b42 draft default tip
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 95721ced8347c09e79340e6d67ecb41c5cc64163
| author | workflow4metabolomics |
|---|---|
| date | Mon, 03 Feb 2025 14:41:19 +0000 |
| parents | 177b5847a211 |
| children |
comparison
equal
deleted
inserted
replaced
| 49:177b5847a211 | 50:0bc08f128b42 |
|---|---|
| 7 | 7 |
| 8 | 8 |
| 9 # ----- PACKAGE ----- | 9 # ----- PACKAGE ----- |
| 10 cat("\tSESSION INFO\n") | 10 cat("\tSESSION INFO\n") |
| 11 | 11 |
| 12 #Import the different functions | 12 # Import the different functions |
| 13 source_local <- function(fname) { | 13 source_local <- function(fname) { |
| 14 argv <- commandArgs(trailingOnly = FALSE) | 14 argv <- commandArgs(trailingOnly = FALSE) |
| 15 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) | 15 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) |
| 16 source(paste(base_dir, fname, sep = "/")) | 16 source(paste(base_dir, fname, sep = "/")) |
| 17 } | 17 } |
| 18 source_local("lib.r") | 18 source_local("lib.r") |
| 19 | 19 |
| 20 pkgs <- c("xcms", "batch", "RColorBrewer") | 20 pkgs <- c("xcms", "batch", "RColorBrewer") |
| 21 loadAndDisplayPackages(pkgs) | 21 loadAndDisplayPackages(pkgs) |
| 22 cat("\n\n") | 22 cat("\n\n") |
| 23 | 23 |
| 24 | 24 |
| 25 # ----- ARGUMENTS ----- | 25 # ----- ARGUMENTS ----- |
| 26 cat("\tARGUMENTS INFO\n") | 26 cat("\tARGUMENTS INFO\n") |
| 27 args <- parseCommandArgs(evaluate = FALSE) #interpretation of arguments given in command line as an R list of objects | 27 args <- parseCommandArgs(evaluate = FALSE) # interpretation of arguments given in command line as an R list of objects |
| 28 write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t") | 28 write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t") |
| 29 | 29 |
| 30 cat("\n\n") | 30 cat("\n\n") |
| 31 | 31 |
| 32 # ----- PROCESSING INFILE ----- | 32 # ----- PROCESSING INFILE ----- |
| 33 cat("\tARGUMENTS PROCESSING INFO\n") | 33 cat("\tARGUMENTS PROCESSING INFO\n") |
| 34 | 34 |
| 35 #saving the specific parameters | 35 # saving the specific parameters |
| 36 method <- args$method | 36 method <- args$method |
| 37 | 37 |
| 38 cat("\n\n") | 38 cat("\n\n") |
| 39 | 39 |
| 40 | 40 |
| 41 # ----- ARGUMENTS PROCESSING ----- | 41 # ----- ARGUMENTS PROCESSING ----- |
| 42 cat("\tINFILE PROCESSING INFO\n") | 42 cat("\tINFILE PROCESSING INFO\n") |
| 43 | 43 |
| 44 #image is an .RData file necessary to use xset variable given by previous tools | 44 # image is an .RData file necessary to use xset variable given by previous tools |
| 45 load(args$image) | 45 load(args$image) |
| 46 args$image <- NULL | 46 args$image <- NULL |
| 47 if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*") | 47 if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*") |
| 48 | 48 |
| 49 # Handle infiles | 49 # Handle infiles |
| 68 | 68 |
| 69 adjustRtimeParam <- do.call(paste0(method, "Param"), args) | 69 adjustRtimeParam <- do.call(paste0(method, "Param"), args) |
| 70 print(adjustRtimeParam) | 70 print(adjustRtimeParam) |
| 71 | 71 |
| 72 if (hasAdjustedRtime(xdata)) { | 72 if (hasAdjustedRtime(xdata)) { |
| 73 cat("WARNING: a retention time ajustment had already been applied to your data.\nThe function applyAdjustedRtime was processed to cumulate the ajustment") | 73 cat("WARNING: a retention time ajustment had already been applied to your data.\nThe function applyAdjustedRtime was processed to cumulate the ajustment") |
| 74 cat("Replace raw retention times with adjusted retention times.\n") | 74 cat("Replace raw retention times with adjusted retention times.\n") |
| 75 xdata <- applyAdjustedRtime(xdata) | 75 xdata <- applyAdjustedRtime(xdata) |
| 76 } | 76 } |
| 77 xdata <- adjustRtime(xdata, param = adjustRtimeParam) | 77 xdata <- adjustRtime(xdata, param = adjustRtimeParam) |
| 78 | 78 |
| 79 cat("\n\n") | 79 cat("\n\n") |
| 80 | 80 |
| 95 # Get the legacy xcmsSet object | 95 # Get the legacy xcmsSet object |
| 96 xset <- getxcmsSetObject(xdata) | 96 xset <- getxcmsSetObject(xdata) |
| 97 print(xset) | 97 print(xset) |
| 98 cat("\n\n") | 98 cat("\n\n") |
| 99 | 99 |
| 100 #saving R data in .Rdata file to save the variables used in the present tool | 100 # saving R data in .Rdata file to save the variables used in the present tool |
| 101 objects2save <- c("xdata", "zipfile", "singlefile", "md5sumList", "sampleNamesList") | 101 objects2save <- c("xdata", "zipfile", "singlefile", "md5sumList", "sampleNamesList") |
| 102 save(list = objects2save[objects2save %in% ls()], file = "retcor.RData") | 102 save(list = objects2save[objects2save %in% ls()], file = "retcor.RData") |
| 103 | 103 |
| 104 cat("\n\n") | 104 cat("\n\n") |
| 105 | 105 |
