view ipo4retgroup.r @ 10:57f180a8eaae draft default tip

planemo upload for repository https://github.com/rietho/IPO commit d25c744220e416cce158161fa7dc3b0f153a5c11
author workflow4metabolomics
date Mon, 11 Sep 2023 22:36:51 +0000
parents 364756ea5f42
children
line wrap: on
line source

#!/usr/bin/env Rscript
# Authors Gildas Le Corguille and Yann Guitton


# ----- PACKAGE -----
cat("\tSESSION INFO\n")

# Import the different functions
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("lib.r")

pkgs <- c("IPO", "batch")
loadAndDisplayPackages(pkgs)
cat("\n\n")
# ----- ARGUMENTS -----
cat("\tARGUMENTS INFO\n")
args <- parseCommandArgs(evaluate = FALSE) # interpretation of arguments given in command line as an R list of objects
write.table(as.matrix(args), col.names = FALSE, quote = FALSE, sep = "\t")

cat("\n\n")
# ----- PROCESSING INFILE -----
cat("\tARGUMENTS PROCESSING INFO\n")

samplebyclass <- 2
if (!is.null(args$samplebyclass)) {
  samplebyclass <- args$samplebyclass
  args$samplebyclass <- NULL
}

cat("\n\n")

# ----- INFILE PROCESSING -----
cat("\tINFILE PROCESSING INFO\n")
options(bitmapType = "cairo")

# image is an .RData file necessary to use xset variable given by previous tools
load(args$image)
args$image <- NULL

# Because so far CAMERA isn't compatible with the new XCMSnExp object
if (exists("xdata")) {
  xset <- getxcmsSetObject(xdata)
}

if (!exists("xset")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata' which is provided by the tool: MSnbase readMSData")


# Handle infiles
if (!exists("singlefile")) singlefile <- NULL
rawFilePath <- getRawfilePathFromArguments(singlefile, NULL, args)
singlefile <- rawFilePath$singlefile
print(singlefile)
directory <- retrieveRawfileInWD(singlefile, NULL)


cat("\n\n")


# ----- MAIN PROCESSING INFO -----
cat("\tMAIN PROCESSING INFO\n")

ipo4retgroup(xset, directory, "IPO_parameters4xcmsSet.tsv", args, samplebyclass)

cat("\n\n")


cat("\tDONE\n")