annotate mixomics_plotvar_script.R @ 5:1ee8d2c20c0a draft

planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 25773bd7a90072f9782df823969b282e4fe29252
author ppericard
date Tue, 10 Mar 2020 06:27:02 -0400
parents 6595c17673cb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
1 #!/usr/bin/env Rscript
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
2
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
3 # Setup R error handling to go to stderr
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
4 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
5
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
6 # we need that to not crash galaxy with an UTF8 error on German LC settings.
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
7 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
8
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
9 ## Main Function ##
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
10
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
11 suppressPackageStartupMessages(require(argparse))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
12
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
13 parser <- ArgumentParser(description='Run the mixOmics plotVar function')
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
14
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
15 parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
16 parser$add_argument('--legend', dest='legend', action="store_true", help="Display the legend")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
17 parser$add_argument('--cutoff', dest='cutoff', type='double', required=TRUE, help="Cutoff (0..1)")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
18 parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
19
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
20 args <- parser$parse_args()
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
21
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
22 ##
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
23 print("Input RData:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
24 print(args$input_rdata)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
25 print("Plot legend:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
26 print(args$legend)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
27 print("Cutoff:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
28 print(args$cutoff)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
29 print("Output PDF file:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
30 print(args$output_pdf)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
31
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
32 # loading libraries
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
33 suppressPackageStartupMessages(require(mixOmics))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
34
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
35 load(args$input_rdata)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
36
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
37 pdf(args$output_pdf)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
38
1
6595c17673cb planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7ed137ea956b8074c34d43a5e1d46b39ddef1482-dirty
ppericard
parents: 0
diff changeset
39 # plotVar(mixomics_result,
6595c17673cb planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7ed137ea956b8074c34d43a5e1d46b39ddef1482-dirty
ppericard
parents: 0
diff changeset
40 # legend = args$legend,
6595c17673cb planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7ed137ea956b8074c34d43a5e1d46b39ddef1482-dirty
ppericard
parents: 0
diff changeset
41 # cutoff = args$cutoff)
0
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
42
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
43 for(k in 1:(length(mixomics_result$names[[3]])-1))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
44 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
45 name_block = mixomics_result$names[[3]][k]
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
46
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
47 plotVar(mixomics_result,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
48 blocks = k,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
49 legend = args$legend,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
50 cutoff = args$cutoff)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
51 }
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
52
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
53 dev.off()