changeset 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 e93350dc99f1
children df8428358b7f
files README.md additional_functions_block_splsda.R circleCor.xml circleCor_wrapper.R computeMatSimilarity.xml computeMatSimilarity_wrapper.R macros.xml macros_mixomics.xml macros_viscorvar.xml matCorAddVar.xml matCorAddVar_wrapper.R mixomics_blocksplsda.R mixomics_blocksplsda.xml mixomics_blocksplsda_additional_funct.R mixomics_blocksplsda_script.R mixomics_plotindiv.R mixomics_plotindiv.xml mixomics_plotindiv_script.R mixomics_plotvar.R mixomics_plotvar.xml mixomics_plotvar_script.R networkVar.xml networkVar_wrapper.R viscorvar_circlecor.R viscorvar_circlecor.xml viscorvar_computematsimilarity.R viscorvar_computematsimilarity.xml viscorvar_matcoraddvar.R viscorvar_matcoraddvar.xml viscorvar_networkvar.R viscorvar_networkvar.xml
diffstat 31 files changed, 1557 insertions(+), 1218 deletions(-) [+]
line wrap: on
line diff
--- a/README.md	Thu Oct 15 12:22:25 2020 +0000
+++ b/README.md	Fri Oct 23 10:15:56 2020 +0000
@@ -1,70 +1,33 @@
-# galaxy-mixomics-blocksplsda
-Galaxy wrappers for the block.splsda, plotIndiv and plotVar functions from the mixOmics R package
+# galaxy-viscorvar
+
+Galaxy wrappers for the visCorVar R package and selected functions from the mixOmics R package (block.splsda, plotIndiv and plotVar).
 
-# Install for developers
+## Install from Toolshed
+
+Install `viscorvar` repository from Galaxy ToolShed (owner: `ppericard`)
+
+## Install for developers
 
 Clone repository
 
 ```
-$ git clone --recurse-submodules https://gitlab.com/bilille/galaxy-mixomics-blocksplsda.git
+$ git clone --recurse-submodules https://gitlab.com/bilille/galaxy-viscorvar.git
 ```
 
-Add `galaxy-mixomics-blocksplsda` repository to `$GALAXYDIR/tools` directory.
+Add `galaxy-viscorvar` repository to `$GALAXYDIR/tools` directory.
 
 Edit `$GALAXYDIR/config/tool_conf.xml` and add:
 
 ```
 <section id="development" name="Tools development">
-  <label id="mixomics_blocksplsda" name="mixOmics blocksplsda" />
-    <tool file="galaxy-mixomics-blocksplsda/mixomics_blocksplsda.xml" />
-    <tool file="galaxy-mixomics-blocksplsda/mixomics_plotindiv.xml" />
-    <tool file="galaxy-mixomics-blocksplsda/mixomics_plotvar.xml" />
-    <tool file="galaxy-mixomics-blocksplsda/matCor_addVar.xml" />
-    <tool file="galaxy-mixomics-blocksplsda/computeMatSimilarity.xml" />
-    <tool file="galaxy-mixomics-blocksplsda/circleCor.xml" />
-    <tool file="galaxy-mixomics-blocksplsda/networkVar.xml" />
+  <label id="viscorvar" name="visCorVar" />
+    <tool file="galaxy-viscorvar/mixomics_blocksplsda.xml" />
+    <tool file="galaxy-viscorvar/mixomics_plotindiv.xml" />
+    <tool file="galaxy-viscorvar/mixomics_plotvar.xml" />
+    <tool file="galaxy-viscorvar/viscorvar_matcoraddvar.xml" />
+    <tool file="galaxy-viscorvar/viscorvar_circlecor.xml" />
+    <tool file="galaxy-viscorvar/viscorvar_computematsimilarity.xml" />
+    <tool file="galaxy-viscorvar/viscorvar_networkvar.xml" />
 </section>
 ```
 
