changeset 1:e93350dc99f1 draft

"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 1eda261d4fe137d6e8806b0c6af7eaf12d11ac95"
author ppericard
date Thu, 15 Oct 2020 12:22:25 +0000
parents d0b77b926863
children c8533e9298e5
files additional_functions_block_splsda.R circleCor.xml circleCor_wrapper.R computeMatSimilarity.xml computeMatSimilarity_wrapper.R matCorAddVar.xml matCorAddVar_wrapper.R mixomics_blocksplsda.xml mixomics_blocksplsda_script.R mixomics_plotindiv.xml mixomics_plotindiv_script.R mixomics_plotvar.xml mixomics_plotvar_script.R networkVar.xml networkVar_wrapper.R
diffstat 15 files changed, 70 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/additional_functions_block_splsda.R	Tue Jun 23 19:57:35 2020 -0400
+++ b/additional_functions_block_splsda.R	Thu Oct 15 12:22:25 2020 +0000
@@ -1,55 +1,3 @@
-#' @title Check if a block contains missing values
-#' @description Check if a block contains missing values
-#' @param list_X type : list of matrix. This list is used to perform the data integration.
-#' @details This function checks if a block contains missing values.
-#' @return  type : boolean. If at least one block contains missing values, 
-#' this function returns TRUE, otherwise this function returns FALSE.
-#' @examples 
-#' X1 = matrix(1:9, nrow = 3, ncol = 3)
-#' X2 = matrix(10:18, nrow = 3, ncol = 3)
-#' list_X = list()
-#' list_X[[1]] = X1
-#' list_X[[2]] = X2
-#' names(list_X) = c("X1", "X2")
-#' boolean_block_missing_values = blockMissingValues(list_X)
-#' @export
-blockMissingValues <-function(list_X)
-{
-  name_blocks = names(list_X)
-  name_blocks_missing_values = c()
-  boolean_block_missing_values = FALSE 
-  
-  for(i in 1:length(list_X))
-  {
-    X_i = list_X[[i]]
-    name_block_i = name_blocks[i]
-    
-    vec = sapply(1:dim(X_i)[2], FUN = function(j){
-      res = any(is.na(X_i[, j]))
-      
-      return(res)
-    })
-    
-    if(any(vec))
-    {
-      name_blocks_missing_values = c(name_blocks_missing_values, name_block_i)
-      
-    }
-    
-  } # End for(i in 1:length(list_X)).
-  
-  if(length(name_blocks_missing_values) != 0)
-  {
-    stop(paste("The data integration can not be performed if a block contains missing values  : ", paste(name_blocks_missing_values, collapse = ", "), " contains missing values. "))
-    boolean_block_missing_values = TRUE
-    
-  }
-  
-  return(boolean_block_missing_values)  
-  
-}
-
-
 #' @title Determination of selected variables for all components
 #' @description The function unionSelectBlockVariables determines, for each block, the selected block variables
 #' for all components.
--- a/circleCor.xml	Tue Jun 23 19:57:35 2020 -0400
+++ b/circleCor.xml	Thu Oct 15 12:22:25 2020 +0000
@@ -1,14 +1,10 @@
-<tool id="circleCor" name="circleCor" version="1.0" profile="16.04" workflow_compatible="true">
+<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="6.12">bioconductor-mixomics</requirement> <!-- Remove when viscorvar is available via conda -->
-        <!-- <requirement type="package" version="0.4">r-ellipse</requirement> -->
+        <requirement type="package" version="0.6">r-viscorvar</requirement>
         <requirement type="package" version="2.0">r-argparse</requirement>
-        <!-- <requirement type="package" version="1.1">r-rcolorbrewer</requirement> -->
-
-        <!-- <requirement type="package" version="6.8">bioconductor-mixomics</requirement> -->
     </requirements>
 
     <stdio>
--- a/circleCor_wrapper.R	Tue Jun 23 19:57:35 2020 -0400
+++ b/circleCor_wrapper.R	Thu Oct 15 12:22:25 2020 +0000
@@ -58,7 +58,7 @@
 # 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.3.tar.gz", repos=NULL)
+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")
 
