diff mixomics_plotindiv.R @ 2:c8533e9298e5 draft

"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
author ppericard
date Fri, 23 Oct 2020 10:15:56 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mixomics_plotindiv.R	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,55 @@
+#!/usr/bin/env Rscript
+
+# Setup R error handling to go to stderr
+options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
+
+# we need that to not crash galaxy with an UTF8 error on German LC settings.
+loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
+
+## Get parameters ##
+suppressPackageStartupMessages(require(argparse))
+
+parser <- ArgumentParser(description='Run the mixOmics plotIndiv function')
+
+parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
+parser$add_argument('--legend', dest='legend', action="store_true", help="Display the legend")
+parser$add_argument('--ellipse', dest='ellipse', action="store_true", help="Plot ellipse plots")
+parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file")
+
+args <- parser$parse_args()
+
+## Print parameters
+print("Input RData:")
+print(args$input_rdata)
+print("Plot legend:")
+print(args$legend)
+print("Plot ellipse plots:")
+print(args$ellipse)
+print("Output PDF file:")
+print(args$output_pdf)
+
+# loading libraries
+suppressPackageStartupMessages(require(mixOmics))
+
+load(args$input_rdata)
+
+pdf(args$output_pdf, width=8, height=7)
+mar = c(5, 5, 2, 8)
+par(mar = mar)
+
+# plotIndiv(mixomics_result,
+#           legend = args$legend,
+#           ellipse = args$ellipse)
+
+for(k in 1:(length(mixomics_result$names[[3]])-1))
+{
+    name_block = mixomics_result$names[[3]][k]
+
+    try(plotIndiv(mixomics_result,
+                  blocks = k,
+                  legend = args$legend,
+                  ellipse = args$ellipse),
+        silent = FALSE)
+}
+
+dev.off()
\ No newline at end of file