-# Preparing Galaxy conda manual environment for visCorVar
-
-Activate Galaxy self-installed conda (for your shell; bash here) and reload terminal
-
-```
-$ . $GALAXYDIR/database/dependencies/_conda/bin/conda init bash
-```
-
-Create and activate conda environment for visCorVar package
-
-```
-$ conda create --name __viscorvar@0.1 && conda activate __viscorvar@0.1
-```
-
-Install dependencies
-
-```
-$ conda install bioconductor-mixomics r-rdpack r-igraph
-```
-
-Manually install visCorVar package from repository
-
-```
-$ R
-
-> install.packages("https://gitlab.com/bilille/mixomics-blocksplsda-integration/-/raw/master/visCorVar_0.1.tar.gz", repos=NULL)
-> library(visCorVar)
-```
-
-
-
-
-
-
-
-
-
-
-
-
-
-
--- a/additional_functions_block_splsda.R	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-#' @title Determination of selected variables for all components
-#' @description The function unionSelectBlockVariables determines, for each block, the selected block variables
-#' for all components.
-#' @param res_block_splsda type : sgccda. This parameter is the output of block.splsda function 
-#' mixOmics.
-#' @details For each block, the function unionSelectBlockVariables returns 1 if the block variable is selected for
-#' at least one component. Otherwise, this function returns 0.
-#' @return type : list of matrix. For each block, if the block variable is selected, the value 1 is associated with 
-#' this block variable. Otherwise the value 0 is associated with this block variable. 
-#' @examples 
-#' data(res_data_integration)
-#' list_union_selected_block_variables = unionSelectBlockVariables(res_data_integration)
-#' @export
-unionSelectBlockVariables <-function(res_block_splsda)
-{
-  ncomp = res_block_splsda$ncomp[1]
-  
-  names_blocks = names(res_block_splsda$loadings)
-  index_Y = which(names_blocks == "Y")
-  names_blocks = names_blocks[ - index_Y]
-  list_select_block_variables = list()
-  
-  for(i in 1:length(names_blocks))
-  {
-    mat_loadings_i = res_block_splsda$loadings[[i]]
-    index_i = c()
-    
-    for(j in 1:ncomp)
-    {
-      loadings_i_j = mat_loadings_i[, j]
-      index_i_j = which(loadings_i_j != 0)
-      
-      index_i = c(index_i, index_i_j)
-      
-    } # End for(j 1:ncomp).
-    
-    index_i = unique(index_i)
-    
-    mat_select_block_variables = matrix(0,
-                                        nrow = dim(mat_loadings_i)[1],
-                                        ncol = 1)
-    mat_select_block_variables[index_i, 1] = rep(1, length(index_i))
-    rownames(mat_select_block_variables) = rownames(mat_loadings_i)
-    
-    list_select_block_variables[[i]] = mat_select_block_variables
-    
-  } # End for(i in 1:length(names_blocks)).
-  
-  names(list_select_block_variables) = names_blocks
-  
-  return(list_select_block_variables)
-}
--- a/circleCor.xml	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-<tool id="circleCor" name="circleCor" version="0.6+galaxy0" profile="16.04" workflow_compatible="true">
-
-    <description>plots a correlation circle for the datasets whose correlation circles can be superimposed. This correlation circle contains the selected variables of these datasets which are included in a rectangle and the response variables.</description>
-
-    <requirements>
-        <requirement type="package" version="0.6">r-viscorvar</requirement>
-        <requirement type="package" version="2.0">r-argparse</requirement>
-    </requirements>
-
-    <stdio>
-        <!-- <exit_code range="1:" level="fatal" /> -->
-    </stdio>
-
-    <command detect_errors="aggressive">
-        <![CDATA[
-        Rscript
-        ${__tool_directory__}/circleCor_wrapper.R
-        --input_rdata ${input_rdata}
-        --blocks_vec ${select_blocks.value}
-        --responses_var ${select_responses_var}
-        --x_min ${x_min}
-        --x_max ${x_max}
-        --y_min ${y_min}
-        --y_max ${y_max}
-        --output_var ${output_var}
-        --output_pdf ${output_pdf}
-        ]]>
-    </command>
-
-    <inputs>
-        <param name="input_rdata" type="data" format="rdata"
-               label="Input RData file"
-               help="output RData from matCorAddVar"/>
-        <param name="blocks_vec_list" type="data" format="tabular"
-               label="List of blocks vector."
-               help="output *_blocks_comb.tsv file from matCorAddVar"/>
-        <param name="select_blocks" type="select"
-               label="Blocks"
-               help="list of the blocks that are to be superimposed">
-            <options from_dataset="blocks_vec_list">
-                <column name="value" index="0"/>
-                <filter type="unique_value" column="0"/>
-                <filter type="sort_by" name="sorted_value" column="0"/>
-            </options>
-        </param>
-        <param name="responses_var_list" type="data" format="tabular"
-               label="List of response variables"
-               help="output *_response_var.tsv file from matCorAddVar"/>
-        <param name="select_responses_var" type="select" display="checkboxes"
-               multiple="true" label="Response variables"
-               help="select the response variables which will be plotted in the correlation circle">
-        <!-- <param name="select_responses_var" type="select" multiple="true" label="Response variables"> -->
-            <options from_dataset="responses_var_list">
-                <column name="value" index="0"/>
-                <filter type="unique_value" column="0"/>
-                <filter type="sort_by" name="sorted_value" column="0"/>
-            </options>
-        </param>
-        <param name="x_min" type="float" value="-1" min="-1" max="1"
-               label="X min" help="" />
-        <param name="x_max" type="float" value="1" min="-1" max="1"
-               label="X max" help="" />
-        <param name="y_min" type="float" value="-1" min="-1" max="1"
-               label="Y min" help="" />
-        <param name="y_max" type="float" value="1" min="-1" max="1"
-               label="Y max" help="" />
-    </inputs>
-
-    <outputs>
-        <data name="output_var" format="tabular" label="${tool.name}_selected_var.tsv" />
-        <data name="output_pdf" format="pdf" label="${tool.name}.pdf" />
-    </outputs>
-
-    <tests>
-    </tests>
-
-    <help>
-    </help>
-
-</tool>
\ No newline at end of file
--- a/circleCor_wrapper.R	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-#!/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='Run the circleCor function')
-
-parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
-parser$add_argument('--blocks_vec', dest='blocks_vec', required=TRUE, help="Blocks vector")
-parser$add_argument('--responses_var', dest='responses_var', required=TRUE, help="Responses variables")
-parser$add_argument('--x_min', dest='x_min', type='double', required=TRUE, help="X min")
-parser$add_argument('--x_max', dest='x_max', type='double', required=TRUE, help="X max")
-parser$add_argument('--y_min', dest='y_min', type='double', required=TRUE, help="Y min")
-parser$add_argument('--y_max', dest='y_max', type='double', required=TRUE, help="Y max")
-parser$add_argument('--output_var', dest='output_var', required=TRUE, help="Output variables file")
-parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file")
-
-args <- parser$parse_args()
-
-## Print parameters
-print("Input RData:")
-print(args$input_rdata)
-print("Blocks vector:")
-print(args$blocks_vec)
-print("Response variables:")
-print(args$responses_var)
-print("X min:")
-print(args$x_min)
-print("X max:")
-print(args$x_max)
-print("Y min:")
-print(args$y_min)
-print("Y max:")
-print(args$y_max)
-print("Output variables file:")
-print(args$output_var)
-print("Output PDF file:")
-print(args$output_pdf)
-
-names_blocks = strsplit(args$blocks_vec, ",")[[1]]
-names_response_variables = strsplit(args$responses_var, ",")[[1]]
-
-print("names_blocks:")
-print(names_blocks)
-print("names_response_variables:")
-print(names_response_variables)
-
-## Loading libraries
-# suppressPackageStartupMessages(require(ellipse))
-# suppressPackageStartupMessages(require(grDevices))
-# suppressPackageStartupMessages(require(RColorBrewer))
-# suppressPackageStartupMessages(require(mixOmics))
-## Loading local functions
-# source_local("mixomics-blocksplsda-integration/integration_block_splsda_func.R")
-install.packages("https://gitlab.com/bilille/mixomics-blocksplsda-integration/-/raw/master/visCorVar_0.5.tar.gz", repos=NULL)
-suppressPackageStartupMessages(require(visCorVar))
-print("visCorVar has been loaded")
-
-# 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 input Rdata file
-# loads res_matCorAddVar object
-load(args$input_rdata)
-
-mat_cor_comp1 = res_matCorAddVar$mat_cor_comp1
-mat_cor_comp2 = res_matCorAddVar$mat_cor_comp2
-cutoff_comp = res_matCorAddVar$cutoff_comp
-comp = res_matCorAddVar$comp
-list_vec_index_block_select  = res_matCorAddVar$list_vec_index_block_select
-list_vec_names_blocks = res_matCorAddVar$list_vec_names_blocks
-list_cor_comp_selected_var_resp_var = res_matCorAddVar$list_cor_comp_selected_var_resp_var
-res_compute_cor_var_interest = res_matCorAddVar$res_compute_cor_var_interest
-res_block_splsda = res_matCorAddVar$res_block_splsda
-
-#
-print("mat_cor_comp1:")
-print(mat_cor_comp1)
-print("mat_cor_comp2:")
-print(mat_cor_comp2)
-print("cutoff_comp:")
-print(cutoff_comp)
-print("comp:")
-print(comp)
-print("list_vec_index_block_select:")
-print(list_vec_index_block_select)
-print("list_vec_names_blocks:")
-print(list_vec_names_blocks)
-print("list_cor_comp_selected_var_resp_var:")
-print(list_cor_comp_selected_var_resp_var)
-print("res_compute_cor_var_interest:")
-print(res_compute_cor_var_interest)
-
-# Open output pdf file
-pdf(args$output_pdf, width=8, height=7)
-mar = c(5, 5, 2, 8)
-par(mar = mar)
-
-selected_variables = circleCor(list_dataframe_cor_comp_var_global = list_cor_comp_selected_var_resp_var,
-                               list_vec_index_block_select = list_vec_index_block_select,
-                               mat_cor_comp1 = mat_cor_comp1,
-                               mat_cor_comp2 = mat_cor_comp2,
-                               names_blocks = names_blocks,
-                               names_response_variables = names_response_variables,
-                               comp = comp,
-                               cutoff = 0.80,
-                               min.X = args$x_min,
-                               max.X = args$x_max,
-                               min.Y = args$y_min,
-                               max.Y = args$y_max,
-                               # vec_col = vec_col,
-                               rad.in = 0.5,
-                               cex = 0.7,
-                               cex_legend = 0.8,
-                               pos = c(1.2, 0),
-                               pch = 20)
-
-dev.off()
-
-write(selected_variables, file=args$output_var, ncolumns=1)
\ No newline at end of file
--- a/computeMatSimilarity.xml	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-<tool id="computeMatSimilarity" name="computeMatSimilarity" version="0.6+galaxy0" profile="16.04" workflow_compatible="true">
-
-    <description>performs the computation of the similarities. The similarity between two variables is an approximation of the correlation between these two variables.</description>
-
-    <requirements>
-        <requirement type="package" version="0.6">r-viscorvar</requirement>
-        <requirement type="package" version="2.0">r-argparse</requirement>
-    </requirements>
-
-    <stdio>
-        <!-- <exit_code range="1:" level="fatal" /> -->
-    </stdio>
-
-    <command detect_errors="aggressive">
-        <![CDATA[
-        Rscript
-        ${__tool_directory__}/computeMatSimilarity_wrapper.R
-        --input_rdata ${input_rdata}
-        --output_rdata ${output_rdata}
-        ]]>
-    </command>
-
-    <inputs>
-        <param name="input_rdata" type="data" format="rdata"
-               label="Input RData file"
-               help="output RData file from matCorAddVar"/>
-    </inputs>
-
-    <outputs>
-        <data name="output_rdata" format="rdata" label="${tool.name}_output.rdata" />
-    </outputs>
-
-    <tests>
-    </tests>
-
-    <help>
-    </help>
-
-</tool>
\ No newline at end of file
--- a/computeMatSimilarity_wrapper.R	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-#!/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='Run the computeMatSimilarity function')
-
-parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
-parser$add_argument('--output_rdata', dest='output_rdata', required=TRUE, help="Output RData file")
-
-args <- parser$parse_args()
-
-## Print parameters
-print("Input RData:")
-print(args$input_rdata)
-print("Output RData:")
-print(args$output_rdata)
-
-## 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("mixomics-blocksplsda-integration/integration_block_splsda_func.R")
-install.packages("https://gitlab.com/bilille/mixomics-blocksplsda-integration/-/raw/master/visCorVar_0.5.tar.gz", repos=NULL)
-suppressPackageStartupMessages(require(visCorVar))
-print("visCorVar has been loaded")
-
-# Loading input Rdata file
-# loads res_matCorAddVar object
-load(args$input_rdata)
-
-# Run main function
-res_compute_mat_similarity = computeMatSimilarity(res_matCorAddVar = res_matCorAddVar)
-
-liste_mat_similarity_group  = res_compute_mat_similarity$liste_mat_similarity_group
-res_matCorAddVar = res_compute_mat_similarity$res_matCorAddVar
-
-save(res_compute_mat_similarity,
-     file = args$output_rdata)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/macros.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<macros>
+    <xml name="stdio">
+        <stdio>
+            <exit_code range="1" level="fatal" />
+        </stdio>
+    </xml>
+
+    <!-- COMMAND -->
+    <token name="@COMMAND_RSCRIPT@">LC_ALL=C Rscript $__tool_directory__/</token>
+
+    <token name="@COMMAND_LOG_EXIT@">
+        ;
+        return=\$?;
+        cat 'log.txt';
+        sh -c "exit \$return"
+    </token>
+
+    <token name="@HELP_AUTHORS_WRAPPERS@">
+
+.. class:: infomark
+
+**Galaxy integration** bilille platform - UMS 2014 / US 41 - Université de Lille, CNRS, Inserm, Institut Pasteur de Lille, CHU Lille
+
+ | Contact bilille@univ-lille.fr for any questions or concerns about the Galaxy implementation of this tool.
+
+    </token>
+
+</macros>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/macros_mixomics.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<macros>
+
+    <token name="@TOOL_VERSION@">6.12</token>
+    <xml name="requirements">
+        <requirements>
+            <requirement type="package" version="@TOOL_VERSION@">bioconductor-mixomics</requirement>
+            <requirement type="package" version="2.0">r-argparse</requirement>
+            <yield />
+        </requirements>
+    </xml>
+
+    <token name="@HELP_AUTHORS@">
+
+.. class:: infomark
+
+**Authors**  Kim-Anh Le Cao, Florian Rohart, Ignacio Gonzalez, Sebastien Dejean, and others. http://mixomics.org/contact-us/
+
+@HELP_AUTHORS_WRAPPERS@
+
+---------------------------------------------------
+
+    </token>
+
+    <token name="@HELP_MANUAL@">
+
+For details and explanations concerning all the parameters and workflow of mixOmics_ package, see its vignette_ and its manual_
+
+.. _mixOmics: http://mixomics.org/
+.. _vignette: https://www.bioconductor.org/packages/release/bioc/vignettes/mixOmics/inst/doc/vignette.html
+.. _manual: https://www.bioconductor.org/packages/release/bioc/manuals/mixOmics/man/mixOmics.pdf
+
+    </token>
+
+    <xml name="citations">
+        <citations>
+            <citation type="doi">10.1371/journal.pcbi.1005752</citation>
+            <citation type="doi">10.18129/B9.bioc.mixOmics</citation>
+        </citations>
+    </xml>
+</macros>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/macros_viscorvar.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<macros>
+
+    <token name="@TOOL_VERSION@">0.6</token>
+    <xml name="requirements">
+        <requirements>
+            <requirement type="package" version="@TOOL_VERSION@">r-viscorvar</requirement>
+            <requirement type="package" version="2.0">r-argparse</requirement>
+            <yield />
+        </requirements>
+    </xml>
+
+    <token name="@HELP_AUTHORS@">
+
+.. class:: infomark
+
+**Authors**  Maxime Brunin (maxime.brunin@univ-lille.fr), Pierre Pericard (pierre.pericard@univ-lille.fr)
+
+@HELP_AUTHORS_WRAPPERS@
+
+---------------------------------------------------
+
+    </token>
+
+    <token name="@HELP_MANUAL@">
+
+For details and explanations concerning all the parameters and workflow of visCorVar_ package, see its vignette_
+
+.. _visCorVar: https://gitlab.com/bilille/viscorvar
+.. _vignette: https://gitlab.com/bilille/viscorvar/-/blob/master/vignettes/visCorVar.pdf
+
+    </token>
+
+    <xml name="citations">
+        <citations>
+            <!-- <citation type="doi">10.1371/journal.pcbi.1005752</citation>
+            <citation type="doi">10.18129/B9.bioc.mixOmics</citation> -->
+        </citations>
+    </xml>
+</macros>
\ No newline at end of file
--- a/matCorAddVar.xml	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-<tool id="matCorAddVar" name="matCorAddVar" version="0.6+galaxy0" profile="16.04" workflow_compatible="true">
-
-    <description>determine the correlation circles that can be overlaid and compute the correlations</description>
-
-    <requirements>
-        <requirement type="package" version="0.6">r-viscorvar</requirement>
-        <requirement type="package" version="2.0">r-argparse</requirement>
-    </requirements>
-
-    <stdio>
-        <!-- <exit_code range="1:" level="fatal" /> -->
-    </stdio>
-
-    <command detect_errors="aggressive">
-        <![CDATA[
-        Rscript
-        ${__tool_directory__}/matCorAddVar_wrapper.R
-        --input_rdata ${input_rdata}
-        ##--cutoff_comp ${cutoff_comp}
-        --cutoff_comp 0.75
-        #if str($var_of_interest_file) !='':
-            --interest_var_file ${var_of_interest_file}
-        #end if
-        --block_Y_file ${block_Y}
-        --output_rdata ${output_rdata}
-        --output_response_var ${output_response_var}
-        --output_blocks_comb ${output_blocks_comb}
-        ]]>
-    </command>
-
-    <inputs>
-        <param name="input_rdata" type="data" format="rdata"
-               label="Input RData file from block.SPLSDA"
-               help="This is the RData output file from the block.splsda function." />
-        <param name="block_Y" type="data" format="tabular"
-               label="Block Y"
-               help="[block_Y] (tabular format) This table contains the name of the samples in the first column. The other columns correspond to phenotypes. For each of these other columns, a column determines which sample is associated with this phenotype (value equals to 1) or not (value equals to 0). The name of the samples in Block Y (transposed), in the sample metadata (transposed) and for all datasets have to be in the same order" />
-        <!-- Fichier avec noms de gènes/variables, donné par l'utilisateur -->
-        <param name="var_of_interest_file" type="data" format="txt" optional="true"
-               label="Variables of interest (Optional)"
-               help="variables not belonging to any block will not be considered"/>
-<!--         <param name="cutoff_comp" type="float" value="0.775" min="0" max="1"
-               label="Cutoff comp"
-               help="[cutoff_comp] Two correlation circles will be superimposed if the correlation of their first and second axis is greater than cutoff_comp in absolute value." /> -->
-    </inputs>
-
-    <outputs>
-        <data name="output_rdata" format="rdata" label="${tool.name}_output.rdata" />
-        <data name="output_response_var" format="tabular" label="${tool.name}_response_var.tsv" />
-        <data name="output_blocks_comb" format="tabular" label="${tool.name}_blocks_comb.tsv" />
-    </outputs>
-
-    <tests>
-    </tests>
-
-    <help>
-    </help>
-
-</tool>
\ No newline at end of file
--- a/matCorAddVar_wrapper.R	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-#!/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('--interest_var_file', dest='interest_var_file', required=FALSE, help="Variables of interest file")
-parser$add_argument('--block_Y_file', dest='block_Y_file', required=TRUE, help="Block Y filepath")
-parser$add_argument('--output_rdata', dest='output_rdata', required=TRUE, help="Output RData file")
-parser$add_argument('--output_response_var', dest='output_response_var', required=TRUE, help="Output response variables 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("Variables of interest:")
-print(args$interest_var_file)
-print("Block Y file:")
-print(args$block_Y_file)
-print("Output RData:")
-print(args$output_rdata)
-print("Output Response variables:")
-print(args$output_response_var)
-print("Output Blocks combinations:")
-print(args$output_blocks_comb)
-
-## Loading libraries
-# source_local("mixomics-blocksplsda-integration/integration_block_splsda_func.R")
-install.packages("https://gitlab.com/bilille/mixomics-blocksplsda-integration/-/raw/master/visCorVar_0.5.tar.gz", repos=NULL)
-suppressPackageStartupMessages(require(visCorVar))
-print("visCorVar has been loaded")
-
-# 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 input Rdata file
-load(args$input_rdata)
-
-ncomp = mixomics_result$ncomp
-
-# Reading Block Y matrix
-print("Reading Block Y")
-mat_block_Y = read.table(args$block_Y_file, header=TRUE, row.names=1)
-print(mat_block_Y)
-
-response_var = colnames(mat_block_Y)
-
-print("response_var:")
-print(response_var)
-
-# Write response variables to output file
-invisible(lapply(response_var, write, file=args$output_response_var, append=TRUE, ncolumns=1))
-
-# Reading var of intereset file
-interest_var_vec = NULL
-if (args$interest_var_file != 'None') {
-    interest_var_vec = as.character(read.table(args$interest_var_file, header=FALSE)[[1]])
-}
-
-#
-comp = 1:2
-
-# Running main function
-res_matCorAddVar = matCorAddVar(res_block_splsda = mixomics_result,
-                                block_Y = mat_block_Y,
-                                cutoff_comp = args$cutoff_comp,
-                                var_interest = interest_var_vec,
-                                comp = comp)
-
-#
-mat_cor_comp1 = res_matCorAddVar$mat_cor_comp1
-mat_cor_comp2 = res_matCorAddVar$mat_cor_comp2
-list_vec_index_block_select  = res_matCorAddVar$list_vec_index_block_select
-list_vec_names_blocks = res_matCorAddVar$list_vec_names_blocks
-list_cor_comp_selected_var_resp_var = res_matCorAddVar$list_cor_comp_selected_var_resp_var
-res_compute_cor_var_interest = res_matCorAddVar$res_compute_cor_var_interest
-
-#
-print("mat_cor_comp1:")
-print(mat_cor_comp1)
-print("mat_cor_comp2:")
-print(mat_cor_comp2)
-print("list_vec_index_block_select:")
-print(list_vec_index_block_select)
-print("list_vec_names_blocks:")
-print(list_vec_names_blocks)
-print("list_cor_comp_selected_var_resp_var:")
-print(list_cor_comp_selected_var_resp_var)
-print("res_compute_cor_var_interest:")
-print(res_compute_cor_var_interest)
-
-# Write all possible blocks combinations to output file
-invisible(lapply(list_vec_names_blocks, write, file=args$output_blocks_comb, append=TRUE, ncolumns=100, sep=","))
-
-# Save all objects in Rdata output file
-save(res_matCorAddVar,
-     file = args$output_rdata)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mixomics_blocksplsda.R	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,256 @@
+#!/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='Run the mixOmics block.splsda function')
+
+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")
+parser$add_argument('--sample_metadata_in', dest='sample_metadata_in', required=TRUE,
+                    help="Samples metadata file")
+parser$add_argument('--sample_description_col', dest='sample_description_col', type='integer',
+                    default=0, help="Sample description column number")
+parser$add_argument('--ncomp', dest='ncomp', type='integer', default=2,
+                    help="Number of components to include in the model")
+parser$add_argument('--correlation', dest='correlation', action="store_true",
+                    help="Add correlation between all blocks")
+parser$add_argument('--scheme', dest='scheme', default="horst", help="Scheme")
+parser$add_argument('--mode', dest='mode', default="regression", help="Mode")
+parser$add_argument('--maxiter', dest='maxiter', type='integer', default=100,
+                    help="Maximum number of iterations")
+parser$add_argument('--scale', dest='scale', action="store_true",
+                    help="Each block is standardized to zero means and unit variances")
+parser$add_argument('--check_missing_values', dest='check_missing_values', action="store_true",
+                    help="Check for missing values and raise an error")
+parser$add_argument('--init', dest='init', default="svd",
+                    help="Init (svd or svd.single)")
+parser$add_argument('--tol', dest='tol', type='double', default=1e-06,
+                    help="Convergence stopping value")
+parser$add_argument('--nearzerovar', dest='nearzerovar', action="store_true",
+                    help="Should be set in particular for data with many zero values")
+parser$add_argument('--rdata_out', dest='rdata_out', required=TRUE, help="Output Rdata file")
+# parser$add_argument('--sample_metadata_out', dest='sample_metadata_out', required=TRUE, help="Output sample metadata file")
+parser$add_argument('--variable_metadata_outdir', dest='variable_metadata_outdir', required=TRUE, help="Output variable metadata directory")
+
+args <- parser$parse_args()
+
+## Print parameters
+print("Blocks:")
+print(args$blocks_list)
+print("Sample metadata file:")
+print(args$sample_metadata_in)
+print("Sample description column number:")
+print(args$sample_description_col)
+print("Number of components:")
+print(args$ncomp)
+print("Compute correlation between all blocks:")
+print(args$correlation)
+print("Scheme:")
+print(args$scheme)
+print("Mode:")
+print(args$mode)
+print("Max nb of iterations:")
+print(args$maxiter)
+print("Scale:")
+print(args$scale)
+print("Check for missing values:")
+print(args$check_missing_values)
+print("Tol:")
+print(args$tol)
+print("near.zero.var:")
+print(args$nearzerovar)
+print("Output Rdata file:")
+print(args$rdata_out)
+# print("Output sample metadata file:")
+# print(args$sample_metadata_out)
+print("Output variable metadata directory:")
+print(args$variable_metadata_outdir)
+
+## Loading libraries
+suppressPackageStartupMessages(require(mixOmics))
+
+## Read sample metadata file and set description factor matrix
+sample_metadata <- read.table(args$sample_metadata_in, sep='\t', header=TRUE, row.names=1)
+sample_metadata_names <- row.names(sample_metadata)
+# print(sample_metadata_names)
+
+# print("Sample metadata matrix:")
+# print(head(sample_metadata))
+
+description_column <- ncol(sample_metadata)
+if(args$sample_description_col > 0)
+{
+    description_column <- args$sample_description_col
+}
+
+Y <- factor(sample_metadata[[description_column]])
+
+print("Y factor matrix:")
+print(Y)
+
+## Read and prepare block datasets
+list_X <- c()
+keepX <- c()
+
+for(i in 1:nrow(args$blocks_list))
+{
+    # Read block input parameters
+    block_name <- args$blocks_list[i,1]
+    block_keep <- strtoi(args$blocks_list[i,2])
+    block_data_matrix_filename <- args$blocks_list[i,3]
+    # block_meta_var <- args$blocks_list[i,4]
+
+    print(sprintf("Processing block %s", block_name))
+
+    # Store block data matrices
+    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
+    block_data_matrix_names <- row.names(block_data_matrix)
+    # print(block_data_matrix_names)
+
+    if(!identical(sample_metadata_names, block_data_matrix_names))
+    {
+        stop("Sample names must be the same and in the same order in the sample metadata matrix and the block data matrix")
+    }
+
+    if(any(is.na(block_data_matrix)))
+    {
+        stop(sprintf("Block %s contains missing values. We recommend not to perform data integration with missing values. If you want to force run, change the advanced parameter 'Check for missing values' to 'No'.", block_name))
+    }
+
+    list_X[[block_name]] <- block_data_matrix
+
+    # Set the nb of variables to keep
+    nb_variables = ncol(list_X[[block_name]])
+    if(block_keep > 0)
+    {
+        keepX[[block_name]] <- rep(block_keep, args$ncomp)
+    }
+    else
+    {
+        keepX[[block_name]] <- rep(nb_variables, args$ncomp)
+    }
+    print(sprintf("Block %s contains %d variables and %d will be selected", block_name, nb_variables, block_keep))
+}
+
+# print(list_X)
+
+## Generate design matrix
+block_nb <- nrow(args$blocks_list)
+
+design <- matrix(0, nrow = block_nb, ncol = block_nb)
+
+if(args$correlation)
+{
+    design <- matrix(1, nrow = block_nb, ncol = block_nb)
+    diag(design) <- 0
+}
+
+# print("Design matrix:")
+# print(design)
+
+###################
+## Main function ##
+###################
+
+mixomics_result <- block.splsda(X = list_X,
+                                Y = Y,
+                                ncomp = args$ncomp,
+                                keepX = keepX,
+                                design = design,
+                                scheme = args$scheme,
+                                mode = args$mode,
+                                scale = args$scale,
+                                init = args$init,
+                                tol = args$tol,
+                                max.iter = args$maxiter,
+                                near.zero.var = args$nearzerovar,
+                                all.outputs = TRUE)
+
+print("Block.splsda object:")
+print(mixomics_result)
+print(attributes(mixomics_result))
+
+## Save output Rdata file
+save(mixomics_result, file=args$rdata_out)
+
+# 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="/"))
+}
+
+# Load library
+source_local("mixomics_blocksplsda_additional_funct.R")
+
+
+list_union_selected_block_variables = unionSelectBlockVariables(mixomics_result)
+
+## Save output sample metadata file
+# print("Block.splsda variates:")
+# print(mixomics_result$variates)
+
+# for(block_name in names(mixomics_result$variates))
+# {
+#     # print(block_name)
+#     # print(mixomics_result$variates[[block_name]])
+
+#     # Format the column names to add the block name and replace spaces
+#     colnames(mixomics_result$variates[[block_name]]) <- paste("block.splsda_variates", block_name, gsub(" ", "_", colnames(mixomics_result$variates[[block_name]])), sep = "_")
+#     # print(mixomics_result$variates[[block_name]])
+
+#     # Append the new columns to the sample metadata matrix
+#     sample_metadata <- cbind2(sample_metadata, mixomics_result$variates[[block_name]])
+# }
+
+# print(sample_metadata)
+
+# write.table(sample_metadata, file = args$sample_metadata_out, quote = TRUE, sep = "\t", row.names = TRUE, col.names = NA)
+
+## Save output variable metadata files in output directory
+# print("Block.splsda loadings:")
+# print(mixomics_result$loadings)
+
+for(i in 1:nrow(args$blocks_list))
+{
+    # Read again block input parameters
+    block_name <- args$blocks_list[i,1]
+    # block_keep <- strtoi(args$blocks_list[i,2])
+    # block_data_matrix_filename <- args$blocks_list[i,3]
+    block_meta_var <- args$blocks_list[i,4]
+
+    print(sprintf("Saving block %s output metavar", block_name))
+
+
+    meta_variable <- list_union_selected_block_variables[[i]]
+    colnames(meta_variable) <- "block.splsda_var_select"
+
+    # meta_variable <- mixomics_result$loadings[[block_name]]
+    # print(head(meta_variable))
+
+    # Format the column names to add the block name and replace spaces
+    # colnames(meta_variable) <- paste("block.splsda_loadings", gsub(" ", "_", colnames(meta_variable)), sep = "_")
+
+    # Read input block variable metadata files if provided (optional)
+    if(block_meta_var != "None")
+    {
+        input_meta_variable <- read.table(block_meta_var, sep='\t', header=TRUE, row.names=1)
+        # print(head(input_meta_variable))
+
+        # Append the new columns to the variable metadata matrix
+        meta_variable <- cbind2(input_meta_variable, meta_variable)
+    }
+
+    # print(head(meta_variable))
+
+    block_meta_var_output_filename <- paste("mixomics_blocksplsda_block_", block_name, "_variable_metadata.tsv", sep="")
+    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)
+}
--- a/mixomics_blocksplsda.xml	Thu Oct 15 12:22:25 2020 +0000
+++ b/mixomics_blocksplsda.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -1,21 +1,20 @@
-<tool id="mixomics_blocksplsda" name="mixOmics block.splsda" version="6.12+galaxy0" profile="16.04" workflow_compatible="true">
+<tool id="mixomics_blocksplsda" name="mixOmics block.splsda" version="@TOOL_VERSION@+galaxy1" profile="16.04" workflow_compatible="true">
 
     <description>performs N-integration and feature selection with Projection to Latent Structures models (PLS) with sparse Discriminant Analysis</description>
 
