comparison mixomics_plotvar_script.R @ 0:d0b77b926863 draft

"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
author ppericard
date Tue, 23 Jun 2020 19:57:35 -0400
parents
children e93350dc99f1
comparison
equal deleted inserted replaced
-1:000000000000 0:d0b77b926863
1 #!/usr/bin/env Rscript
2
3 # Setup R error handling to go to stderr
4 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
5
6 # we need that to not crash galaxy with an UTF8 error on German LC settings.
7 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
8
9 ## Main Function ##
10
11 suppressPackageStartupMessages(require(argparse))
12
13 parser <- ArgumentParser(description='Run the mixOmics plotVar function')
14
15 parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
16 parser$add_argument('--legend', dest='legend', action="store_true", help="Display the legend")
17 parser$add_argument('--cutoff', dest='cutoff', type='double', required=TRUE, help="Cutoff (0..1)")
18 parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file")
19
20 args <- parser$parse_args()
21
22 ##
23 print("Input RData:")
24 print(args$input_rdata)
25 print("Plot legend:")
26 print(args$legend)
27 print("Cutoff:")
28 print(args$cutoff)
29 print("Output PDF file:")
30 print(args$output_pdf)
31
32 # loading libraries
33 suppressPackageStartupMessages(require(mixOmics))
34
35 load(args$input_rdata)
36
37 pdf(args$output_pdf)
38
39 # plotVar(mixomics_result,
40 # legend = args$legend,
41 # cutoff = args$cutoff)
42
43 for(k in 1:(length(mixomics_result$names[[3]])-1))
44 {
45 name_block = mixomics_result$names[[3]][k]
46
47 # We're still continuing even if a graph is empty
48 try(plotVar(mixomics_result,
49 blocks = k,
50 legend = args$legend,
51 cutoff = args$cutoff),
52 silent = FALSE)
53
54 }
55
56 dev.off()