annotate mixomics_plotvar.R @ 4:d4e9f7546dfa draft

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