-    <requirements>
-        <requirement type="package" version="6.12">bioconductor-mixomics</requirement>
-        <requirement type="package" version="2.0">r-argparse</requirement>
-    </requirements>
+    <macros>
+        <import>macros.xml</import>
+        <import>macros_mixomics.xml</import>
+    </macros>
 
-<!--     <stdio>
-        <exit_code range="1:" level="fatal" />
-    </stdio> -->
+    <expand macro="requirements"/>
+    <expand macro="stdio"/>
 
-    <command detect_errors="aggressive">
-        <![CDATA[
+    <command detect_errors="aggressive"><![CDATA[
+
         mkdir outdir
-        && Rscript
-        ${__tool_directory__}/mixomics_blocksplsda_script.R
+        && @COMMAND_RSCRIPT@/mixomics_blocksplsda.R
+
         #for $b in $blocks
             --block
             #if $b.block_name
@@ -27,8 +26,10 @@
             ${b.data_matrix}
             ${b.variable_metadata}
         #end for
+
         --sample_metadata_in ${sample_metadata_in}
         --sample_description_col ${sample_description_col}
+
         --ncomp ${adv.ncomp}
         ${correlation}
         ##--scheme ${adv.scheme}
@@ -40,11 +41,14 @@
         ##--init ${adv.init}
         ##--tol ${adv.tol}
         ##${adv.nearzerovar}
+
         --rdata_out ${rdata_out}
         ##--sample_metadata_out ${sample_metadata_out}
         --variable_metadata_outdir outdir
-        ]]>
-    </command>
+
+        @COMMAND_LOG_EXIT@
+
+    ]]></command>
 
     <inputs>
         <repeat name="blocks" title="Blocks">
