diff xcms_export_samplemetadata.r @ 0:e3c06320f884 draft

planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
author lecorguille
date Tue, 09 Oct 2018 12:50:47 -0400
parents
children 008aceb33627
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xcms_export_samplemetadata.r	Tue Oct 09 12:50:47 2018 -0400
@@ -0,0 +1,27 @@
+#!/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(sampleNamesOrigin)
+
+# Create a sampleMetada file
+write.table(sampleMetadata,file="sampleMetadata.tsv", sep="\t", row.names=FALSE, quote=FALSE)