annotate networkVar_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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
1 #!/usr/bin/env Rscript
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
2
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
3 # Setup R error handling to go to stderr
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
4 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
5
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
6 # we need that to not crash galaxy with an UTF8 error on German LC settings.
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
7 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
8
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
9 ## Get parameters ##
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
10 suppressPackageStartupMessages(require(argparse))
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
11
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
12 parser <- ArgumentParser(description='Run the networkVar function')
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
13
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
14 parser$add_argument('--mat_similarity_rdata', dest='mat_similarity_rdata', required=TRUE, help="matSimilarity RData file")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
15 parser$add_argument('--block_splsda_rdata', dest='block_splsda_rdata', required=TRUE, help="block.splsda RData file")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
16 parser$add_argument('--var_list_file', dest='var_list_file', required=TRUE, help="Variables list file")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
17 parser$add_argument('--interest_var_file', dest='interest_var_file', required=FALSE, help="Variables of interest file")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
18 parser$add_argument('--responses_var', dest='responses_var', required=TRUE, help="Responses variables")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
19 parser$add_argument('--output_graph', dest='output_graph', required=TRUE, help="Output graphml")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
20
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
21 args <- parser$parse_args()
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
22
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
23 ## Print parameters
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
24 print("matSimilarity RData file:")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
25 print(args$mat_similarity_rdata)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
26 print("block.splsda RData file:")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
27 print(args$block_splsda_rdata)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
28 print("Variables list file:")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
29 print(args$var_list_file)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
30 print("Variables of interest:")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
31 print(args$interest_var_file)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
32 print("Response variables:")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
33 print(args$responses_var)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
34 print("Output graphml:")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
35 print(args$output_graph)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
36
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
37 ## Loading libraries
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
38 suppressPackageStartupMessages(require(mixOmics))
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
39 suppressPackageStartupMessages(require(igraph))
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
40
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
41 # R script call
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
42 source_local <- function(fname)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
43 {
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
44 argv <- commandArgs(trailingOnly = FALSE)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
45 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
46 source(paste(base_dir, fname, sep="/"))
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
47 }
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
48 ## Loading local functions
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
49 source_local("Integration_block_splsda_fonc.R")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
50
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
51 load(args$mat_similarity_rdata)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
52 load(args$block_splsda_rdata)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
53
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
54 variables_vector = as.character(read.table(args$var_list_file, header=FALSE)[[1]])
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
55 interest_var_vec = NULL
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
56
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
57 if (args$interest_var_file != 'None') {
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
58 interest_var_vec = as.character(read.table(args$interest_var_file, header=FALSE)[[1]])
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
59 }
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
60
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
61 response_variables = strsplit(args$responses_var, ",")[[1]]
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
62
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
63 print("Variables vector:")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
64 print(variables_vector)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
65 print("interest_var_vec:")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
66 print(interest_var_vec)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
67 print("response_variables:")
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
68 print(response_variables)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
69
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
70 network = networkVar(liste_matSimilarity_group = liste_matSimilarity_group,
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
71 comp = comp,
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
72 res_block_splsda = mixomics_result,
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
73 cutoff_comp = 0.8,
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
74 vec_varBlock = variables_vector,
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
75 vec_varRep = response_variables,
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
76 vec_varBlockInteret = interest_var_vec,
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
77 cutoff = 0)
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
78
0a3c83f2197a planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 24b8259494ac7ab10cbd1f9ee991f455a7507590-dirty
ppericard
parents:
diff changeset
79 write.graph(network$gR, file = args$output_graph, format = "graphml")