# HG changeset patch # User ppericard # Date 1603448156 0 # Node ID c8533e9298e5fa8220b444c9c79751a4962ea02e # Parent e93350dc99f1f0644767575f1ff65b96f76928da "planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 8cb5630238352459037b3647eebfabb5554566f6-dirty" diff -r e93350dc99f1 -r c8533e9298e5 README.md --- 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: ```
-
``` -# 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) -``` - - - - - - - - - - - - - - diff -r e93350dc99f1 -r c8533e9298e5 additional_functions_block_splsda.R --- 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) -} diff -r e93350dc99f1 -r c8533e9298e5 circleCor.xml --- 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 @@ - - - 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. - - - r-viscorvar - r-argparse - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 circleCor_wrapper.R --- 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 diff -r e93350dc99f1 -r c8533e9298e5 computeMatSimilarity.xml --- 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 @@ - - - performs the computation of the similarities. The similarity between two variables is an approximation of the correlation between these two variables. - - - r-viscorvar - r-argparse - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 computeMatSimilarity_wrapper.R --- 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 diff -r e93350dc99f1 -r c8533e9298e5 macros.xml --- /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 @@ + + + + + + + + + + LC_ALL=C Rscript $__tool_directory__/ + + + ; + return=\$?; + cat 'log.txt'; + sh -c "exit \$return" + + + + +.. 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. + + + + \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 macros_mixomics.xml --- /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 @@ + + + + 6.12 + + + bioconductor-mixomics + r-argparse + + + + + + +.. class:: infomark + +**Authors** Kim-Anh Le Cao, Florian Rohart, Ignacio Gonzalez, Sebastien Dejean, and others. http://mixomics.org/contact-us/ + +@HELP_AUTHORS_WRAPPERS@ + +--------------------------------------------------- + + + + + +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 + + + + + + 10.1371/journal.pcbi.1005752 + 10.18129/B9.bioc.mixOmics + + + \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 macros_viscorvar.xml --- /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 @@ + + + + 0.6 + + + r-viscorvar + r-argparse + + + + + + +.. class:: infomark + +**Authors** Maxime Brunin (maxime.brunin@univ-lille.fr), Pierre Pericard (pierre.pericard@univ-lille.fr) + +@HELP_AUTHORS_WRAPPERS@ + +--------------------------------------------------- + + + + + +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 + + + + + + + + + \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 matCorAddVar.xml --- 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 @@ - - - determine the correlation circles that can be overlaid and compute the correlations - - - r-viscorvar - r-argparse - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 matCorAddVar_wrapper.R --- 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) diff -r e93350dc99f1 -r c8533e9298e5 mixomics_blocksplsda.R --- /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) +} diff -r e93350dc99f1 -r c8533e9298e5 mixomics_blocksplsda.xml --- 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 @@ - + performs N-integration and feature selection with Projection to Latent Structures models (PLS) with sparse Discriminant Analysis - - bioconductor-mixomics - r-argparse - + + macros.xml + macros_mixomics.xml + - + + - - - + + @COMMAND_LOG_EXIT@ + + ]]> @@ -73,7 +77,7 @@ - - @@ -127,26 +131,13 @@ - + - - - + ]]> - - 10.1371/journal.pcbi.1005752 - + \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 mixomics_blocksplsda_additional_funct.R --- /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) +} diff -r e93350dc99f1 -r c8533e9298e5 mixomics_blocksplsda_script.R --- 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) -} diff -r e93350dc99f1 -r c8533e9298e5 mixomics_plotindiv.R --- /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 diff -r e93350dc99f1 -r c8533e9298e5 mixomics_plotindiv.xml --- 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 @@ - + provides scatter plots for individuals (experimental units) representation in (sparse)(I)PCA,(regularized)CCA, (sparse)PLS(DA) and (sparse)(R)GCCA(DA) - - bioconductor-mixomics - r-argparse - + + macros.xml + macros_mixomics.xml + - - - + + + + - - + + @COMMAND_LOG_EXIT@ + + ]]> - - - + ]]> - - 10.1371/journal.pcbi.1005752 - + \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 mixomics_plotindiv_script.R --- 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 diff -r e93350dc99f1 -r c8533e9298e5 mixomics_plotvar.R --- /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 diff -r e93350dc99f1 -r c8533e9298e5 mixomics_plotvar.xml --- 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 @@ - + provides variables representation for (regularized) CCA, (sparse) PLS regression, PCA and (sparse) Regularized generalised CCA - - bioconductor-mixomics - r-argparse - + + macros.xml + macros_mixomics.xml + - - - + + + + - - + + @COMMAND_LOG_EXIT@ + + ]]> - - - + ]]> - - 10.1371/journal.pcbi.1005752 - + \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 mixomics_plotvar_script.R --- 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 diff -r e93350dc99f1 -r c8533e9298e5 networkVar.xml --- 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 @@ - - - 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. - - - r-viscorvar - r-argparse - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 networkVar_wrapper.R --- 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 diff -r e93350dc99f1 -r c8533e9298e5 viscorvar_circlecor.R --- /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 diff -r e93350dc99f1 -r c8533e9298e5 viscorvar_circlecor.xml --- /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 @@ + + + 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. + + + macros.xml + macros_viscorvar.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 viscorvar_computematsimilarity.R --- /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 diff -r e93350dc99f1 -r c8533e9298e5 viscorvar_computematsimilarity.xml --- /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 @@ + + + performs the computation of the similarities. The similarity between two variables is an approximation of the correlation between these two variables. + + + macros.xml + macros_viscorvar.xml + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 viscorvar_matcoraddvar.R --- /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) diff -r e93350dc99f1 -r c8533e9298e5 viscorvar_matcoraddvar.xml --- /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 @@ + + + determine the correlation circles that can be overlaid and compute the correlations + + + macros.xml + macros_viscorvar.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r e93350dc99f1 -r c8533e9298e5 viscorvar_networkvar.R --- /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 diff -r e93350dc99f1 -r c8533e9298e5 viscorvar_networkvar.xml --- /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 @@ + + + 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. + + + macros.xml + macros_viscorvar.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file