Mercurial > repos > ppericard > mixomics_blocksplsda
comparison circleCor_wrapper.R @ 3:0a3c83f2197a draft
planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
author | ppericard |
---|---|
date | Fri, 25 Oct 2019 07:10:59 -0400 |
parents | |
children | b0ab97ffc2a1 |
comparison
equal
deleted
inserted
replaced
2:655d1fbcd3e6 | 3:0a3c83f2197a |
---|---|
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 ## Get parameters ## | |
10 suppressPackageStartupMessages(require(argparse)) | |
11 | |
12 parser <- ArgumentParser(description='Run the circleCor function') | |
13 | |
14 parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file") | |
15 parser$add_argument('--blocks_vec', dest='blocks_vec', required=TRUE, help="Blocks vector") | |
16 parser$add_argument('--responses_var', dest='responses_var', required=TRUE, help="Responses variables") | |
17 parser$add_argument('--x_min', dest='x_min', type='double', required=TRUE, help="X min") | |
18 parser$add_argument('--x_max', dest='x_max', type='double', required=TRUE, help="X max") | |
19 parser$add_argument('--y_min', dest='y_min', type='double', required=TRUE, help="Y min") | |
20 parser$add_argument('--y_max', dest='y_max', type='double', required=TRUE, help="Y max") | |
21 parser$add_argument('--output_var', dest='output_var', required=TRUE, help="Output variables file") | |
22 parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file") | |
23 | |
24 args <- parser$parse_args() | |
25 | |
26 ## Print parameters | |
27 print("Input RData:") | |
28 print(args$input_rdata) | |
29 print("Blocks vector:") | |
30 print(args$blocks_vec) | |
31 print("Response variables:") | |
32 print(args$responses_var) | |
33 print("X min:") | |
34 print(args$x_min) | |
35 print("X max:") | |
36 print(args$x_max) | |
37 print("Y min:") | |
38 print(args$y_min) | |
39 print("Y max:") | |
40 print(args$y_max) | |
41 print("Output variables file:") | |
42 print(args$output_var) | |
43 print("Output PDF file:") | |
44 print(args$output_pdf) | |
45 | |
46 ## Loading libraries | |
47 suppressPackageStartupMessages(require(ellipse)) | |
48 suppressPackageStartupMessages(require(grDevices)) | |
49 suppressPackageStartupMessages(require(RColorBrewer)) | |
50 # suppressPackageStartupMessages(require(mixOmics)) | |
51 | |
52 | |
53 # R script call | |
54 source_local <- function(fname) | |
55 { | |
56 argv <- commandArgs(trailingOnly = FALSE) | |
57 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) | |
58 source(paste(base_dir, fname, sep="/")) | |
59 } | |
60 ## Loading local functions | |
61 source_local("Integration_block_splsda_fonc.R") | |
62 | |
63 load(args$input_rdata) | |
64 | |
65 blocks_vector = strsplit(args$blocks_vec, ",")[[1]] | |
66 response_variables = strsplit(args$responses_var, ",")[[1]] | |
67 | |
68 | |
69 print("liste_vec_indice_blockSelect:") | |
70 print(liste_vec_indice_blockSelect) | |
71 print("liste_vec_blocks:") | |
72 print(liste_vec_blocks) | |
73 print("Mat cor comp1:") | |
74 print(mat_cor_comp1) | |
75 print("blocks_vector:") | |
76 print(blocks_vector) | |
77 | |
78 | |
79 | |
80 pdf(args$output_pdf, width=12, height=9) | |
81 | |
82 varSelect = circleCor(liste_dataframe_cor_comp_var_global = liste_dataframe_cor_comp_var_global, | |
83 liste_vec_indice_blockSelect = liste_vec_indice_blockSelect, | |
84 mat_cor_comp1 = mat_cor_comp1, | |
85 mat_cor_comp2 = mat_cor_comp2, | |
86 vec_blocks = blocks_vector, | |
87 nomsVarReponses = response_variables, | |
88 min.X = args$x_min, | |
89 max.X = args$x_max, | |
90 min.Y = args$y_min, | |
91 max.Y = args$y_max, | |
92 cutoff = 0.85, | |
93 rad.in = 0.5, | |
94 cex = 0.7, | |
95 cex_legend = 0.8, | |
96 pos = c(1.2, 0), | |
97 pch = 20, | |
98 inset = c(-0.25, 0)) | |
99 | |
100 dev.off() | |
101 | |
102 write(varSelect, file=args$output_var, ncolumns=1) |