annotate mixomics_plotindiv.R @ 5:88c1fd2ac110 draft default tip

"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 21d09ff286a496ff475f32626d88dd42423ae663"
author ppericard
date Tue, 07 Sep 2021 10:40:08 +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 ## Get parameters ##
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
10 suppressPackageStartupMessages(require(argparse))
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
11
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
12 parser <- ArgumentParser(description='Run the mixOmics plotIndiv function')
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
13
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
14 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
15 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
16 parser$add_argument('--ellipse', dest='ellipse', action="store_true", help="Plot ellipse plots")
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
17 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
18
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
19 args <- parser$parse_args()
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
20
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
21 ## Print parameters
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
22 print("Input RData:")
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
23 print(args$input_rdata)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
24 print("Plot legend:")
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
25 print(args$legend)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
26 print("Plot ellipse plots:")
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
27 print(args$ellipse)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
28 print("Output PDF file:")
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
29 print(args$output_pdf)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
30
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
31 # loading libraries
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
32 suppressPackageStartupMessages(require(mixOmics))
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
33
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
34 load(args$input_rdata)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
35
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
36 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
37 mar = c(5, 5, 2, 8)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
38 par(mar = mar)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
39
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
40 # plotIndiv(mixomics_result,
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
41 # legend = args$legend,
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
42 # ellipse = args$ellipse)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
43
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
44 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
45 {
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
46 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
47
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
48 try(plotIndiv(mixomics_result,
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
49 blocks = k,
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
50 legend = args$legend,
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
51 ellipse = args$ellipse),
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
52 silent = FALSE)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
53 }
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
54
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
55 dev.off()