@@ -73,7 +77,7 @@
             <param name="ncomp" type="integer" value="2" min="1"
                    label="Number of components to include in the model"
                    help="[ncomp] Number of new variables (components) computed by the data integration." />
-<!--             <param name="scheme" type="select" label="Scheme">
+            <!-- <param name="scheme" type="select" label="Scheme">
                 <option value="horst" selected="true">horst</option>
                 <option value="factorial"            >factorial</option>
                 <option value="centroid"             >centroid</option>
@@ -87,13 +91,13 @@
             <param name="maxiter" type="integer" value="100" min="1"
                    label="Maximum number of iterations"
                    help="[max.iter] Maximum number of iterations performed by block.splsda." />
-<!--            <param name="scale" type="boolean" truevalue="-\-scale" falsevalue="" checked="true"
+            <!-- <param name="scale" type="boolean" truevalue="-\-scale" falsevalue="" checked="true"
                    label="Scale"
                    help="if checked, each block is standardized to zero means and unit variances" /> -->
             <param name="check_missing_values" type="boolean" truevalue="-\-check_missing_values" falsevalue="" checked="true"
                    label="Check for missing values"
                    help="will raise an error if missing values are found in data matrices" />
-<!--             <param name="init" type="select" label="Init">
+            <!-- <param name="init" type="select" label="Init">
                 <option value="svd" selected="true">svd</option>
                 <option value="svd.single"         >svd.single</option>
             </param>
@@ -106,7 +110,7 @@
     </inputs>
 
     <outputs>
-        <data name="rdata_out" format="rdata" label="${tool.name}_output.rdata" />
+        <data name="rdata_out" format="rdata" label="${tool.name}_output.RData" />
         <!-- <data name="sample_metadata_out" format="tabular"
               label="${tool.name}_${sample_metadata_in.name}" /> -->
         <collection name="blocks_output" type="list" label="${tool.name}_blocks_output">
@@ -127,26 +131,13 @@
             </repeat>
             <param name="sample_metadata_in" value="in_sample_meta.tabular" />
             <output name="rdata_out" value="out_rdata.rdata" />
-            <output name="sample_metadata_out" value="out_sample_meta.tabular" />
+            <!-- <output name="sample_metadata_out" value="out_sample_meta.tabular" /> -->
         </test>
     </tests>
 
-    <help>
-        <![CDATA[
-.. class:: infomark
-
-**Authors** Pierre Pericard (pierre.pericard@pasteur-lille.fr)
-
----------------------------------------------------
+    <help><![CDATA[
 
-.. class:: infomark
-
-**Please cite**
-
-Rohart F, Gautier B, Singh A, Lê Cao KA (2017) mixOmics: An R package for ‘omics feature selection and multiple data integration.
-PLOS Computational Biology 13(11): e1005752. https://doi.org/10.1371/journal.pcbi.1005752
-
----------------------------------------------------
+@HELP_AUTHORS@
 
 ======================
 mixOmics blocks.splsda
@@ -159,12 +150,30 @@
 The blocks.splsda function is part of the mixOmics package for exploration and integration of Omics datasets.
 Performs N-integration and feature selection with Projection to Latent Structures models (PLS) with sparse Discriminant Analysis.
 
+-----------------
+Workflow position
+-----------------
+
+**Downstream tools**
+
+======================= ================================== ==========
+Name                               Output file               Format
+======================= ================================== ==========
+mixOmics.plotIndiv      mixomics_blocksplsda_output.RData  rdata
+----------------------- ---------------------------------- ----------
+mixOmics.plotVar        mixomics_blocksplsda_output.RData  rdata
+----------------------- ---------------------------------- ----------
+visCorVar.matCorAddVar  mixomics_blocksplsda_output.RData  rdata
+======================= ================================== ==========
+
+---------------------------------------------------
+
 -----------
 Input files
 -----------
 
 For each block (min 2 blocks):
-==============================
+------------------------------
 
 +------------------------------+------------+
 | Parameter : num + label      |   Format   |
@@ -188,7 +197,7 @@
     * First column = variables names. MUST be the same and in the same order than in the associated data matrix
 
 Global input files:
-===================
+-------------------
 
 +-----------------------------+------------+
 | Parameter : num + label     |   Format   |
@@ -209,7 +218,7 @@
 ----------
 
 For each block (min 2 blocks):
-==============================
+------------------------------
 
 Block name
     Name of the block. If not provided, this will default to the input filename
@@ -218,7 +227,7 @@
     If set to 0 (default), all variables will be considered in the model
 
 Global parameters:
-==================
+------------------
 
 Sample description column number
 
@@ -227,7 +236,7 @@
 Correlation between all blocks
 
 Advanced options:
-=================
+-----------------
 
 Scheme
 
@@ -243,26 +252,22 @@
 
 Near zero var
 
+
+@HELP_MANUAL@
+
 ------------
 Output files
 ------------
 
-mixomics_blocksplsda_output.rdata
-    | rData output
+mixomics_blocksplsda_output.RData
+    | RData output
     | Contains the `mixomics_result` R object containing the result of the block.splsda function
 
-mixomics_blocksplsda_{input_sample_metadata_name}
-    | tabular output
-    | Identical to the input Sample metadata file with appended columns from the result of block.splsda function
-
 mixomics_blocksplsda_blocks_output
     A collection with the variable metadata output files (mixomics_blocksplsda_block_{block name}_variable_metadata) for each input block
 
-        ]]>
-    </help>
+    ]]></help>
 
-    <citations>
-        <citation type="doi">10.1371/journal.pcbi.1005752</citation>
-    </citations>
+    <expand macro="citations" />
 
 </tool>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mixomics_blocksplsda_additional_funct.R	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,52 @@
