annotate mixomics_blocksplsda_script.R @ 0:bea08702ed51 draft

planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
author ppericard
date Fri, 17 May 2019 05:00:22 -0400
parents
children 6595c17673cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
1 #!/usr/bin/env Rscript
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
2
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
3 # Setup R error handling to go to stderr
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
4 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
5
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
6 # we need that to not crash galaxy with an UTF8 error on German LC settings.
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
7 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
8
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
9 ## Get parameters ##
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
10 suppressPackageStartupMessages(require(argparse))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
11
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
12 parser <- ArgumentParser(description='Run the mixOmics block.splsda function')
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
13
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
14 parser$add_argument('--block', dest='blocks_list', nargs=4, action="append", required=TRUE, help="Block name + nb variables to select + data matrix file + variables metadata file")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
15 parser$add_argument('--sample_metadata_in', dest='sample_metadata_in', required=TRUE, help="Samples metadata file")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
16 parser$add_argument('--sample_description_col', dest='sample_description_col', type='integer', required=TRUE, help="Sample description column number")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
17 parser$add_argument('--ncomp', dest='ncomp', type='integer', required=TRUE, help="Number of components to include in the model")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
18 parser$add_argument('--correlation', dest='correlation', action="store_true", help="Add correlation between all blocks")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
19 parser$add_argument('--scheme', dest='scheme', required=TRUE, help="Scheme")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
20 parser$add_argument('--mode', dest='mode', required=TRUE, help="Mode")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
21 parser$add_argument('--maxiter', dest='maxiter', type='integer', required=TRUE, help="Maximum number of iterations")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
22 parser$add_argument('--scale', dest='scale', action="store_true", help="Each block is standardized to zero means and unit variances")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
23 parser$add_argument('--init', dest='init', required=TRUE, help="Init (svd or svd.single)")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
24 parser$add_argument('--tol', dest='tol', type='double', required=TRUE, help="Convergence stopping value")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
25 parser$add_argument('--nearzerovar', dest='nearzerovar', action="store_true", help="Should be set in particular for data with many zero values")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
26 parser$add_argument('--rdata_out', dest='rdata_out', required=TRUE, help="Output Rdata file")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
27 parser$add_argument('--sample_metadata_out', dest='sample_metadata_out', required=TRUE, help="Output sample metadata file")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
28 parser$add_argument('--variable_metadata_outdir', dest='variable_metadata_outdir', required=TRUE, help="Output variable metadata directory")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
29
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
30 args <- parser$parse_args()
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
31
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
32 ## Print parameters
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
33 print("Blocks:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
34 print(args$blocks_list)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
35 print("Sample metadata file:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
36 print(args$sample_metadata_in)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
37 print("Sample description column number:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
38 print(args$sample_description_col)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
39 print("Number of components:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
40 print(args$ncomp)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
41 print("Compute correlation between all blocks:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
42 print(args$correlation)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
43 print("Scheme:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
44 print(args$scheme)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
45 print("Mode:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
46 print(args$mode)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
47 print("Max nb of iterations:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
48 print(args$maxiter)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
49 print("Scale:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
50 print(args$scale)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
51 print("Tol:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
52 print(args$tol)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
53 print("near.zero.var:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
54 print(args$nearzerovar)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
55 print("Output Rdata file:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
56 print(args$rdata_out)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
57 print("Output sample metadata file:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
58 print(args$sample_metadata_out)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
59 print("Output variable metadata directory:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
60 print(args$variable_metadata_outdir)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
61
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
62 ## Loading libraries
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
63 suppressPackageStartupMessages(require(mixOmics))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
64
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
65 ## Read sample metadata file and set description factor matrix
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
66 sample_metadata <- read.table(args$sample_metadata_in, sep='\t', header=TRUE, row.names=1)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
67 sample_metadata_names <- row.names(sample_metadata)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
68 # print(sample_metadata_names)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
69
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
70 # print("Sample metadata matrix:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
71 # print(head(sample_metadata))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
72
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
73 description_column <- ncol(sample_metadata)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
74 if(args$sample_description_col > 0)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
75 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
76 description_column <- args$sample_description_col
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
77 }
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
78
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
79 Y <- factor(sample_metadata[[description_column]])
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
80
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
81 print("Y factor matrix:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
82 print(Y)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
83
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
84 ## Read and prepare block datasets
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
85 list_X <- c()
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
86 keepX <- c()
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
87
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
88 for(i in 1:nrow(args$blocks_list))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
89 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
90 # Read block input parameters
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
91 block_name <- args$blocks_list[i,1]
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
92 block_keep <- strtoi(args$blocks_list[i,2])
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
93 block_data_matrix_filename <- args$blocks_list[i,3]
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
94 # block_meta_var <- args$blocks_list[i,4]
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
95
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
96 print(sprintf("Processing block %s", block_name))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
97
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
98 # Store block data matrices
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
99 block_data_matrix <- t(read.table(block_data_matrix_filename, sep='\t', header=TRUE, row.names=1)) # transpose the matrix so that the samples become rows and the variables become columns
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
100 block_data_matrix_names <- row.names(block_data_matrix)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
101 # print(block_data_matrix_names)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
102
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
103 if(!identical(sample_metadata_names, block_data_matrix_names))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
104 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
105 stop("Sample names must be the same and in the same order in the sample metadata matrix and the block data matrix")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
106 }
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
107
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
108 list_X[[block_name]] <- block_data_matrix
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
109
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
110 # Set the nb of variables to keep
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
111 nb_variables = ncol(list_X[[block_name]])
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
112 if(block_keep > 0)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
113 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
114 keepX[[block_name]] <- rep(block_keep, args$ncomp)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
115 }
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
116 else
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
117 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
118 keepX[[block_name]] <- rep(nb_variables, args$ncomp)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
119 }
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
120 print(sprintf("Block %s contains %d variables and %d will be selected", block_name, nb_variables, block_keep))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
121 }
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
122
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
123 # print(list_X)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
124
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
125 ## Generate design matrix
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
126 block_nb <- nrow(args$blocks_list)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
127
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
128 design <- matrix(0, nrow = block_nb, ncol = block_nb)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
129
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
130 if(args$correlation)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
131 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
132 design <- matrix(1, nrow = block_nb, ncol = block_nb)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
133 diag(design) <- 0
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
134 }
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
135
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
136 # print("Design matrix:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
137 # print(design)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
138
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
139 ###################
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
140 ## Main function ##
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
141 ###################
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
142
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
143 mixomics_result <- block.splsda(X = list_X,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
144 Y = Y,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
145 ncomp = args$ncomp,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
146 keepX = keepX,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
147 design = design,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
148 scheme = args$scheme,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
149 mode = args$mode,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
150 scale = args$scale,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
151 init = args$init,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
152 tol = args$tol,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
153 max.iter = args$maxiter,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
154 near.zero.var = args$nearzerovar,
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
155 all.outputs = TRUE)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
156
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
157 print("Block.splsda object:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
158 print(mixomics_result)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
159
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
160 ## Save output Rdata file
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
161 save(mixomics_result, file=args$rdata_out)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
162
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
163 ## Save output sample metadata file
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
164 # print("Block.splsda variates:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
165 # print(mixomics_result$variates)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
166
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
167 for(bname in names(mixomics_result$variates))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
168 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
169 # print(bname)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
170 # print(mixomics_result$variates[[bname]])
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
171
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
172 # Format the column names to add the block name and replace spaces
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
173 colnames(mixomics_result$variates[[bname]]) <- paste("block.splsda", bname, gsub(" ", "_", colnames(mixomics_result$variates[[bname]])), sep = "_")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
174 # print(mixomics_result$variates[[bname]])
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
175
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
176 # Append the new columns to the sample metadata matrix
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
177 sample_metadata <- cbind2(sample_metadata, mixomics_result$variates[[bname]])
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
178 }
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
179
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
180 # print(sample_metadata)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
181
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
182 write.table(sample_metadata, file = args$sample_metadata_out, quote = TRUE, sep = "\t", row.names = TRUE, col.names = NA)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
183
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
184 ## Save output variable metadata files in output directory
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
185 # print("Block.splsda loadings:")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
186 # print(mixomics_result$loadings)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
187
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
188 for(i in 1:nrow(args$blocks_list))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
189 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
190 # Read again block input parameters
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
191 block_name <- args$blocks_list[i,1]
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
192 # block_keep <- strtoi(args$blocks_list[i,2])
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
193 # block_data_matrix_filename <- args$blocks_list[i,3]
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
194 block_meta_var <- args$blocks_list[i,4]
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
195
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
196 meta_variable <- mixomics_result$loadings[[block_name]]
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
197 # print(head(meta_variable))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
198
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
199 # Read input block variable metadata files if provided (optional)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
200 if(block_meta_var != "None")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
201 {
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
202 input_meta_variable <- read.table(block_meta_var, sep='\t', header=TRUE, row.names=1)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
203 # print(head(input_meta_variable))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
204
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
205 # Append the new columns to the variable metadata matrix
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
206 meta_variable <- cbind2(input_meta_variable, meta_variable)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
207 }
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
208
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
209 # print(head(meta_variable))
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
210
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
211 block_meta_var_output_filename <- paste("mixomics_blocksplsda_block_", block_name, "_variable_metadata.tsv", sep="")
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
212 write.table(meta_variable, file = paste(args$variable_metadata_outdir,block_meta_var_output_filename, sep='/'), quote = TRUE, sep = "\t", row.names = TRUE, col.names = NA)
bea08702ed51 planemo upload for repository https://github.com/bilille/galaxy-mixomics-blocksplsda commit 7595141b2b760d3c9781f350abd2aa76a0644b1a
ppericard
parents:
diff changeset
213 }