@@ -102,7 +102,7 @@
 print("res_compute_cor_var_interest:")
 print(res_compute_cor_var_interest)
 
-# Open output pdf file 
+# Open output pdf file
 pdf(args$output_pdf, width=8, height=7)
 mar = c(5, 5, 2, 8)
 par(mar = mar)
@@ -114,7 +114,7 @@
                                names_blocks = names_blocks,
                                names_response_variables = names_response_variables,
                                comp = comp,
-                               cutoff = 0.85,
+                               cutoff = 0.80,
                                min.X = args$x_min,
                                max.X = args$x_max,
                                min.Y = args$y_min,
--- a/computeMatSimilarity.xml	Tue Jun 23 19:57:35 2020 -0400
+++ b/computeMatSimilarity.xml	Thu Oct 15 12:22:25 2020 +0000
@@ -1,9 +1,9 @@
-<tool id="computeMatSimilarity" name="computeMatSimilarity" version="1.0" profile="16.04" workflow_compatible="true">
+<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="6.12">bioconductor-mixomics</requirement> <!-- Remove when viscorvar is available via conda -->
+        <requirement type="package" version="0.6">r-viscorvar</requirement>
         <requirement type="package" version="2.0">r-argparse</requirement>
     </requirements>
 
--- a/computeMatSimilarity_wrapper.R	Tue Jun 23 19:57:35 2020 -0400
+++ b/computeMatSimilarity_wrapper.R	Thu Oct 15 12:22:25 2020 +0000
@@ -35,7 +35,7 @@
 
 ## 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.3.tar.gz", repos=NULL)
+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")
 
--- a/matCorAddVar.xml	Tue Jun 23 19:57:35 2020 -0400
+++ b/matCorAddVar.xml	Thu Oct 15 12:22:25 2020 +0000
@@ -1,24 +1,23 @@
-<tool id="matCorAddVar" name="matCorAddVar" version="1.0" profile="16.04" workflow_compatible="true">
+<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="6.12">bioconductor-mixomics</requirement> <!-- Remove when viscorvar is available via conda -->
+        <requirement type="package" version="0.6">r-viscorvar</requirement>
         <requirement type="package" version="2.0">r-argparse</requirement>
-        <!-- <requirement type="package" version="0.3">viscorvar</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.775
+        --cutoff_comp 0.75
         #if str($var_of_interest_file) !='':
             --interest_var_file ${var_of_interest_file}
         #end if
@@ -39,7 +38,7 @@
         <!-- 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"/>
+               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." /> -->
--- a/matCorAddVar_wrapper.R	Tue Jun 23 19:57:35 2020 -0400
+++ b/matCorAddVar_wrapper.R	Thu Oct 15 12:22:25 2020 +0000
@@ -39,7 +39,7 @@
 
 ## 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.3.tar.gz", repos=NULL)
+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")
 
--- a/mixomics_blocksplsda.xml	Tue Jun 23 19:57:35 2020 -0400
+++ b/mixomics_blocksplsda.xml	Thu Oct 15 12:22:25 2020 +0000
@@ -1,4 +1,4 @@
-<tool id="mixomics_blocksplsda" name="mixOmics block.splsda" version="1.0" profile="16.04" workflow_compatible="true">
+<tool id="mixomics_blocksplsda" name="mixOmics block.splsda" version="6.12+galaxy0" 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>
 
@@ -41,7 +41,7 @@
         ##--tol ${adv.tol}
         ##${adv.nearzerovar}
         --rdata_out ${rdata_out}
-        --sample_metadata_out ${sample_metadata_out}
+        ##--sample_metadata_out ${sample_metadata_out}
         --variable_metadata_outdir outdir
         ]]>
     </command>
@@ -107,8 +107,8 @@
 
     <outputs>
         <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}" />
+        <!-- <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">
             <discover_datasets pattern="(?P&lt;designation&gt;.+)\.tsv"
                                directory="outdir" format="tabular" />
