diff xcms_differential_analysis.r @ 49:f772a5caa86a

Added more options and better documentation. Added MsClust support for parsing XCMS alignment results. Improved output reports for XCMS wrappers. New tools.
author pieter.lukasse@wur.nl
date Wed, 10 Dec 2014 22:03:27 +0100
parents e67149fbff20
children 10f3cb998c4e
line wrap: on
line diff
--- a/xcms_differential_analysis.r	Wed Nov 19 15:11:45 2014 +0100
+++ b/xcms_differential_analysis.r	Wed Dec 10 22:03:27 2014 +0100
@@ -14,19 +14,23 @@
 #cat(paste("args.topcount <- ", args[4], "\n", sep=""))
 
 args.outTable <- args[5]
-args.outLogFile <- args[6]
-#cat(paste("args.outLogFile <- \"", args[6], "\"\n", sep=""))
 
 ## report files
-args.htmlReportFile <- args[7]
-args.htmlReportFile.files_path <- args[8]
-#cat(paste("args.htmlReportFile <- \"", args[7], "\"\n", sep=""))
-#cat(paste("args.htmlReportFile.files_path <- \"", args[8], "\"\n", sep=""))
+args.htmlReportFile <- args[6]
+args.htmlReportFile.files_path <- args[7]
+#cat(paste("args.htmlReportFile <- \"", args[6], "\"\n", sep=""))
+#cat(paste("args.htmlReportFile.files_path <- \"", args[7], "\"\n", sep=""))
+
 
-# Send all STDERR to STDOUT using sink() see http://mazamascience.com/WorkingWithData/?p=888
-msg <- file(args.outLogFile, open="wt")
-sink(msg, type="message") 
-sink(msg, type="output")
+if (length(args) == 8)
+{
+	args.outLogFile <- args[8]
+	# suppress messages:
+	# Send all STDERR to STDOUT using sink() see http://mazamascience.com/WorkingWithData/?p=888
+	msg <- file(args.outLogFile, open="wt")
+	sink(msg, type="message") 
+	sink(msg, type="output")
+}
 
 tryCatch(
         {
@@ -34,12 +38,18 @@
         	library(xcms)
 	        #library("R2HTML")
 	
-			## load the constructed DB :
-			xcmsSet <- readRDS(args.xsetData)
+			# load the xset data :
+			xsetData <- readRDS(args.xsetData)
+			# if here to support both scenarios:
+			if ("xcmsSet" %in% slotNames(xsetData) )
+			{
+				xsetData <- xsetData@xcmsSet
+			}
+			
 			
 			# info: levels(xcmsSet@phenoData$class) also gives access to the class names
-			dir.create(file.path(args.htmlReportFile.files_path), showWarnings = FALSE)
-			reporttab <- diffreport(xcmsSet, args.class1, args.class2, paste(args.htmlReportFile.files_path,"/fig", sep=""), args.topcount, metlin = 0.15, h=480, w=640)
+			dir.create(file.path(args.htmlReportFile.files_path), showWarnings = FALSE, recursive = TRUE)
+			reporttab <- diffreport(xsetData, args.class1, args.class2, paste(args.htmlReportFile.files_path,"/fig", sep=""), args.topcount, metlin = 0.15, h=480, w=640)
 			
 			# write out tsv table:
 			write.table(reporttab, args.outTable, sep="\t", row.names=FALSE)