Mercurial > repos > ppericard > viscorvar
annotate computeMatSimilarity_wrapper.R @ 1:e93350dc99f1 draft
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 1eda261d4fe137d6e8806b0c6af7eaf12d11ac95"
author | ppericard |
---|---|
date | Thu, 15 Oct 2020 12:22:25 +0000 |
parents | d0b77b926863 |
children |
rev | line source |
---|---|
0
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
2 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
3 # Setup R error handling to go to stderr |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
4 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
5 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
6 # we need that to not crash galaxy with an UTF8 error on German LC settings. |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
7 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
8 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
9 ## Get parameters ## |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
10 suppressPackageStartupMessages(require(argparse)) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
11 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
12 parser <- ArgumentParser(description='Run the computeMatSimilarity function') |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
13 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
14 parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file") |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
15 parser$add_argument('--output_rdata', dest='output_rdata', required=TRUE, help="Output RData file") |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
16 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
17 args <- parser$parse_args() |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
18 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
19 ## Print parameters |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
20 print("Input RData:") |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
21 print(args$input_rdata) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
22 print("Output RData:") |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
23 print(args$output_rdata) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
24 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
25 ## Loading libraries |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
26 # suppressPackageStartupMessages(require(mixOmics)) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
27 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
28 # R script call |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
29 source_local <- function(fname) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
30 { |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
31 argv <- commandArgs(trailingOnly = FALSE) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
32 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
33 source(paste(base_dir, fname, sep="/")) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
34 } |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
35 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
36 ## Loading local functions |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
37 # source_local("mixomics-blocksplsda-integration/integration_block_splsda_func.R") |
1
e93350dc99f1
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 1eda261d4fe137d6e8806b0c6af7eaf12d11ac95"
ppericard
parents:
0
diff
changeset
|
38 install.packages("https://gitlab.com/bilille/mixomics-blocksplsda-integration/-/raw/master/visCorVar_0.5.tar.gz", repos=NULL) |
0
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
39 suppressPackageStartupMessages(require(visCorVar)) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
40 print("visCorVar has been loaded") |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
41 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
42 # Loading input Rdata file |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
43 # loads res_matCorAddVar object |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
44 load(args$input_rdata) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
45 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
46 # Run main function |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
47 res_compute_mat_similarity = computeMatSimilarity(res_matCorAddVar = res_matCorAddVar) |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
48 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
49 liste_mat_similarity_group = res_compute_mat_similarity$liste_mat_similarity_group |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
50 res_matCorAddVar = res_compute_mat_similarity$res_matCorAddVar |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
51 |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
52 save(res_compute_mat_similarity, |
d0b77b926863
"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 85dac6b13a9adce48b47b2b8cb28d2319ae9c1ca-dirty"
ppericard
parents:
diff
changeset
|
53 file = args$output_rdata) |