+#' @title Determination of selected variables for all components
+#' @description The function unionSelectBlockVariables determines, for each block, the selected block variables
+#' for all components.
+#' @param res_block_splsda type : sgccda. This parameter is the output of block.splsda function 
+#' mixOmics.
+#' @details For each block, the function unionSelectBlockVariables returns 1 if the block variable is selected for
+#' at least one component. Otherwise, this function returns 0.
+#' @return type : list of matrix. For each block, if the block variable is selected, the value 1 is associated with 
+#' this block variable. Otherwise the value 0 is associated with this block variable. 
+#' @examples 
+#' data(res_data_integration)
+#' list_union_selected_block_variables = unionSelectBlockVariables(res_data_integration)
+#' @export
+unionSelectBlockVariables <-function(res_block_splsda)
+{
+  ncomp = res_block_splsda$ncomp[1]
+  
+  names_blocks = names(res_block_splsda$loadings)
+  index_Y = which(names_blocks == "Y")
+  names_blocks = names_blocks[ - index_Y]
+  list_select_block_variables = list()
+  
+  for(i in 1:length(names_blocks))
+  {
+    mat_loadings_i = res_block_splsda$loadings[[i]]
+    index_i = c()
+    
+    for(j in 1:ncomp)
+    {
+      loadings_i_j = mat_loadings_i[, j]
+      index_i_j = which(loadings_i_j != 0)
+      
+      index_i = c(index_i, index_i_j)
+      
+    } # End for(j 1:ncomp).
+    
+    index_i = unique(index_i)
+    
+    mat_select_block_variables = matrix(0,
+                                        nrow = dim(mat_loadings_i)[1],
+                                        ncol = 1)
+    mat_select_block_variables[index_i, 1] = rep(1, length(index_i))
+    rownames(mat_select_block_variables) = rownames(mat_loadings_i)
+    
+    list_select_block_variables[[i]] = mat_select_block_variables
+    
+  } # End for(i in 1:length(names_blocks)).
+  
+  names(list_select_block_variables) = names_blocks
+  
+  return(list_select_block_variables)
+}
--- a/mixomics_blocksplsda_script.R	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
-#!/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='Run the mixOmics block.splsda function')
-
-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")
-parser$add_argument('--sample_metadata_in', dest='sample_metadata_in', required=TRUE,
-                    help="Samples metadata file")
-parser$add_argument('--sample_description_col', dest='sample_description_col', type='integer',
-                    default=0, help="Sample description column number")
-parser$add_argument('--ncomp', dest='ncomp', type='integer', default=2,
-                    help="Number of components to include in the model")
-parser$add_argument('--correlation', dest='correlation', action="store_true",
-                    help="Add correlation between all blocks")
-parser$add_argument('--scheme', dest='scheme', default="horst", help="Scheme")
-parser$add_argument('--mode', dest='mode', default="regression", help="Mode")
-parser$add_argument('--maxiter', dest='maxiter', type='integer', default=100,
-                    help="Maximum number of iterations")
-parser$add_argument('--scale', dest='scale', action="store_true",
-                    help="Each block is standardized to zero means and unit variances")
-parser$add_argument('--check_missing_values', dest='check_missing_values', action="store_true",
-                    help="Check for missing values and raise an error")
-parser$add_argument('--init', dest='init', default="svd",
-                    help="Init (svd or svd.single)")
-parser$add_argument('--tol', dest='tol', type='double', default=1e-06,
-                    help="Convergence stopping value")
-parser$add_argument('--nearzerovar', dest='nearzerovar', action="store_true",
-                    help="Should be set in particular for data with many zero values")
-parser$add_argument('--rdata_out', dest='rdata_out', required=TRUE, help="Output Rdata file")
-# parser$add_argument('--sample_metadata_out', dest='sample_metadata_out', required=TRUE, help="Output sample metadata file")
-parser$add_argument('--variable_metadata_outdir', dest='variable_metadata_outdir', required=TRUE, help="Output variable metadata directory")
-
-args <- parser$parse_args()
-
-## Print parameters
-print("Blocks:")
-print(args$blocks_list)
-print("Sample metadata file:")
-print(args$sample_metadata_in)
-print("Sample description column number:")
-print(args$sample_description_col)
-print("Number of components:")
-print(args$ncomp)
-print("Compute correlation between all blocks:")
-print(args$correlation)
-print("Scheme:")
-print(args$scheme)
-print("Mode:")
-print(args$mode)
-print("Max nb of iterations:")
-print(args$maxiter)
-print("Scale:")
-print(args$scale)
-print("Check for missing values:")
-print(args$check_missing_values)
-print("Tol:")
-print(args$tol)
-print("near.zero.var:")
-print(args$nearzerovar)
-print("Output Rdata file:")
-print(args$rdata_out)
-# print("Output sample metadata file:")
-# print(args$sample_metadata_out)
-print("Output variable metadata directory:")
-print(args$variable_metadata_outdir)
-
-## Loading libraries
-suppressPackageStartupMessages(require(mixOmics))
-
-## Read sample metadata file and set description factor matrix
-sample_metadata <- read.table(args$sample_metadata_in, sep='\t', header=TRUE, row.names=1)
-sample_metadata_names <- row.names(sample_metadata)
-# print(sample_metadata_names)
-
-# print("Sample metadata matrix:")
-# print(head(sample_metadata))
-
-description_column <- ncol(sample_metadata)
-if(args$sample_description_col > 0)
-{
-    description_column <- args$sample_description_col
-}
-
-Y <- factor(sample_metadata[[description_column]])
-
-print("Y factor matrix:")
-print(Y)
-
-## Read and prepare block datasets
-list_X <- c()
-keepX <- c()
-
-for(i in 1:nrow(args$blocks_list))
-{
-    # Read block input parameters
-    block_name <- args$blocks_list[i,1]
-    block_keep <- strtoi(args$blocks_list[i,2])
-    block_data_matrix_filename <- args$blocks_list[i,3]
-    # block_meta_var <- args$blocks_list[i,4]
-
-    print(sprintf("Processing block %s", block_name))
-
-    # Store block data matrices
-    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
-    block_data_matrix_names <- row.names(block_data_matrix)
-    # print(block_data_matrix_names)
-
-    if(!identical(sample_metadata_names, block_data_matrix_names))
-    {
-        stop("Sample names must be the same and in the same order in the sample metadata matrix and the block data matrix")
-    }
-
-    if(any(is.na(block_data_matrix)))
-    {
-        stop(sprintf("Block %s contains missing values. We recommend not to perform data integration with missing values. If you want to force run, change the advanced parameter 'Check for missing values' to 'No'.", block_name))
-    }
-
-    list_X[[block_name]] <- block_data_matrix
-
-    # Set the nb of variables to keep
-    nb_variables = ncol(list_X[[block_name]])
-    if(block_keep > 0)
-    {
-        keepX[[block_name]] <- rep(block_keep, args$ncomp)
-    }
-    else
-    {
-        keepX[[block_name]] <- rep(nb_variables, args$ncomp)
-    }
-    print(sprintf("Block %s contains %d variables and %d will be selected", block_name, nb_variables, block_keep))
-}
-
-# print(list_X)
-
-## Generate design matrix
-block_nb <- nrow(args$blocks_list)
-
-design <- matrix(0, nrow = block_nb, ncol = block_nb)
-
-if(args$correlation)
-{
-    design <- matrix(1, nrow = block_nb, ncol = block_nb)
-    diag(design) <- 0
-}
-
-# print("Design matrix:")
-# print(design)
-
-###################
-## Main function ##
-###################
-
-mixomics_result <- block.splsda(X = list_X,
-                                Y = Y,
-                                ncomp = args$ncomp,
-                                keepX = keepX,
-                                design = design,
-                                scheme = args$scheme,
-                                mode = args$mode,
-                                scale = args$scale,
-                                init = args$init,
-                                tol = args$tol,
-                                max.iter = args$maxiter,
-                                near.zero.var = args$nearzerovar,
-                                all.outputs = TRUE)
-
-print("Block.splsda object:")
-print(mixomics_result)
-print(attributes(mixomics_result))
-
-## Save output Rdata file
-save(mixomics_result, file=args$rdata_out)
-
-# 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="/"))
-}
-
-# Load library
-source_local("additional_functions_block_splsda.R")
-
-
-
-list_union_selected_block_variables = unionSelectBlockVariables(mixomics_result)
-
-## Save output sample metadata file
-# print("Block.splsda variates:")
-# print(mixomics_result$variates)
-
-# for(block_name in names(mixomics_result$variates))
-# {
-#     # print(block_name)
-#     # print(mixomics_result$variates[[block_name]])
-
-#     # Format the column names to add the block name and replace spaces
-#     colnames(mixomics_result$variates[[block_name]]) <- paste("block.splsda_variates", block_name, gsub(" ", "_", colnames(mixomics_result$variates[[block_name]])), sep = "_")
-#     # print(mixomics_result$variates[[block_name]])
-
-#     # Append the new columns to the sample metadata matrix
-#     sample_metadata <- cbind2(sample_metadata, mixomics_result$variates[[block_name]])
-# }
-
-# print(sample_metadata)
-
-# write.table(sample_metadata, file = args$sample_metadata_out, quote = TRUE, sep = "\t", row.names = TRUE, col.names = NA)
-
-## Save output variable metadata files in output directory
-# print("Block.splsda loadings:")
-# print(mixomics_result$loadings)
-
-for(i in 1:nrow(args$blocks_list))
-{
-    # Read again block input parameters
-    block_name <- args$blocks_list[i,1]
-    # block_keep <- strtoi(args$blocks_list[i,2])
-    # block_data_matrix_filename <- args$blocks_list[i,3]
-    block_meta_var <- args$blocks_list[i,4]
-
-    print(sprintf("Saving block %s output metavar", block_name))
-
-
-    meta_variable <- list_union_selected_block_variables[[i]]
-    colnames(meta_variable) <- "block.splsda_var_select"
-
-    # meta_variable <- mixomics_result$loadings[[block_name]]
-    # print(head(meta_variable))
-
-    # Format the column names to add the block name and replace spaces
-    # colnames(meta_variable) <- paste("block.splsda_loadings", gsub(" ", "_", colnames(meta_variable)), sep = "_")
-
-    # Read input block variable metadata files if provided (optional)
-    if(block_meta_var != "None")
-    {
-        input_meta_variable <- read.table(block_meta_var, sep='\t', header=TRUE, row.names=1)
-        # print(head(input_meta_variable))
-
-        # Append the new columns to the variable metadata matrix
-        meta_variable <- cbind2(input_meta_variable, meta_variable)
-    }
-
-    # print(head(meta_variable))
-
-    block_meta_var_output_filename <- paste("mixomics_blocksplsda_block_", block_name, "_variable_metadata.tsv", sep="")
-    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)
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mixomics_plotindiv.R	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,55 @@
+#!/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='Run the mixOmics plotIndiv function')
+
+parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
+parser$add_argument('--legend', dest='legend', action="store_true", help="Display the legend")
+parser$add_argument('--ellipse', dest='ellipse', action="store_true", help="Plot ellipse plots")
+parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file")
+
+args <- parser$parse_args()
+
+## Print parameters
+print("Input RData:")
+print(args$input_rdata)
+print("Plot legend:")
+print(args$legend)
+print("Plot ellipse plots:")
+print(args$ellipse)
+print("Output PDF file:")
+print(args$output_pdf)
+
+# loading libraries
+suppressPackageStartupMessages(require(mixOmics))
+
+load(args$input_rdata)
+
+pdf(args$output_pdf, width=8, height=7)
+mar = c(5, 5, 2, 8)
+par(mar = mar)
+
+# plotIndiv(mixomics_result,
+#           legend = args$legend,
+#           ellipse = args$ellipse)
+
+for(k in 1:(length(mixomics_result$names[[3]])-1))
+{
+    name_block = mixomics_result$names[[3]][k]
+
+    try(plotIndiv(mixomics_result,
+                  blocks = k,
+                  legend = args$legend,
+                  ellipse = args$ellipse),
+        silent = FALSE)
+}
+
+dev.off()
\ No newline at end of file
--- a/mixomics_plotindiv.xml	Thu Oct 15 12:22:25 2020 +0000
+++ b/mixomics_plotindiv.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -1,26 +1,29 @@
-<tool id="mixomics_plotindiv" name="mixOmics plotIndiv" version="6.12+galaxy0" profile="16.04" workflow_compatible="true">
+<tool id="mixomics_plotindiv" name="mixOmics plotIndiv" version="@TOOL_VERSION@+galaxy1" profile="16.04" workflow_compatible="true">
 
     <description>provides scatter plots for individuals (experimental units) representation in (sparse)(I)PCA,(regularized)CCA, (sparse)PLS(DA) and (sparse)(R)GCCA(DA)</description>
 
-    <requirements>
-        <requirement type="package" version="6.12">bioconductor-mixomics</requirement>
-        <requirement type="package" version="2.0">r-argparse</requirement>
-    </requirements>
+    <macros>
+        <import>macros.xml</import>
+        <import>macros_mixomics.xml</import>
+    </macros>
 
-    <stdio>
-        <!-- <exit_code range="1:" level="fatal" /> -->
-    </stdio>
+    <expand macro="requirements"/>
+    <expand macro="stdio"/>
+
+    <command detect_errors="aggressive"><![CDATA[
 
-    <command detect_errors="aggressive">
-        <![CDATA[
-        Rscript
-        ${__tool_directory__}/mixomics_plotindiv_script.R
+        @COMMAND_RSCRIPT@/mixomics_plotindiv.R
+
         --input_rdata $input_rdata
+
         $adv.legend
         $adv.ellipse
+
         --output_pdf $output_pdf
-        ]]>
-    </command>
+
+        @COMMAND_LOG_EXIT@
+
+    ]]></command>
 
     <inputs>
         <param name="input_rdata" type="data" format="rdata"
@@ -45,22 +48,9 @@
         </test>
     </tests>
 
-    <help>
-        <![CDATA[
-.. class:: infomark
-
-**Authors** Pierre Pericard (pierre.pericard@pasteur-lille.fr)
-
----------------------------------------------------
+    <help><![CDATA[
 
-.. class:: infomark
-
-**Please cite**
-
-Rohart F, Gautier B, Singh A, Lê Cao KA (2017) mixOmics: An R package for ‘omics feature selection and multiple data integration.
-PLOS Computational Biology 13(11): e1005752. https://doi.org/10.1371/journal.pcbi.1005752
-
----------------------------------------------------
+@HELP_AUTHORS@
 
 ==================
 mixOmics plotIndiv
@@ -73,6 +63,20 @@
 The plotIndiv function is part of the mixOmics package for exploration and integration of Omics datasets.
 Provides scatter plots for individuals (experimental units) representation in (sparse)(I)PCA,(regularized)CCA, (sparse)PLS(DA) and (sparse)(R)GCCA(DA).
 
+-----------------
+Workflow position
+-----------------
+
+**Upstream tools**
+
+======================= =================================== ========
+Name                    Output file                         Format
+======================= =================================== ========
+mixOmics.block.splsda   mixomics_blocksplsda_output.RData   rdata
+======================= =================================== ========
+
+---------------------------------------------------
+
 -----------
 Input files
 -----------
@@ -94,6 +98,9 @@
 
 Plot ellipse plots
 
+
+@HELP_MANUAL@
+
 ------------
 Output files
 ------------
@@ -101,11 +108,8 @@
 plotIndiv.pdf
     A pdf file with scatter plots for individuals
 
-        ]]>
-    </help>
+    ]]></help>
 
-    <citations>
-        <citation type="doi">10.1371/journal.pcbi.1005752</citation>
-    </citations>
+    <expand macro="citations" />
 
 </tool>
\ No newline at end of file
--- a/mixomics_plotindiv_script.R	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-#!/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='Run the mixOmics plotIndiv function')
-
-parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
-parser$add_argument('--legend', dest='legend', action="store_true", help="Display the legend")
-parser$add_argument('--ellipse', dest='ellipse', action="store_true", help="Plot ellipse plots")
-parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file")
-
-args <- parser$parse_args()
-
-## Print parameters
-print("Input RData:")
-print(args$input_rdata)
-print("Plot legend:")
-print(args$legend)
-print("Plot ellipse plots:")
-print(args$ellipse)
-print("Output PDF file:")
-print(args$output_pdf)
-
-# loading libraries
-suppressPackageStartupMessages(require(mixOmics))
-
-load(args$input_rdata)
-
-pdf(args$output_pdf, width=8, height=7)
-mar = c(5, 5, 2, 8)
-par(mar = mar)
-
-# plotIndiv(mixomics_result,
-#           legend = args$legend,
-#           ellipse = args$ellipse)
-
-for(k in 1:(length(mixomics_result$names[[3]])-1))
-{
-    name_block = mixomics_result$names[[3]][k]
-
-    try(plotIndiv(mixomics_result,
-                  blocks = k,
-                  legend = args$legend,
-                  ellipse = args$ellipse),
-        silent = FALSE)
-}
-
-dev.off()
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mixomics_plotvar.R	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,58 @@
+#!/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")
+
+## Main Function ##
+
+suppressPackageStartupMessages(require(argparse))
+
+parser <- ArgumentParser(description='Run the mixOmics plotVar function')
+
+parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
+parser$add_argument('--legend', dest='legend', action="store_true", help="Display the legend")
+parser$add_argument('--cutoff', dest='cutoff', type='double', required=TRUE, help="Cutoff (0..1)")
+parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file")
+
+args <- parser$parse_args()
+
+##
+print("Input RData:")
+print(args$input_rdata)
+print("Plot legend:")
+print(args$legend)
+print("Cutoff:")
+print(args$cutoff)
+print("Output PDF file:")
+print(args$output_pdf)
+
+# loading libraries
+suppressPackageStartupMessages(require(mixOmics))
+
+load(args$input_rdata)
+
+pdf(args$output_pdf, width=8, height=7)
+mar = c(5, 5, 2, 8)
+par(mar = mar)
+
+# plotVar(mixomics_result,
+#         legend = args$legend,
+#         cutoff = args$cutoff)
+
+for(k in 1:(length(mixomics_result$names[[3]])-1))
+{
+    name_block = mixomics_result$names[[3]][k]
+
+    # We're still continuing even if a graph is empty
+    try(plotVar(mixomics_result,
+                blocks = k,
+                legend = args$legend,
+                cutoff = args$cutoff),
+        silent = FALSE)
+
+}
+
+dev.off()
\ No newline at end of file
--- a/mixomics_plotvar.xml	Thu Oct 15 12:22:25 2020 +0000
+++ b/mixomics_plotvar.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -1,26 +1,29 @@
-<tool id="mixomics_plotvar" name="mixOmics plotVar" version="6.12+galaxy0" profile="16.04" workflow_compatible="true">
+<tool id="mixomics_plotvar" name="mixOmics plotVar" version="@TOOL_VERSION@+galaxy1" profile="16.04" workflow_compatible="true">
 
     <description>provides variables representation for (regularized) CCA, (sparse) PLS regression, PCA and (sparse) Regularized generalised CCA</description>
 
