view xcms_export_samplemetadata.r @ 1:008aceb33627 draft

planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86-dirty
author lecorguille
date Tue, 09 Oct 2018 12:57:14 -0400
parents e3c06320f884
children 942ffa3c38b8
line wrap: on
line source

#!/usr/bin/env Rscript

#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")
source_local("lib-xcms3.x.x.r")

pkgs <- c("xcms","batch")
loadAndDisplayPackages(pkgs)
cat("\n\n");

args <- parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects


sampleMetadata <- NULL
for(image in args$images) {
    load(image)
    if (is.null(sampleMetadata))
        sampleMetadata <- xdata@phenoData@data
    else
        sampleMetadata <- rbind(sampleMetadata,xdata@phenoData@data)
}
colnames(sampleMetadata) <- c("sample_name","class")
sampleMetadata$sample_name <- make.names(sampleMetadata$sample_name)

# Create a sampleMetada file
write.table(sampleMetadata,file="sampleMetadata.tsv", sep="\t", row.names=FALSE, quote=FALSE)