-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatCor_addVar_wrapper.R
93 lines (72 loc) · 3.42 KB
/
matCor_addVar_wrapper.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env Rscript
# Setup R error handling to go to stderr
options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
# we need that to not crash galaxy with an UTF8 error on German LC settings.
loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
## Get parameters ##
suppressPackageStartupMessages(require(argparse))
parser <- ArgumentParser(description='Compute the matCorEtBlockSelect and addVariablesReponses functions')
parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
parser$add_argument('--cutoff_comp', dest='cutoff_comp', type='double', required=TRUE, help="")
parser$add_argument('--mat_block_Y_file', dest='mat_block_Y_file', required=TRUE, help="Matrix block Y filepath")
parser$add_argument('--output_rdata', dest='output_rdata', required=TRUE, help="Output RData file")
parser$add_argument('--output_blocks_comb', dest='output_blocks_comb', required=TRUE, help="Output blocks combinations file")
args <- parser$parse_args()
## Print parameters
print("Input RData:")
print(args$input_rdata)
print("Cutoff comp:")
print(args$cutoff_comp)
print("Mat Block Y file:")
print(args$mat_block_Y_file)
print("Output RData:")
print(args$output_rdata)
print("Output Blocks combinations:")
print(args$output_blocks_comb)
## Loading libraries
suppressPackageStartupMessages(require(mixOmics))
# R script call
source_local <- function(fname)
{
argv <- commandArgs(trailingOnly = FALSE)
base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
source(paste(base_dir, fname, sep="/"))
}
## Loading local functions
source_local("Integration_block_splsda_fonc.R")
load(args$input_rdata)
liste_matCorEtBlockSelect = matCorEtBlockSelect(res_block_splsda = mixomics_result,
cutoff_comp = args$cutoff_comp,
comp = 1:2)
mat_cor_comp1 = liste_matCorEtBlockSelect$mat_cor_comp1
mat_cor_comp2 = liste_matCorEtBlockSelect$mat_cor_comp2
dataframe_cor_comp_var_global = liste_matCorEtBlockSelect$dataframe_cor_comp_var_global
liste_vec_indice_blockSelect = liste_matCorEtBlockSelect$liste_vec_indice_blockSelect
liste_vec_blocks = liste_matCorEtBlockSelect$liste_vec_blocks
print("Mat cor comp1:")
print(mat_cor_comp1)
print("Mat cor comp2:")
print(mat_cor_comp2)
print("dataframe_cor_comp_var_global:")
print(dataframe_cor_comp_var_global)
print("liste_vec_indice_blockSelect:")
print(liste_vec_indice_blockSelect)
print("liste_vec_blocks:")
print(liste_vec_blocks)
lapply(liste_vec_blocks, write, file=args$output_blocks_comb, append=TRUE, ncolumns=100, sep=",")
print("Reading Mat Block Y")
mat_block_Y = read.table(args$mat_block_Y_file, header=TRUE, row.names=1)
print(mat_block_Y)
liste_dataframe_cor_comp_var_global = addVariablesReponses(res_block_splsda = mixomics_result,
dataframe_cor_comp_var_global = dataframe_cor_comp_var_global,
liste_vec_indice_blockSelect = liste_vec_indice_blockSelect,
mat_block_Y = mat_block_Y)
save(mixomics_result,
liste_matCorEtBlockSelect,
mat_cor_comp1,
mat_cor_comp2,
dataframe_cor_comp_var_global,
liste_vec_indice_blockSelect,
liste_vec_blocks,
liste_dataframe_cor_comp_var_global,
file = args$output_rdata)