-    <requirements>
-        <requirement type="package" version="6.12">bioconductor-mixomics</requirement>
-        <requirement type="package" version="2.0">r-argparse</requirement>
-    </requirements>
+    <macros>
+        <import>macros.xml</import>
+        <import>macros_mixomics.xml</import>
+    </macros>
 
-    <stdio>
-        <!-- <exit_code range="1:" level="fatal" /> -->
-    </stdio>
+    <expand macro="requirements"/>
+    <expand macro="stdio"/>
+
+    <command detect_errors="aggressive"><![CDATA[
 
-    <command detect_errors="aggressive">
-        <![CDATA[
-        Rscript
-        ${__tool_directory__}/mixomics_plotvar_script.R
+        @COMMAND_RSCRIPT@/mixomics_plotvar.R
+
         --input_rdata $input_rdata
+
         $adv.legend
         --cutoff $adv.cutoff
+
         --output_pdf $output_pdf
-        ]]>
-    </command>
+
+        @COMMAND_LOG_EXIT@
+
+    ]]></command>
 
     <inputs>
         <param name="input_rdata" type="data" format="rdata"
@@ -46,22 +49,9 @@
         </test>
     </tests>
 
-    <help>
-        <![CDATA[
-.. class:: infomark
-
-**Authors** Pierre Pericard (pierre.pericard@pasteur-lille.fr)
-
----------------------------------------------------
+    <help><![CDATA[
 
-.. class:: infomark
-
-**Please cite**
-
-Rohart F, Gautier B, Singh A, Lê Cao KA (2017) mixOmics: An R package for ‘omics feature selection and multiple data integration.
-PLOS Computational Biology 13(11): e1005752. https://doi.org/10.1371/journal.pcbi.1005752
-
----------------------------------------------------
+@HELP_AUTHORS@
 
 ================
 mixOmics plotVar
@@ -74,6 +64,20 @@
 The plotVar function is part of the mixOmics package for exploration and integration of Omics datasets.
 Provides variables representation for (regularized) CCA, (sparse) PLS regression, PCA and (sparse) Regularized generalised CCA.
 
+-----------------
+Workflow position
+-----------------
+
+**Upstream tools**
+
+======================= =================================== ========
+Name                    Output file                         Format
+======================= =================================== ========
+mixOmics.block.splsda   mixomics_blocksplsda_output.RData   rdata
+======================= =================================== ========
+
+---------------------------------------------------
+
 -----------
 Input files
 -----------
@@ -95,18 +99,18 @@
 
 Cut-off
 
+
+@HELP_MANUAL@
+
 ------------
 Output files
 ------------
 
-plotIndiv.pdf
-    A pdf file with scatter plots for individuals
+plotVar.pdf
+    A pdf file with scatter plots for variables
 
-        ]]>
-    </help>
+    ]]></help>
 
-    <citations>
-        <citation type="doi">10.1371/journal.pcbi.1005752</citation>
-    </citations>
+    <expand macro="citations" />
 
 </tool>
