Mercurial > repos > eschen42 > w4mcorcov
changeset 8:342570ad880c draft
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 0c81f4f1416129dd7061042b12cd28c0b8927aab
author | eschen42 |
---|---|
date | Sat, 04 Aug 2018 17:43:16 -0400 |
parents | 066b1f409e9f |
children | 06c51af11531 |
files | w4mcorcov.xml w4mcorcov_wrapper.R |
diffstat | 2 files changed, 175 insertions(+), 203 deletions(-) [+] |
line wrap: on
line diff
--- a/w4mcorcov.xml Thu Jul 26 10:23:34 2018 -0400 +++ b/w4mcorcov.xml Sat Aug 04 17:43:16 2018 -0400 @@ -1,160 +1,145 @@ -<tool id="w4mcorcov" name="OPLS-DA_Contrasts" version="0.98.11"> - - <description>OPLS-DA Contrasts of Univariate Results</description> - - <macros> - <xml name="paramPairSigFeatOnly"> - <param - name="pairSigFeatOnly" - type="boolean" - checked="true" - truevalue="TRUE" - falsevalue="FALSE" - label="Retain only pairwise-significant features" - help="When this option is set to 'Yes', analysis will be performed including only features that differ significantly for the pair of levels being contrasted; when set to 'No', any feature that varies significantly across all levels will be included (i.e., exclude any feature that is not significantly different across all levels). See examples below." /> - </xml> - <xml name="cplots"> - <param name="cplot_y" label="C-plot Y-axis" type="select" help="Choose the Y-axis for C-plots."> - <option value="correlation">Plot VIP versus correlation</option> - <option value="covariance">Plot VIP versus covariance</option> - </param> - <param - name="cplot_p" - type="boolean" - checked="TRUE" - truevalue="TRUE" - falsevalue="FALSE" - label="Produce predictor C-plot" - help="When this option is set to 'Yes', correlation will be plotted against vip4 for predictor loadings." /> - <param - name="cplot_o" - type="boolean" - checked="TRUE" - truevalue="TRUE" - falsevalue="FALSE" - label="Produce orthogonal C-plot" - help="When this option is set to 'Yes', correlation will be plotted against vip4 for orthogonal loadings." /> - </xml> - </macros> - - <requirements> - <requirement type="package">r-batch</requirement> - <requirement type="package">bioconductor-ropls</requirement> - </requirements> - - <stdio> - <exit_code range="1:" level="fatal" /> - </stdio> - - <command><![CDATA[ - cd $__tool_directory__; Rscript w4mcorcov_wrapper.R - dataMatrix_in "$dataMatrix_in" - sampleMetadata_in "$sampleMetadata_in" - variableMetadata_in "$variableMetadata_in" - facC "$facC" - #if str( $signif_test.tesC ) == "none": - tesC "none" - pairSigFeatOnly "FALSE" - #else: - tesC "$signif_test.tesC" - pairSigFeatOnly "$signif_test.pairSigFeatOnly" - #end if - levCSV '$levCSV' - matchingC '$matchingC' - labelFeatures '$labelFeatures' - #if str( $xplots.expPlot ) == "none": - cplot_p "FALSE" - cplot_o "FALSE" - cplot_y "correlation" - #else if str( $xplots.expPlot ) == "cplot": - cplot_p "$xplots.cplot_p" - cplot_o "$xplots.cplot_o" - cplot_y "$xplots.cplot_y" - #end if - contrast_detail '$contrast_detail' - contrast_corcov '$contrast_corcov' - contrast_salience '$contrast_salience' +<tool id="w4mcorcov" name="OPLS-DA_Contrasts" version="0.98.12"> + <description>OPLS-DA Contrasts of Univariate Results</description> + <macros> + <xml name="paramPairSigFeatOnly"> + <param name="pairSigFeatOnly" type="boolean" checked="true" truevalue="TRUE" falsevalue="FALSE" + label="Retain only pairwise-significant features" + help="When this option is set to 'Yes', analysis will be performed including only features that differ significantly for the pair of levels being contrasted; when set to 'No', any feature that varies significantly across all levels will be included (i.e., exclude any feature that is not significantly different across all levels). See examples below." /> + </xml> + <xml name="cplots"> + <param name="cplot_y" label="C-plot Y-axis" type="select" help="Choose the Y-axis for C-plots."> + <option value="correlation">Plot VIP versus correlation</option> + <option value="covariance">Plot VIP versus covariance</option> + </param> + <param name="cplot_p" type="boolean" checked="true" truevalue="TRUE" falsevalue="FALSE" + label="Produce predictor C-plot" + help="When this option is set to 'Yes', correlation will be plotted against vip4 for predictor loadings." /> + <param name="cplot_o" type="boolean" checked="true" truevalue="TRUE" falsevalue="FALSE" + label="Produce orthogonal C-plot" + help="When this option is set to 'Yes', correlation will be plotted against vip4 for orthogonal loadings." /> + </xml> + </macros> + <requirements> + <requirement type="package">r-batch</requirement> + <requirement type="package">bioconductor-ropls</requirement> + </requirements> + <command detect_errors="aggressive"><![CDATA[ + Rscript '$__tool_directory__/w4mcorcov_wrapper.R' + dataMatrix_in '$dataMatrix_in' + sampleMetadata_in '$sampleMetadata_in' + variableMetadata_in '$variableMetadata_in' + facC '$facC' + #if str( $signif_test.tesC ) == "none": + tesC "none" + pairSigFeatOnly "FALSE" + #else: + tesC '$signif_test.tesC' + pairSigFeatOnly '$signif_test.pairSigFeatOnly' + #end if + levCSV '$levCSV' + matchingC '$matchingC' + labelFeatures '$labelFeatures' + #if str( $xplots.expPlot ) == "none": + cplot_p "FALSE" + cplot_o "FALSE" + cplot_y "correlation" + #else if str( $xplots.expPlot ) == "cplot": + cplot_p '$xplots.cplot_p' + cplot_o '$xplots.cplot_o' + cplot_y '$xplots.cplot_y' + #end if + contrast_detail '$contrast_detail' + contrast_corcov '$contrast_corcov' + contrast_salience '$contrast_salience' ]]></command> - <inputs> - <param name="dataMatrix_in" label="Data matrix file" type="data" format="tabular" help="Features x samples (tabular data - decimal: '.'; missing: NA; mode: numerical; separator: tab character)" /> - <param name="sampleMetadata_in" label="Sample metadata file" type="data" format="tabular" help="Samples x metadata (tabular data - decimal: '.'; missing: NA; mode: character or numerical; separator: tab character)" /> - <param name="variableMetadata_in" label="Variable metadata file (ideally from Univariate)" type="data" format="tabular" help="Features x metadata (tabular data - decimal: '.'; missing: NA; mode: character or numerical; separator: tab character)" /> - <param name="facC" label="Factor of interest" type="text" help="REQUIRED - The name of the column of sampleMetadata corresponding to the qualitative variable used to define the contrasts. Except when the 'Univariate Significance-test' is set to 'none', this also must be a portion of the column names in the variableMetadata file."/> - <conditional name="signif_test"> - <param name="tesC" label="Univariate significance-test" type="select" help="Either 'none' or the name of the statistical test that was run by the 'Univariate' tool to produce the variableMetadata file; that name must also be a portion of the column names in that file."> - <option value="none">none - Display all features from variableMetadata (rather than choosing a subset based on significance in univariate testing)</option> - <option value="ttest">ttest - Student's t-test (parametric test, qualitative factor with exactly 2 levels)</option> - <option value="anova">anova - Analysis of variance (parametric test, qualitative factor with more than 2 levels)</option> - <option value="wilcoxon">wilcoxon - Wilcoxon rank test (nonparametric test, qualitative factor with exactly 2 levels)</option> - <option value="kruskal">kruskal - Kruskal-Wallis rank test (nonparametric test, qualitative factor with more than 2 levels)</option> - </param> - <when value="none" /> - <when value="ttest"> - <expand macro="paramPairSigFeatOnly" /> - </when> - <when value="anova"> - <expand macro="paramPairSigFeatOnly" /> - </when> - <when value="wilcoxon"> - <expand macro="paramPairSigFeatOnly" /> - </when> - <when value="kruskal"> - <expand macro="paramPairSigFeatOnly" /> - </when> - </conditional> - <param name="levCSV" label="Levels of interest" type="text" value = "*" help="Comma-separated level-names (or comma-less regular expressions to match level-names) to consider in analysis; must match at least two levels; levels must be non-numeric; may include wild cards or regular expressions. Note that extra space characters will affect results - 'a,b' is correct, but 'a , b' is not and may fail or give different results."> - <sanitizer> - <valid initial="string.letters"> - <add preset="string.digits"/> - <add value="$" /> <!-- $ dollar, dollar-sign --> - <add value="(" /> <!-- ( left-paren --> - <add value=")" /> <!-- ) right-paren --> - <add value="*" /> <!-- * splat, asterisk --> - <add value="+" /> <!-- + plus --> - <add value="," /> <!-- , comma --> - <add value="-" /> <!-- - dash, minus-sign --> - <add value="." /> <!-- . dot, period --> - <add value=":" /> <!-- : colon --> - <add value=";" /> <!-- ; semi, semicolon --> - <add value="?" /> <!-- ? what, question mark --> - <add value="[" /> <!-- [ l-squib, left-squre-bracket --> - <add value="\" /> <!-- \ whack, backslash --> - <add value="]" /> <!-- ] r-squib, right-squre-bracket --> - <add value="^" /> <!-- ^ hat, caret --> - <add value="{" /> <!-- { l-cube, left-curly-bracket --> - <add value="|" /> <!-- | pipe --> - <add value="}" /> <!-- } r-cube, right-curly-bracket --> - <!-- IMPORTANT - Note that single and double quotes are not part of this list; they have the potential to make the 'command' section insecure or broken. --> - </valid> - </sanitizer> - </param> - <param name="matchingC" label="Level-name matching" type="select" help="How to specify level-names generically. (See help below for details on using wild cards or regular expressions.)"> - <option value="none">do no generic matching (default)</option> - <option value="wildcard" selected="true">use wild-cards for matching level-names</option> - <option value="regex">use regular expressions for matching level-names</option> - </param> - <param name="labelFeatures" type="text" value="3" label="How many features having extreme loadings should be labelled on cov-vs.-cor plot" help="Specify the number of features at each of the loading-extremes that should be labelled (with the name of the feature) on the covariance-vs.-correlation plot; specify 'ALL' to label all features or '0' to label no features; this choice has no effect on the OPLS-DA loadings plot."/> - <conditional name="xplots"> - <param name="expPlot" label="Extra plots to include" type="select" help="Choosing 'none' hides further choices."> - <option value="none">none - Do not include additonal extra plots.</option> - <option value="cplot">cplot - Include C-plots (predictor-loading vs. 'vip4p' and orthogonal-loading versus 'vip4o')</option> - </param> - <when value="none" /> - <when value="cplot"> - <expand macro="cplots" /> - </when> - </conditional> - </inputs> - - <outputs> + <inputs> + <param name="dataMatrix_in" type="data" format="tabular" label="Data matrix file" + help="Features x samples (tabular data - decimal: '.'; missing: NA; mode: numerical; separator: tab character)" /> + <param name="sampleMetadata_in" type="data" format="tabular" label="Sample metadata file" + help="Samples x metadata (tabular data - decimal: '.'; missing: NA; mode: character or numerical; separator: tab character)" /> + <param name="variableMetadata_in" type="data" format="tabular" + label="Variable metadata file (ideally from Univariate)" + help="Features x metadata (tabular data - decimal: '.'; missing: NA; mode: character or numerical; separator: tab character)" /> + <param name="facC" type="text" + label="Factor of interest" + help="REQUIRED - The name of the column of sampleMetadata corresponding to the qualitative variable used to define the contrasts. Except when the 'Univariate Significance-test' is set to 'none', this also must be a portion of the column names in the variableMetadata file."/> + <conditional name="signif_test"> + <param name="tesC" label="Univariate significance-test" type="select" help="Either 'none' or the name of the statistical test that was run by the 'Univariate' tool to produce the variableMetadata file; that name must also be a portion of the column names in that file."> + <option value="none">none - Display all features from variableMetadata (rather than choosing a subset based on significance in univariate testing)</option> + <option value="ttest">ttest - Student's t-test (parametric test, qualitative factor with exactly 2 levels)</option> + <option value="anova">anova - Analysis of variance (parametric test, qualitative factor with more than 2 levels)</option> + <option value="wilcoxon">wilcoxon - Wilcoxon rank test (nonparametric test, qualitative factor with exactly 2 levels)</option> + <option value="kruskal">kruskal - Kruskal-Wallis rank test (nonparametric test, qualitative factor with more than 2 levels)</option> + </param> + <when value="none" /> + <when value="ttest"> + <expand macro="paramPairSigFeatOnly" /> + </when> + <when value="anova"> + <expand macro="paramPairSigFeatOnly" /> + </when> + <when value="wilcoxon"> + <expand macro="paramPairSigFeatOnly" /> + </when> + <when value="kruskal"> + <expand macro="paramPairSigFeatOnly" /> + </when> + </conditional> + <param name="levCSV" type="text" value="*" label="Levels of interest" + help="Comma-separated level-names (or comma-less regular expressions to match level-names) to consider in analysis; must match at least two levels; levels must be non-numeric; may include wild cards or regular expressions. Note that extra space characters will affect results - 'a,b' is correct, but 'a , b' is not and may fail or give different results."> + <sanitizer> + <valid initial="string.letters"> + <add preset="string.digits"/> + <add value="$" /> <!-- $ dollar, dollar-sign --> + <add value="(" /> <!-- ( left-paren --> + <add value=")" /> <!-- ) right-paren --> + <add value="*" /> <!-- * splat, asterisk --> + <add value="+" /> <!-- + plus --> + <add value="," /> <!-- , comma --> + <add value="-" /> <!-- - dash, minus-sign --> + <add value="." /> <!-- . dot, period --> + <add value=":" /> <!-- : colon --> + <add value=";" /> <!-- ; semi, semicolon --> + <add value="?" /> <!-- ? what, question mark --> + <add value="[" /> <!-- [ l-squib, left-squre-bracket --> + <add value="\" /> <!-- \ whack, backslash --> + <add value="]" /> <!-- ] r-squib, right-squre-bracket --> + <add value="^" /> <!-- ^ hat, caret --> + <add value="{" /> <!-- { l-cube, left-curly-bracket --> + <add value="|" /> <!-- | pipe --> + <add value="}" /> <!-- } r-cube, right-curly-bracket --> + <!-- IMPORTANT - Note that single and double quotes are not part of this list; they have the potential to make the 'command' section insecure or broken. --> + </valid> + </sanitizer> + </param> + <param name="matchingC" label="Level-name matching" type="select" help="How to specify level-names generically. (See help below for details on using wild cards or regular expressions.)"> + <option value="none">do no generic matching (default)</option> + <option value="wildcard" selected="true">use wild-cards for matching level-names</option> + <option value="regex">use regular expressions for matching level-names</option> + </param> + <param name="labelFeatures" type="text" value="3" + label="How many features having extreme loadings should be labelled on cov-vs.-cor plot" + help="Specify the number of features at each of the loading-extremes that should be labelled (with the name of the feature) on the covariance-vs.-correlation plot; specify 'ALL' to label all features or '0' to label no features; this choice has no effect on the OPLS-DA loadings plot."/> + <conditional name="xplots"> + <param name="expPlot" label="Extra plots to include" type="select" help="Choosing 'none' hides further choices."> + <option value="none">Do not include additonal extra plots.</option> + <option value="cplot">Include C-plots (predictor-loading vs. 'vip4p' and orthogonal-loading versus 'vip4o')</option> + </param> + <when value="none" /> + <when value="cplot"> + <expand macro="cplots" /> + </when> + </conditional> + </inputs> + <outputs> <!-- pdf1: summaries of each contrasts, clearly labelled by level=pair name * first PCA score-plot * then PLS score-plot * then PLS S-PLOT; color in red features with VIP > 1; color in grey any non-pairwise-significant features, if these are included --> - <data name="contrast_detail" label="${tool.name}_${variableMetadata_in.name}_detail" format="pdf" /> + <data name="contrast_detail" format="pdf" label="${tool.name}_${variableMetadata_in.name}_detail" /> <!-- tsv1: cor and cov table with columns: * feature-ID @@ -166,7 +151,7 @@ * Galindo_Prieto_2014 VIP for orthogonal components, VIP[4,o] * (When filtering on significance of univariate tests) Significance of test of null hypothesis that there is no difference between the two classes, i.e, the pair-wise test. --> - <data name="contrast_corcov" label="${tool.name}_${variableMetadata_in.name}_corcov" format="tabular" /> + <data name="contrast_corcov" format="tabular" label="${tool.name}_${variableMetadata_in.name}_corcov" /> <!-- tsv2: salience table with columns (experimental feature): * feature-ID @@ -174,9 +159,8 @@ * Salient robust coefficient of variation, i.e., for the feature, the mean absolute deviation of the intensity for the salient level divided by the median intensity for the salient level * Salience, i.e., for the feature, the median of the class-level having the greatest intensity divided by the mean of the medians for all class-levels. --> - <data name="contrast_salience" label="${tool.name}_${variableMetadata_in.name}_salience" format="tabular" /> + <data name="contrast_salience" format="tabular" label="${tool.name}_${variableMetadata_in.name}_salience" /> </outputs> - <tests> <!-- test #1 --> <test> @@ -725,51 +709,6 @@ OPLS-DA, SIMCA, and S-PLOT are registered trademarks of the Umetrics company. http://umetrics.com/about-us/trademarks -Release notes -------------- - -0.98.11 - -- bug fix: Readdress issue 2 - features now are pareto-scaled *and centered* per Wikland *op cit.*. - -0.98.10 - -- new feature: C-plots of VIP versus correlation or relative covariance. -- bug fix: Handle issue 2 - features now are only pareto-scaled per Wikland *op cit.*. - -0.98.9 - -- bug fix: Handle issue 1 - handle features removed by ropls because variance is less than 2.2e-16. - -0.98.8 - -- new feature: Replace loadings plot with correlation-versus-covariance plot for orthogonal features, i.e., the consistency of features influencing within-treatment variation (which is linearly related to the loading of the orthogonal projection) versus consistency. This eliminates the need for the parameter to suppress labels for features with extreme orthogonal loadings - -0.98.7 - -- bug fix: Handle case of a treatment level with only one sample. - -0.98.6 - -- bug fix: Set 'crossvalI' param (of R function 'ropls::opls') to the number of samples when the there are fewer than seven samples. - -0.98.5 - -- bug fix: Fit feature-labels within clipping region of cor-vs.cov plot -- new feature: optionally (and by default) suppress labels for features with extreme orthogonal loadings - -0.98.3 - -- Add support for two-level factors -- Add adjusted mz and rt to output tables -- Allow explicitly setting the number of features with extreme loadings to be labelled on the correlation vs. covariance plot -- Add loadings to corcov table - -0.98.2 - -- first release - - ]]></help> <citations> <!-- this tool -->
--- a/w4mcorcov_wrapper.R Thu Jul 26 10:23:34 2018 -0400 +++ b/w4mcorcov_wrapper.R Sat Aug 04 17:43:16 2018 -0400 @@ -22,12 +22,45 @@ ## subroutines ##---------- -source("w4mcorcov_lib.R") -source("w4mcorcov_util.R") -source("w4mcorcov_input.R") -source("w4mcorcov_salience.R") -source("w4mcorcov_calc.R") -source("w4mcorcov_output.R") +# from: https://github.com/molgenis/molgenis-pipelines/wiki/How-to-source-another_file.R-from-within-your-R-script +LocationOfThisScript = function() # Function LocationOfThisScript returns the location of this .R script (may be needed to source other files in same dir) +{ + this.file = NULL + # This file may be 'sourced' + for (i in -(1:sys.nframe())) { + if (identical(sys.function(i), base::source)) this.file = (normalizePath(sys.frame(i)$ofile)) + } + + if (!is.null(this.file)) return(dirname(this.file)) + + # But it may also be called from the command line + cmd.args = commandArgs(trailingOnly = FALSE) + cmd.args.trailing = commandArgs(trailingOnly = TRUE) + cmd.args = cmd.args[seq.int(from=1, length.out=length(cmd.args) - length(cmd.args.trailing))] + res = gsub("^(?:--file=(.*)|.*)$", "\\1", cmd.args) + + # If multiple --file arguments are given, R uses the last one + res = tail(res[res != ""], 1) + if (0 < length(res)) return(dirname(res)) + + # Both are not the case. Maybe we are in an R GUI? + return(NULL) +} + +script.dir <- LocationOfThisScript() + +source(paste(script.dir, "w4mcorcov_lib.R", sep="/")) +source(paste(script.dir, "w4mcorcov_util.R", sep="/")) +source(paste(script.dir, "w4mcorcov_input.R", sep="/")) +source(paste(script.dir, "w4mcorcov_salience.R", sep="/")) +source(paste(script.dir, "w4mcorcov_calc.R", sep="/")) +source(paste(script.dir, "w4mcorcov_output.R", sep="/")) +#source("w4mcorcov_lib.R") +#source("w4mcorcov_util.R") +#source("w4mcorcov_input.R") +#source("w4mcorcov_salience.R") +#source("w4mcorcov_calc.R") +#source("w4mcorcov_output.R") ## log file ##---------