annotate viscorvar_computematsimilarity.R @ 2:c8533e9298e5 draft

"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
author ppericard
date Fri, 23 Oct 2020 10:15:56 +0000
parents
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 computeMatSimilarity 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('--output_rdata', dest='output_rdata', required=TRUE, help="Output RData file")
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
16
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
17 args <- parser$parse_args()
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 ## Print parameters
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
20 print("Input RData:")
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
21 print(args$input_rdata)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
22 print("Output RData:")
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
23 print(args$output_rdata)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
24
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
25 ## Loading libraries
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
26 # suppressPackageStartupMessages(require(mixOmics))
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
27
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
28 # R script call
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
29 source_local <- function(fname)
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 argv <- commandArgs(trailingOnly = FALSE)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
32 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
33 source(paste(base_dir, fname, sep="/"))
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
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
36 ## Loading local functions
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
37 suppressPackageStartupMessages(require(visCorVar))
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
38
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
39 # Loading input Rdata file
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
40 # loads res_matCorAddVar object
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
41 load(args$input_rdata)
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
42
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
43 # Run main function
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
44 res_compute_mat_similarity = computeMatSimilarity(res_matCorAddVar = res_matCorAddVar)
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 liste_mat_similarity_group = res_compute_mat_similarity$liste_mat_similarity_group
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
47 res_matCorAddVar = res_compute_mat_similarity$res_matCorAddVar
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 save(res_compute_mat_similarity,
c8533e9298e5 "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty"
ppericard
parents:
diff changeset
50 file = args$output_rdata)