\ No newline at end of file
--- a/mixomics_plotvar_script.R	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-#!/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")
-
-## Main Function ##
-
-suppressPackageStartupMessages(require(argparse))
-
-parser <- ArgumentParser(description='Run the mixOmics plotVar function')
-
-parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
-parser$add_argument('--legend', dest='legend', action="store_true", help="Display the legend")
-parser$add_argument('--cutoff', dest='cutoff', type='double', required=TRUE, help="Cutoff (0..1)")
-parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file")
-
-args <- parser$parse_args()
-
-##
-print("Input RData:")
-print(args$input_rdata)
-print("Plot legend:")
-print(args$legend)
-print("Cutoff:")
-print(args$cutoff)
-print("Output PDF file:")
-print(args$output_pdf)
-
-# loading libraries
-suppressPackageStartupMessages(require(mixOmics))
-
-load(args$input_rdata)
-
-pdf(args$output_pdf, width=8, height=7)
-mar = c(5, 5, 2, 8)
-par(mar = mar)
-
-# plotVar(mixomics_result,
-#         legend = args$legend,
-#         cutoff = args$cutoff)
-
-for(k in 1:(length(mixomics_result$names[[3]])-1))
-{
-    name_block = mixomics_result$names[[3]][k]
-
-    # We're still continuing even if a graph is empty
-    try(plotVar(mixomics_result,
-                blocks = k,
-                legend = args$legend,
-                cutoff = args$cutoff),
-        silent = FALSE)
-
-}
-
-dev.off()
\ No newline at end of file
--- a/networkVar.xml	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-<tool id="networkVar" name="networkVar" version="0.6+galaxy0" profile="16.04" workflow_compatible="true">
-
-    <description>creates a network between selected variables of datasets and the response variables. In the network, the similarity between two variables is associated with the link between these two variables.</description>
-
-    <requirements>
-        <requirement type="package" version="0.6">r-viscorvar</requirement>
-        <requirement type="package" version="2.0">r-argparse</requirement>
-    </requirements>
-
-    <stdio>
-        <!-- <exit_code range="1:" level="fatal" /> -->
-    </stdio>
-
-    <command detect_errors="aggressive">
-        <![CDATA[
-        Rscript
-        ${__tool_directory__}/networkVar_wrapper.R
-        --mat_similarity_rdata ${mat_similarity_rdata}
-        --var_list_file ${var_list_file}
-        --response_var ${select_response_var}
-        --output_graph ${output_graph}
-        ]]>
-    </command>
-
-    <inputs>
-        <param name="mat_similarity_rdata" type="data" format="rdata"
-               label="Input computeMatSimilarity RData file"
-               help="output RData file from computeMatSimilarity"/>
-        <param name="var_list_file" type="data" format="tabular"
-               label="Variables list file"
-               help="selected variables output tabular file from circleCor"/>
-
-        <!-- Fichier avec noms de gènes/variables, donné par l'utilisateur -->
-        <!-- <param name="var_of_interest_file" type="data" format="txt" optional="true"
-               label="Variables of interest (Optional)"
-               help="these variables have to belong to datasets that can be superimposed"/> -->
-
-        <param name="response_var_list" type="data" format="tabular"
-               label="List of response variables"
-               help="output *_response_var.tsv file from matCorAddVar"/>
-        <param name="select_response_var" type="select" display="checkboxes" multiple="true"
-               label="Response variables"
-               help="response variables that will be plotted in the network">
-        <!-- <param name="select_responses_var" type="select" multiple="true" label="Response variables"> -->
-            <options from_dataset="response_var_list">
-                <column name="value" index="0"/>
-                <filter type="unique_value" column="0"/>
-                <filter type="sort_by" name="sorted_value" column="0"/>
-            </options>
-        </param>
-    </inputs>
-
-    <outputs>
-        <data name="output_graph" format="xml" label="${tool.name}_graph.graphml" />
-    </outputs>
-
-    <tests>
-    </tests>
-
-    <help>
-    </help>
-
-</tool>
\ No newline at end of file
--- a/networkVar_wrapper.R	Thu Oct 15 12:22:25 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-#!/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='Run the networkVar function')
-
-parser$add_argument('--mat_similarity_rdata', dest='mat_similarity_rdata', required=TRUE, help="matSimilarity RData file")
-parser$add_argument('--var_list_file', dest='var_list_file', required=TRUE, help="Variables list file")
-# parser$add_argument('--interest_var_file', dest='interest_var_file', required=FALSE, help="Variables of interest file")
-parser$add_argument('--response_var', dest='response_var', required=TRUE, help="Response variables")
-parser$add_argument('--output_graph', dest='output_graph', required=TRUE, help="Output graphml")
-
-args <- parser$parse_args()
-
-## Print parameters
-print("matSimilarity RData file:")
-print(args$mat_similarity_rdata)
-print("Variables list file:")
-print(args$var_list_file)
-# print("Variables of interest:")
-# print(args$interest_var_file)
-print("Response variables:")
-print(args$response_var)
-print("Output graphml:")
-print(args$output_graph)
-
-## Loading libraries
-# suppressPackageStartupMessages(require(mixOmics))
-suppressPackageStartupMessages(require(igraph))
-
-# 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("mixomics-blocksplsda-integration/integration_block_splsda_func.R")
-install.packages("https://gitlab.com/bilille/mixomics-blocksplsda-integration/-/raw/master/visCorVar_0.5.tar.gz", repos=NULL)
-suppressPackageStartupMessages(require(visCorVar))
-print("visCorVar has been loaded")
-
-# Loading input Rdata file
-# loads res_compute_mat_similarity object
-load(args$mat_similarity_rdata)
-
-#
-names_block_variables = as.character(read.table(args$var_list_file, header=FALSE)[[1]])
-names_response_variables = strsplit(args$response_var, ",")[[1]]
-
-# interest_var_vec = NULL
-# if (args$interest_var_file != 'None') {
-#     interest_var_vec = as.character(read.table(args$interest_var_file, header=FALSE)[[1]])
-# }
-
-print("names_block_variables:")
-print(names_block_variables)
-# print("interest_var_vec:")
-# print(interest_var_vec)
-print("names_response_variables:")
-print(names_response_variables)
-
-res_networkVar = networkVar(res_compute_mat_similarity = res_compute_mat_similarity,
-                            names_block_variables = names_block_variables,
-                            names_response_variables = names_response_variables,
-                            cutoff = 0)
-
-print("networkVar() completed")
-print("res_networkVar:")
-print(res_networkVar)
-
-write.graph(res_networkVar$gR, file = args$output_graph, format = "graphml")
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viscorvar_circlecor.R	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,123 @@
+#!/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='Run the circleCor function')
+
+parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
+parser$add_argument('--blocks_vec', dest='blocks_vec', required=TRUE, help="Blocks vector")
+parser$add_argument('--responses_var', dest='responses_var', required=TRUE, help="Responses variables")
+parser$add_argument('--x_min', dest='x_min', type='double', required=TRUE, help="X min")
+parser$add_argument('--x_max', dest='x_max', type='double', required=TRUE, help="X max")
+parser$add_argument('--y_min', dest='y_min', type='double', required=TRUE, help="Y min")
+parser$add_argument('--y_max', dest='y_max', type='double', required=TRUE, help="Y max")
+parser$add_argument('--output_var', dest='output_var', required=TRUE, help="Output variables file")
+parser$add_argument('--output_pdf', dest='output_pdf', required=TRUE, help="Output PDF file")
+
+args <- parser$parse_args()
+
+## Print parameters
+print("Input RData:")
+print(args$input_rdata)
+print("Blocks vector:")
+print(args$blocks_vec)
+print("Response variables:")
+print(args$responses_var)
+print("X min:")
+print(args$x_min)
+print("X max:")
+print(args$x_max)
+print("Y min:")
+print(args$y_min)
+print("Y max:")
+print(args$y_max)
+print("Output variables file:")
+print(args$output_var)
+print("Output PDF file:")
+print(args$output_pdf)
+
+names_blocks = strsplit(args$blocks_vec, ",")[[1]]
+names_response_variables = strsplit(args$responses_var, ",")[[1]]
+
+print("names_blocks:")
+print(names_blocks)
+print("names_response_variables:")
+print(names_response_variables)
+
+## Loading libraries
+suppressPackageStartupMessages(require(visCorVar))
+
+# 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 input Rdata file
+# loads res_matCorAddVar object
+load(args$input_rdata)
+
+mat_cor_comp1 = res_matCorAddVar$mat_cor_comp1
+mat_cor_comp2 = res_matCorAddVar$mat_cor_comp2
+cutoff_comp = res_matCorAddVar$cutoff_comp
+comp = res_matCorAddVar$comp
+list_vec_index_block_select  = res_matCorAddVar$list_vec_index_block_select
+list_vec_names_blocks = res_matCorAddVar$list_vec_names_blocks
+list_cor_comp_selected_var_resp_var = res_matCorAddVar$list_cor_comp_selected_var_resp_var
+res_compute_cor_var_interest = res_matCorAddVar$res_compute_cor_var_interest
+res_block_splsda = res_matCorAddVar$res_block_splsda
+
+#
+print("mat_cor_comp1:")
+print(mat_cor_comp1)
+print("mat_cor_comp2:")
+print(mat_cor_comp2)
+print("cutoff_comp:")
+print(cutoff_comp)
+print("comp:")
+print(comp)
+print("list_vec_index_block_select:")
+print(list_vec_index_block_select)
+print("list_vec_names_blocks:")
+print(list_vec_names_blocks)
+print("list_cor_comp_selected_var_resp_var:")
+print(list_cor_comp_selected_var_resp_var)
+print("res_compute_cor_var_interest:")
+print(res_compute_cor_var_interest)
+
+# Open output pdf file
+pdf(args$output_pdf, width=8, height=7)
+mar = c(5, 5, 2, 8)
+par(mar = mar)
+
+selected_variables = circleCor(list_dataframe_cor_comp_var_global = list_cor_comp_selected_var_resp_var,
+                               list_vec_index_block_select = list_vec_index_block_select,
+                               mat_cor_comp1 = mat_cor_comp1,
+                               mat_cor_comp2 = mat_cor_comp2,
+                               names_blocks = names_blocks,
+                               names_response_variables = names_response_variables,
+                               comp = comp,
+                               cutoff = 0.80,
+                               min.X = args$x_min,
+                               max.X = args$x_max,
+                               min.Y = args$y_min,
+                               max.Y = args$y_max,
+                               # vec_col = vec_col,
+                               rad.in = 0.5,
+                               cex = 0.7,
+                               cex_legend = 0.8,
+                               pos = c(1.2, 0),
+                               pch = 20)
+
+dev.off()
+
+write(selected_variables, file=args$output_var, ncolumns=1)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viscorvar_circlecor.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,150 @@
+<tool id="viscorvar_circlecor" name="visCorVar circleCor" version="@TOOL_VERSION@+galaxy1" profile="16.04" workflow_compatible="true">
+
+    <description>plots a correlation circle for the datasets whose correlation circles can be superimposed. This correlation circle contains the selected variables of these datasets which are included in a rectangle and the response variables.</description>
+
+    <macros>
+        <import>macros.xml</import>
+        <import>macros_viscorvar.xml</import>
+    </macros>
+
+    <expand macro="requirements"/>
+    <expand macro="stdio"/>
+
+    <command detect_errors="aggressive"><![CDATA[
+
+        @COMMAND_RSCRIPT@/viscorvar_circlecor.R
+
+        --input_rdata ${input_rdata}
+
+        --blocks_vec ${select_blocks.value}
+        --responses_var ${select_responses_var}
+        --x_min ${x_min}
+        --x_max ${x_max}
+        --y_min ${y_min}
+        --y_max ${y_max}
+
+        --output_var ${output_var}
+        --output_pdf ${output_pdf}
+
+        @COMMAND_LOG_EXIT@
+
+    ]]></command>
+
+    <inputs>
+        <param name="input_rdata" type="data" format="rdata"
+               label="Input RData file"
+               help="output RData from matCorAddVar"/>
+        <param name="blocks_vec_list" type="data" format="tabular"
+               label="List of blocks vector."
+               help="output *_blocks_comb.tsv file from matCorAddVar"/>
+        <param name="select_blocks" type="select"
+               label="Blocks"
+               help="list of the blocks that are to be superimposed">
+            <options from_dataset="blocks_vec_list">
+                <column name="value" index="0"/>
+                <filter type="unique_value" column="0"/>
+                <filter type="sort_by" name="sorted_value" column="0"/>
+            </options>
+        </param>
+        <param name="responses_var_list" type="data" format="tabular"
+               label="List of response variables"
+               help="output *_response_var.tsv file from matCorAddVar"/>
+        <param name="select_responses_var" type="select" display="checkboxes"
+               multiple="true" label="Response variables"
+               help="select the response variables which will be plotted in the correlation circle">
+        <!-- <param name="select_responses_var" type="select" multiple="true" label="Response variables"> -->
+            <options from_dataset="responses_var_list">
+                <column name="value" index="0"/>
+                <filter type="unique_value" column="0"/>
+                <filter type="sort_by" name="sorted_value" column="0"/>
+            </options>
+        </param>
+        <param name="x_min" type="float" value="-1" min="-1" max="1"
+               label="X min" help="" />
+        <param name="x_max" type="float" value="1" min="-1" max="1"
+               label="X max" help="" />
+        <param name="y_min" type="float" value="-1" min="-1" max="1"
+               label="Y min" help="" />
+        <param name="y_max" type="float" value="1" min="-1" max="1"
+               label="Y max" help="" />
+    </inputs>
+
+    <outputs>
+        <data name="output_var" format="tabular" label="${tool.name}_selected_var.tsv" />
+        <data name="output_pdf" format="pdf" label="${tool.name}.pdf" />
+    </outputs>
+
+    <tests>
+    </tests>
+
+    <help><![CDATA[
+
+@HELP_AUTHORS@
+
+===================
+visCorVar circleCor
+===================
+
+-----------
+Description
+-----------
+
+Bla bla...
+
+-----------------
+Workflow position
+-----------------
+
+**Upstream tools**
+
+======================== ===================================== ========
+Name                     Output file                           Format
+======================== ===================================== ========
+visCorVar.matCorAddVar   viscorvar_matcoraddvar_output.RData   rdata
+======================== ===================================== ========
+
+**Downstream tools**
+
+====================== ====================================== =========
+Name                   Output file                            Format
+====================== ====================================== =========
+visCorVar.networkVar   viscorvar_circlecor_selected_var.tsv   tabular
+====================== ====================================== =========
+
+---------------------------------------------------
+
+-----------
+Input files
+-----------
+
++-------------------------------------------------------+-----------+
+| Parameter : num + label                               |  Format   |
++=======================================================+===========+
+| 1 : Rdata visCorVar.matCorAddVar output               |  rdata    |
++-------------------------------------------------------+-----------+
+| 2 : \*_blocks_comb.tsv visCorVar.matCorAddVar output   |  tabular  |
++-------------------------------------------------------+-----------+
+| 3 : \*_response_var.tsv visCorVar.matCorAddVar output  |  tabular  |
++-------------------------------------------------------+-----------+
+
+----------
+Parameters
+----------
+
+@HELP_MANUAL@
+
+------------
+Output files
+------------
+
+viscorvar_circlecor.pdf
+    Correlation circle pdf file
+
+viscorvar_circlecor_selected_var.tsv
+	List of variables selected in the correlation circle
+
+    ]]></help>
+
+    <expand macro="citations" />
+
+</tool>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viscorvar_computematsimilarity.R	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,50 @@
+#!/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='Run the computeMatSimilarity function')
+
+parser$add_argument('--input_rdata', dest='input_rdata', required=TRUE, help="Input RData file")
+parser$add_argument('--output_rdata', dest='output_rdata', required=TRUE, help="Output RData file")
+
+args <- parser$parse_args()
+
+## Print parameters
+print("Input RData:")
+print(args$input_rdata)
+print("Output RData:")
+print(args$output_rdata)
+
+## 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
+suppressPackageStartupMessages(require(visCorVar))
+
+# Loading input Rdata file
+# loads res_matCorAddVar object
+load(args$input_rdata)
+
+# Run main function
+res_compute_mat_similarity = computeMatSimilarity(res_matCorAddVar = res_matCorAddVar)
+
+liste_mat_similarity_group  = res_compute_mat_similarity$liste_mat_similarity_group
+res_matCorAddVar = res_compute_mat_similarity$res_matCorAddVar
+
+save(res_compute_mat_similarity,
+     file = args$output_rdata)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viscorvar_computematsimilarity.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,101 @@
+<tool id="viscorvar_computematsimilarity" name="visCorVar computeMatSimilarity" version="@TOOL_VERSION@+galaxy1" profile="16.04" workflow_compatible="true">
+
+    <description>performs the computation of the similarities. The similarity between two variables is an approximation of the correlation between these two variables.</description>
+
+    <macros>
+        <import>macros.xml</import>
+        <import>macros_viscorvar.xml</import>
+    </macros>
+
+    <expand macro="requirements"/>
+    <expand macro="stdio"/>
+
+    <command detect_errors="aggressive"><![CDATA[
+
+        @COMMAND_RSCRIPT@/viscorvar_computematsimilarity.R
+
+        --input_rdata ${input_rdata}
+        
+        --output_rdata ${output_rdata}
+
+        @COMMAND_LOG_EXIT@
+
+    ]]></command>
+
+    <inputs>
+        <param name="input_rdata" type="data" format="rdata"
+               label="Input RData file"
+               help="output RData file from matCorAddVar"/>
+    </inputs>
+
+    <outputs>
+        <data name="output_rdata" format="rdata" label="${tool.name}_output.RData" />
+    </outputs>
+
+    <tests>
+    </tests>
+
+    <help><![CDATA[
+
+@HELP_AUTHORS@
+
+==============================
+visCorVar computeMatSimilarity
+==============================
+
+-----------
+Description
+-----------
+
+Bla bla...
+
+-----------------
+Workflow position
+-----------------
+
+**Upstream tools**
+
+======================== ===================================== ========
+Name                     Output file                           Format
+======================== ===================================== ========
+visCorVar.matCorAddVar   viscorvar_matcoraddvar_output.RData   rdata
+======================== ===================================== ========
+
+**Downstream tools**
+
+====================== ============================================= ========
+Name                   Output file                                   Format
+====================== ============================================= ========
+visCorVar.networkVar   viscorvar_computematsimilarity_output.RData   rdata
+====================== ============================================= ========
+
+---------------------------------------------------
+
+-----------
+Input files
+-----------
+
++------------------------------------------+------------+
+| Parameter : num + label                  |   Format   |
++==========================================+============+
+| 1 : Rdata visCorVar.matCorAddVar output  |   Rdata    |
++------------------------------------------+------------+
+
+----------
+Parameters
+----------
+
+@HELP_MANUAL@
+
+------------
+Output files
+------------
+
+viscorvar_computematsimilarity_output.RData
+    RData output
+
+    ]]></help>
+
+    <expand macro="citations" />
+
+</tool>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viscorvar_matcoraddvar.R	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,112 @@
+#!/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('--interest_var_file', dest='interest_var_file', required=FALSE, help="Variables of interest file")
+parser$add_argument('--block_Y_file', dest='block_Y_file', required=TRUE, help="Block Y filepath")
+parser$add_argument('--output_rdata', dest='output_rdata', required=TRUE, help="Output RData file")
+parser$add_argument('--output_response_var', dest='output_response_var', required=TRUE, help="Output response variables 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("Variables of interest:")
+print(args$interest_var_file)
+print("Block Y file:")
+print(args$block_Y_file)
+print("Output RData:")
+print(args$output_rdata)
+print("Output Response variables:")
+print(args$output_response_var)
+print("Output Blocks combinations:")
+print(args$output_blocks_comb)
+
+## Loading libraries
+suppressPackageStartupMessages(require(visCorVar))
+
+# 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 input Rdata file
+load(args$input_rdata)
+
+ncomp = mixomics_result$ncomp
+
+# Reading Block Y matrix
+print("Reading Block Y")
+mat_block_Y = read.table(args$block_Y_file, header=TRUE, row.names=1)
+print(mat_block_Y)
+
+response_var = colnames(mat_block_Y)
+
+print("response_var:")
+print(response_var)
+
+# Write response variables to output file
+invisible(lapply(response_var, write, file=args$output_response_var, append=TRUE, ncolumns=1))
+
+# Reading var of intereset file
+interest_var_vec = NULL
+if (args$interest_var_file != 'None') {
+    interest_var_vec = as.character(read.table(args$interest_var_file, header=FALSE)[[1]])
+}
+
+#
+comp = 1:2
+
+# Running main function
+res_matCorAddVar = matCorAddVar(res_block_splsda = mixomics_result,
+                                block_Y = mat_block_Y,
+                                cutoff_comp = args$cutoff_comp,
+                                var_interest = interest_var_vec,
+                                comp = comp)
+
+#
+mat_cor_comp1 = res_matCorAddVar$mat_cor_comp1
+mat_cor_comp2 = res_matCorAddVar$mat_cor_comp2
+list_vec_index_block_select  = res_matCorAddVar$list_vec_index_block_select
+list_vec_names_blocks = res_matCorAddVar$list_vec_names_blocks
+list_cor_comp_selected_var_resp_var = res_matCorAddVar$list_cor_comp_selected_var_resp_var
+res_compute_cor_var_interest = res_matCorAddVar$res_compute_cor_var_interest
+
+#
+print("mat_cor_comp1:")
+print(mat_cor_comp1)
+print("mat_cor_comp2:")
+print(mat_cor_comp2)
+print("list_vec_index_block_select:")
+print(list_vec_index_block_select)
+print("list_vec_names_blocks:")
+print(list_vec_names_blocks)
+print("list_cor_comp_selected_var_resp_var:")
+print(list_cor_comp_selected_var_resp_var)
+print("res_compute_cor_var_interest:")
+print(res_compute_cor_var_interest)
+
+# Write all possible blocks combinations to output file
+invisible(lapply(list_vec_names_blocks, write, file=args$output_blocks_comb, append=TRUE, ncolumns=100, sep=","))
+
+# Save all objects in Rdata output file
+save(res_matCorAddVar,
+     file = args$output_rdata)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viscorvar_matcoraddvar.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,136 @@
+<tool id="viscorvar_matcoraddvar" name="visCorVar matCorAddVar" version="@TOOL_VERSION@+galaxy1" profile="16.04" workflow_compatible="true">
+
+    <description>determine the correlation circles that can be overlaid and compute the correlations</description>
+
+    <macros>
+        <import>macros.xml</import>
+        <import>macros_viscorvar.xml</import>
+    </macros>
+
+    <expand macro="requirements"/>
+    <expand macro="stdio"/>
+
+    <command detect_errors="aggressive"><![CDATA[
+
+        @COMMAND_RSCRIPT@/viscorvar_matcoraddvar.R
+
+        --input_rdata ${input_rdata}
+        --block_Y_file ${block_Y}
+
+        ##--cutoff_comp ${cutoff_comp}
+        --cutoff_comp 0.75
+        #if str($var_of_interest_file) !='':
+            --interest_var_file ${var_of_interest_file}
+        #end if
+
+        --output_rdata ${output_rdata}
+        --output_response_var ${output_response_var}
+        --output_blocks_comb ${output_blocks_comb}
+
+        @COMMAND_LOG_EXIT@
+
+    ]]></command>
+
+    <inputs>
+        <param name="input_rdata" type="data" format="rdata"
+               label="Input RData file from block.SPLSDA"
+               help="This is the RData output file from the block.splsda function." />
+        <param name="block_Y" type="data" format="tabular"
+               label="Block Y"
+               help="[block_Y] (tabular format) This table contains the name of the samples in the first column. The other columns correspond to phenotypes. For each of these other columns, a column determines which sample is associated with this phenotype (value equals to 1) or not (value equals to 0). The name of the samples in Block Y (transposed), in the sample metadata (transposed) and for all datasets have to be in the same order" />
+        <!-- Fichier avec noms de gènes/variables, donné par l'utilisateur -->
+        <param name="var_of_interest_file" type="data" format="txt" optional="true"
+               label="Variables of interest (Optional)"
+               help="variables not belonging to any block will not be considered"/>
+        <!-- <param name="cutoff_comp" type="float" value="0.775" min="0" max="1"
+               label="Cutoff comp"
+               help="[cutoff_comp] Two correlation circles will be superimposed if the correlation of their first and second axis is greater than cutoff_comp in absolute value." /> -->
+    </inputs>
+
+    <outputs>
+        <data name="output_rdata" format="rdata" label="${tool.name}_output.RData" />
+        <data name="output_response_var" format="tabular" label="${tool.name}_response_var.tsv" />
+        <data name="output_blocks_comb" format="tabular" label="${tool.name}_blocks_comb.tsv" />
+    </outputs>
+
+    <tests>
+    </tests>
+
+    <help><![CDATA[
+
+@HELP_AUTHORS@
+
+======================
+visCorVar matCorAddVar
+======================
+
+-----------
+Description
+-----------
+
+Bla bla...
+
+-----------------
+Workflow position
+-----------------
+
+**Upstream tools**
+
+======================= =================================== ========
+Name                    Output file                         Format
+======================= =================================== ========
+mixOmics.block.splsda   mixomics_blocksplsda_output.RData   rdata
+======================= =================================== ========
+
+**Downstream tools**
+
+================================ ========================================= ========
+Name                             Output file                               Format
+================================ ========================================= ========
+visCorVar.circleCor              viscorvar_matcoraddvar_output.RData       rdata
+-------------------------------- ----------------------------------------- --------
+visCorVar.computeMatSimilarity   viscorvar_matcoraddvar_output.RData       rdata
+-------------------------------- ----------------------------------------- --------
+visCorVar.networkVar             viscorvar_matcoraddvar_response_var.tsv   tabular
+================================ ========================================= ========
+
+---------------------------------------------------
+
+-----------
+Input files
+-----------
+
++---------------------------------+------------+
+| Parameter : num + label         |   Format   |
++=================================+============+
+| 1 : Rdata block.splsda output   |   Rdata    |
++---------------------------------+------------+
+| 2 : Block Y                     |   tabular  |
++---------------------------------+------------+
+| 3 : [opt] Variables of interest |   txt      |
++---------------------------------+------------+
+
+----------
+Parameters
+----------
+
+@HELP_MANUAL@
+
+------------
+Output files
+------------
+
+viscorvar_matcoraddvar_output.RData
+    RData output
+
+viscorvar_matcoraddvar_response_var.tsv
+
+
+viscorvar_matcoraddvar_blocks_comb.tsv
+
+
+    ]]></help>
+
+    <expand macro="citations" />
+
+</tool>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viscorvar_networkvar.R	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,78 @@
+#!/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='Run the networkVar function')
+
+parser$add_argument('--mat_similarity_rdata', dest='mat_similarity_rdata', required=TRUE, help="matSimilarity RData file")
+parser$add_argument('--var_list_file', dest='var_list_file', required=TRUE, help="Variables list file")
+# parser$add_argument('--interest_var_file', dest='interest_var_file', required=FALSE, help="Variables of interest file")
+parser$add_argument('--response_var', dest='response_var', required=TRUE, help="Response variables")
+parser$add_argument('--output_graph', dest='output_graph', required=TRUE, help="Output graphml")
+
+args <- parser$parse_args()
+
+## Print parameters
+print("matSimilarity RData file:")
+print(args$mat_similarity_rdata)
+print("Variables list file:")
+print(args$var_list_file)
+# print("Variables of interest:")
+# print(args$interest_var_file)
+print("Response variables:")
+print(args$response_var)
+print("Output graphml:")
+print(args$output_graph)
+
+## Loading libraries
+# suppressPackageStartupMessages(require(mixOmics))
+suppressPackageStartupMessages(require(igraph))
+
+# 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
+suppressPackageStartupMessages(require(visCorVar))
+
+# Loading input Rdata file
+# loads res_compute_mat_similarity object
+load(args$mat_similarity_rdata)
+
+#
+names_block_variables = as.character(read.table(args$var_list_file, header=FALSE)[[1]])
+names_response_variables = strsplit(args$response_var, ",")[[1]]
+
+# interest_var_vec = NULL
+# if (args$interest_var_file != 'None') {
+#     interest_var_vec = as.character(read.table(args$interest_var_file, header=FALSE)[[1]])
+# }
+
+print("names_block_variables:")
+print(names_block_variables)
+# print("interest_var_vec:")
+# print(interest_var_vec)
+print("names_response_variables:")
+print(names_response_variables)
+
+res_networkVar = networkVar(res_compute_mat_similarity = res_compute_mat_similarity,
+                            names_block_variables = names_block_variables,
+                            names_response_variables = names_response_variables,
+                            cutoff = 0)
+
+print("networkVar() completed")
+print("res_networkVar:")
+print(res_networkVar)
+
+write.graph(res_networkVar$gR, file = args$output_graph, format = "graphml")
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viscorvar_networkvar.xml	Fri Oct 23 10:15:56 2020 +0000
@@ -0,0 +1,125 @@
+<tool id="viscorvar_networkvar" name="visCorVar networkVar" version="@TOOL_VERSION@+galaxy1" profile="16.04" workflow_compatible="true">
+
+    <description>creates a network between selected variables of datasets and the response variables. In the network, the similarity between two variables is associated with the link between these two variables.</description>
+
+    <macros>
+        <import>macros.xml</import>
+        <import>macros_viscorvar.xml</import>
+    </macros>
+
+    <expand macro="requirements"/>
+    <expand macro="stdio"/>
+
+    <command detect_errors="aggressive"><![CDATA[
+
+        @COMMAND_RSCRIPT@/viscorvar_networkvar.R
+
+        --mat_similarity_rdata ${mat_similarity_rdata}
+        --var_list_file ${var_list_file}
+        --response_var ${select_response_var}
+
+        --output_graph ${output_graph}
+
+        @COMMAND_LOG_EXIT@
+
+    ]]></command>
+
+    <inputs>
+        <param name="mat_similarity_rdata" type="data" format="rdata"
+               label="Input computeMatSimilarity RData file"
+               help="output RData file from computeMatSimilarity"/>
+        <param name="var_list_file" type="data" format="tabular"
+               label="Variables list file"
+               help="selected variables output tabular file from circleCor"/>
+
+        <!-- Fichier avec noms de gènes/variables, donné par l'utilisateur -->
+        <!-- <param name="var_of_interest_file" type="data" format="txt" optional="true"
+               label="Variables of interest (Optional)"
+               help="these variables have to belong to datasets that can be superimposed"/> -->
+
+        <param name="response_var_list" type="data" format="tabular"
+               label="List of response variables"
+               help="output *_response_var.tsv file from matCorAddVar"/>
+        <param name="select_response_var" type="select" display="checkboxes" multiple="true"
+               label="Response variables"
+               help="response variables that will be plotted in the network">
+        <!-- <param name="select_responses_var" type="select" multiple="true" label="Response variables"> -->
+            <options from_dataset="response_var_list">
+                <column name="value" index="0"/>
+                <filter type="unique_value" column="0"/>
+                <filter type="sort_by" name="sorted_value" column="0"/>
+            </options>
+        </param>
+    </inputs>
+
+    <outputs>
+        <data name="output_graph" format="xml" label="${tool.name}_graph.graphml" />
+    </outputs>
+
+    <tests>
+    </tests>
+
+    <help><![CDATA[
+
+@HELP_AUTHORS@
+
+====================
+visCorVar networkVar
+====================
+
+-----------
+Description
+-----------
+
+Bla bla...
+
+-----------------
+Workflow position
+-----------------
+
+**Upstream tools**
+
+================================ ============================================= =========
+Name                             Output file                                   Format
+================================ ============================================= =========
+visCorVar.computeMatSimilarity   viscorvar_computematsimilarity_output.RData   rdata
+-------------------------------- --------------------------------------------- ---------
+visCorVar.circleCor              viscorvar_circlecor_selected_var.tsv          tabular
+-------------------------------- --------------------------------------------- ---------
+visCorVar.matCorAddVar           viscorvar_matcoraddvar_response_var.tsv       tabular
+================================ ============================================= =========
+
+---------------------------------------------------
+
+-----------
+Input files
+-----------
+
++-------------------------------------------------------+------------+
+| Parameter : num + label                               |   Format   |
++=======================================================+============+
+| 1 : Rdata visCorVar.computeMatSimilarity output       |   rdata    |
++-------------------------------------------------------+------------+
+| 2 : *_selected_var.tsv visCorVar.circleCor output     |   tabular  |
++-------------------------------------------------------+------------+
+| 3 : *_response_var.tsv visCorVar.matCorAddVar output  |   tabular  |
++-------------------------------------------------------+------------+
+
+----------
+Parameters
+----------
+
+@HELP_MANUAL@
+
+------------
+Output files
+------------
+
+viscorvar_networkvar_graph.graphml
+	GraphML file
+
+    ]]></help>
+
+    <expand macro="citations" />
+
+</tool>
\ No newline at end of file