--- a/mixomics_blocksplsda_script.R	Tue Jun 23 19:57:35 2020 -0400
+++ b/mixomics_blocksplsda_script.R	Thu Oct 15 12:22:25 2020 +0000
@@ -36,7 +36,7 @@
 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('--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()
@@ -68,8 +68,8 @@
 print(args$nearzerovar)
 print("Output Rdata file:")
 print(args$rdata_out)
-print("Output sample metadata file:")
-print(args$sample_metadata_out)
+# print("Output sample metadata file:")
+# print(args$sample_metadata_out)
 print("Output variable metadata directory:")
 print(args$variable_metadata_outdir)
 
@@ -119,6 +119,11 @@
         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
@@ -175,26 +180,41 @@
 ## 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]])
+# 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]])
+#     # 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]])
-}
+#     # 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)
+# 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:")
@@ -210,11 +230,15 @@
 
     print(sprintf("Saving block %s output metavar", block_name))
 
-    meta_variable <- mixomics_result$loadings[[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 = "_")
+    # 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")
@@ -230,4 +254,4 @@
 
     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)
-}
\ No newline at end of file
+}
--- a/mixomics_plotindiv.xml	Tue Jun 23 19:57:35 2020 -0400
+++ b/mixomics_plotindiv.xml	Thu Oct 15 12:22:25 2020 +0000
@@ -1,4 +1,4 @@
-<tool id="mixomics_plotindiv" name="mixOmics plotIndiv" version="1.0" profile="16.04" workflow_compatible="true">
+<tool id="mixomics_plotindiv" name="mixOmics plotIndiv" version="6.12+galaxy0" 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>
 
--- a/mixomics_plotindiv_script.R	Tue Jun 23 19:57:35 2020 -0400
+++ b/mixomics_plotindiv_script.R	Thu Oct 15 12:22:25 2020 +0000
@@ -33,7 +33,9 @@
 
 load(args$input_rdata)
 
-pdf(args$output_pdf)
+pdf(args$output_pdf, width=8, height=7)
+mar = c(5, 5, 2, 8)
+par(mar = mar)
 
 # plotIndiv(mixomics_result,
 #           legend = args$legend,
--- a/mixomics_plotvar.xml	Tue Jun 23 19:57:35 2020 -0400
+++ b/mixomics_plotvar.xml	Thu Oct 15 12:22:25 2020 +0000
@@ -1,4 +1,4 @@
-<tool id="mixomics_plotvar" name="mixOmics plotVar" version="1.0" profile="16.04" workflow_compatible="true">
+<tool id="mixomics_plotvar" name="mixOmics plotVar" version="6.12+galaxy0" profile="16.04" workflow_compatible="true">
 
     <description>provides variables representation for (regularized) CCA, (sparse) PLS regression, PCA and (sparse) Regularized generalised CCA</description>
 
--- a/mixomics_plotvar_script.R	Tue Jun 23 19:57:35 2020 -0400
+++ b/mixomics_plotvar_script.R	Thu Oct 15 12:22:25 2020 +0000
@@ -34,7 +34,9 @@
 
 load(args$input_rdata)
 
-pdf(args$output_pdf)
+pdf(args$output_pdf, width=8, height=7)
+mar = c(5, 5, 2, 8)
+par(mar = mar)
 
 # plotVar(mixomics_result,
 #         legend = args$legend,
--- a/networkVar.xml	Tue Jun 23 19:57:35 2020 -0400
+++ b/networkVar.xml	Thu Oct 15 12:22:25 2020 +0000
@@ -1,10 +1,9 @@
-<tool id="networkVar" name="networkVar" version="1.0" profile="16.04" workflow_compatible="true">
+<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="6.12">bioconductor-mixomics</requirement> <!-- Remove when viscorvar is available via conda -->
-        <requirement type="package" version="1.2">r-igraph</requirement>
+        <requirement type="package" version="0.6">r-viscorvar</requirement>
         <requirement type="package" version="2.0">r-argparse</requirement>
     </requirements>
 
--- a/networkVar_wrapper.R	Tue Jun 23 19:57:35 2020 -0400
+++ b/networkVar_wrapper.R	Thu Oct 15 12:22:25 2020 +0000
@@ -45,7 +45,7 @@
 
 ## 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.3.tar.gz", repos=NULL)
+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")