Next changeset 1:fdefbc780d2e (2016-07-30) |
Commit message:
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit ca0e312e1c986c45310f37effe031f60009fbcab |
added:
LICENSE.md README.md build.xml docker/Dockerfile static/images/univariate_workflowPositionImage.png test-data/dataMatrix.tsv test-data/sampleMetadata.tsv test-data/variableMetadata-output.tsv test-data/variableMetadata.tsv tests/example1/dataMatrix.tsv tests/example1/sampleMetadata.tsv tests/example1/variableMetadata.tsv tests/input/dataMatrix.tsv tests/input/sampleMetadata.tsv tests/input/variableMetadata.tsv tests/output/information.txt tests/output/variableMetadata.tsv tests/univariate_tests.R univariate_config.xml univariate_script.R univariate_wrapper.R |
b |
diff -r 000000000000 -r ef64d3752050 LICENSE.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LICENSE.md Wed Jul 27 11:44:34 2016 -0400 |
[ |
b'@@ -0,0 +1,517 @@\n+ CeCILL FREE SOFTWARE LICENSE AGREEMENT\n+\n+Version 2.1 dated 2013-06-21\n+\n+\n+ Notice\n+\n+This Agreement is a Free Software license agreement that is the result\n+of discussions between its authors in order to ensure compliance with\n+the two main principles guiding its drafting:\n+\n+ * firstly, compliance with the principles governing the distribution\n+ of Free Software: access to source code, broad rights granted to users,\n+ * secondly, the election of a governing law, French law, with which it\n+ is conformant, both as regards the law of torts and intellectual\n+ property law, and the protection that it offers to both authors and\n+ holders of the economic rights over software.\n+\n+The authors of the CeCILL (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre]) \n+license are: \n+\n+Commissariat \xe0 l\'\xe9nergie atomique et aux \xe9nergies alternatives - CEA, a\n+public scientific, technical and industrial research establishment,\n+having its principal place of business at 25 rue Leblanc, immeuble Le\n+Ponant D, 75015 Paris, France.\n+\n+Centre National de la Recherche Scientifique - CNRS, a public scientific\n+and technological establishment, having its principal place of business\n+at 3 rue Michel-Ange, 75794 Paris cedex 16, France.\n+\n+Institut National de Recherche en Informatique et en Automatique -\n+Inria, a public scientific and technological establishment, having its\n+principal place of business at Domaine de Voluceau, Rocquencourt, BP\n+105, 78153 Le Chesnay cedex, France.\n+\n+\n+ Preamble\n+\n+The purpose of this Free Software license agreement is to grant users\n+the right to modify and redistribute the software governed by this\n+license within the framework of an open source distribution model.\n+\n+The exercising of this right is conditional upon certain obligations for\n+users so as to preserve this status for all subsequent redistributions.\n+\n+In consideration of access to the source code and the rights to copy,\n+modify and redistribute granted by the license, users are provided only\n+with a limited warranty and the software\'s author, the holder of the\n+economic rights, and the successive licensors only have limited liability.\n+\n+In this respect, the risks associated with loading, using, modifying\n+and/or developing or reproducing the software by the user are brought to\n+the user\'s attention, given its Free Software status, which may make it\n+complicated to use, with the result that its use is reserved for\n+developers and experienced professionals having in-depth computer\n+knowledge. Users are therefore encouraged to load and test the\n+suitability of the software as regards their requirements in conditions\n+enabling the security of their systems and/or data to be ensured and,\n+more generally, to use and operate it in the same conditions of\n+security. This Agreement may be freely reproduced and published,\n+provided it is not altered, and that no provisions are either added or\n+removed herefrom.\n+\n+This Agreement may apply to any or all software for which the holder of\n+the economic rights decides to submit the use thereof to its provisions.\n+\n+Frequently asked questions can be found on the official website of the\n+CeCILL licenses family (http://www.cecill.info/index.en.html) for any \n+necessary clarification.\n+\n+\n+ Article 1 - DEFINITIONS\n+\n+For the purpose of this Agreement, when the following expressions\n+commence with a capital letter, they shall have the following meaning:\n+\n+Agreement: means this license agreement, and its possible subsequent\n+versions and annexes.\n+\n+Software: means the software in its Object Code and/or Source Code form\n+and, where applicable, its documentation, "as is" when the Licensee\n+accepts the Agreement.\n+\n+Initial Software: means the Software in its Source Code and possibly its\n+Object Code form and, where applicable, its documentation, "as is" when\n+it is first distributed under the terms and conditions of the Agreement.\n+\n+Modified Software: means the Software modified by at lea'..b"l be\n+decided on a case-by-case basis between the relevant Licensor and the\n+Licensee pursuant to a memorandum of understanding. The Licensor\n+disclaims any and all liability as regards the Licensee's use of the\n+name of the Software. No warranty is given as regards the existence of\n+prior rights over the name of the Software or as regards the existence\n+of a trademark.\n+\n+\n+ Article 10 - TERMINATION\n+\n+10.1 In the event of a breach by the Licensee of its obligations\n+hereunder, the Licensor may automatically terminate this Agreement\n+thirty (30) days after notice has been sent to the Licensee and has\n+remained ineffective.\n+\n+10.2 A Licensee whose Agreement is terminated shall no longer be\n+authorized to use, modify or distribute the Software. However, any\n+licenses that it may have granted prior to termination of the Agreement\n+shall remain valid subject to their having been granted in compliance\n+with the terms and conditions hereof.\n+\n+\n+ Article 11 - MISCELLANEOUS\n+\n+\n+ 11.1 EXCUSABLE EVENTS\n+\n+Neither Party shall be liable for any or all delay, or failure to\n+perform the Agreement, that may be attributable to an event of force\n+majeure, an act of God or an outside cause, such as defective\n+functioning or interruptions of the electricity or telecommunications\n+networks, network paralysis following a virus attack, intervention by\n+government authorities, natural disasters, water damage, earthquakes,\n+fire, explosions, strikes and labor unrest, war, etc.\n+\n+11.2 Any failure by either Party, on one or more occasions, to invoke\n+one or more of the provisions hereof, shall under no circumstances be\n+interpreted as being a waiver by the interested Party of its right to\n+invoke said provision(s) subsequently.\n+\n+11.3 The Agreement cancels and replaces any or all previous agreements,\n+whether written or oral, between the Parties and having the same\n+purpose, and constitutes the entirety of the agreement between said\n+Parties concerning said purpose. No supplement or modification to the\n+terms and conditions hereof shall be effective as between the Parties\n+unless it is made in writing and signed by their duly authorized\n+representatives.\n+\n+11.4 In the event that one or more of the provisions hereof were to\n+conflict with a current or future applicable act or legislative text,\n+said act or legislative text shall prevail, and the Parties shall make\n+the necessary amendments so as to comply with said act or legislative\n+text. All other provisions shall remain effective. Similarly, invalidity\n+of a provision of the Agreement, for any reason whatsoever, shall not\n+cause the Agreement as a whole to be invalid.\n+\n+\n+ 11.5 LANGUAGE\n+\n+The Agreement is drafted in both French and English and both versions\n+are deemed authentic.\n+\n+\n+ Article 12 - NEW VERSIONS OF THE AGREEMENT\n+\n+12.1 Any person is authorized to duplicate and distribute copies of this\n+Agreement.\n+\n+12.2 So as to ensure coherence, the wording of this Agreement is\n+protected and may only be modified by the authors of the License, who\n+reserve the right to periodically publish updates or new versions of the\n+Agreement, each with a separate number. These subsequent versions may\n+address new issues encountered by Free Software.\n+\n+12.3 Any Software distributed under a given version of the Agreement may\n+only be subsequently distributed under the same version of the Agreement\n+or a subsequent version, subject to the provisions of Article 5.3.4\n+<#compatibility>.\n+\n+\n+ Article 13 - GOVERNING LAW AND JURISDICTION\n+\n+13.1 The Agreement is governed by French law. The Parties agree to\n+endeavor to seek an amicable solution to any disagreements or disputes\n+that may arise during the performance of the Agreement.\n+\n+13.2 Failing an amicable solution within two (2) months as from their\n+occurrence, and unless emergency proceedings are necessary, the\n+disagreements or disputes shall be referred to the Paris Courts having\n+jurisdiction, by the more diligent Party.\n" |
b |
diff -r 000000000000 -r ef64d3752050 README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Wed Jul 27 11:44:34 2016 -0400 |
[ |
@@ -0,0 +1,37 @@ +# Univariate parametric and non-parametric hypothesis testing with correction for multiple testing + +A Galaxy module from the [Workflow4metabolomics](http://workflow4metabolomics.org) project. + +Status: [![Build Status](https://travis-ci.org/workflow4metabolomics/univariate.svg?branch=master)](https://travis-ci.org/workflow4metabolomics/univariate). + +## Description + +**Version:** 2.1.1 +**Date:** 2015-09-30 +**Author:** Marie Tremblay-Franco (INRA, MetaToul, MetaboHUB, W4M Core Development Team) and Etienne A. Thevenot (CEA, LIST, MetaboHUB, W4M Core Development Team) +**Email:** [marie.tremblay-franco(at)toulouse.inra.fr](mailto:marie.tremblay-franco@toulouse.inra.fr); [etienne.thevenot(at)cea.fr](mailto:etienne.thevenot@cea.fr) +**Citation:** Thevenot E.A., Roux A., Xu Y., Ezan E. and Junot C. (2015). Analysis of the human adult urinary metabolome variations with age, body mass index and gender by implementing a comprehensive workflow for univariate and OPLS statistical analyses. *Journal of Proteome Research*, **14**:3322-3335. [doi:10.1021/acs.jproteome.5b00354](http://dx.doi.org/10.1021/acs.jproteome.5b00354) +**Reference history:** [W4M00001a_sacurine-subset-statistics](http://galaxy.workflow4metabolomics.org/history/list_published), [W4M00004_mtbls1](http://galaxy.workflow4metabolomics.org/history/list_published) +**Licence:** CeCILL +**Funding:** Agence Nationale de la Recherche ([MetaboHUB](http://www.metabohub.fr/index.php?lang=en&Itemid=473) national infrastructure for metabolomics and fluxomics, ANR-11-INBS-0010 grant) + +## Installation + + * Configuration file: **univariate_config.xml** + * Image file: + + **static/images/univariate_workflowPositionImage.png** + * Wrapper file: **univariate_wrapper.R** + * Script file: **univariate_script.R** + * R packages + + **batch** from CRAN: `install.packages("batch", dep=TRUE)`. + + **PMCMR** from Bioconductor: `install.packages("PMCMR", dep=TRUE)`. + +## Tests + +The code in the wrapper can be tested by running the **tests/univariate_tests.R** in R + +## News + +## CHANGES IN VERSION 2.1.1 + + * Internal handling of 'NA' p-values (e.g. when intensities are identical in all samples). |
b |
diff -r 000000000000 -r ef64d3752050 build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build.xml Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,95 @@ +<project name="w4m.univariate" default="all"> + + <property name="tool.xml" value="univariate_config.xml"/> + <property name="conda.dir" value="${user.home}/w4m-conda"/> + + <!--~~~ + ~ ALL ~ + ~~~~~--> + + <target name="all"/> + + <!--~~~~ + ~ TEST ~ + ~~~~~--> + + <target name="test" depends="planemo.lint,planemo.test"/> + + <!--~~~~~~~~~~~~ + ~ PLANEMO LINT ~ + ~~~~~~~~~~~~~--> + + <target name="planemo.lint"> + <exec executable="planemo" failonerror="true"> + <arg value="lint"/> + <arg value="${tool.xml}"/> + </exec> + </target> + + <!--~~~~~~~~~~~~ + ~ PLANEMO TEST ~ + ~~~~~~~~~~~~~--> + + <target name="planemo.test" depends="planemo.conda.install"> + <exec executable="planemo" failonerror="true"> + <arg value="test"/> + <arg value="--conda_prefix"/> + <arg value="${conda.dir}"/> + <arg value="--galaxy_branch"/> + <arg value="release_16.01"/> + <arg value="--conda_dependency_resolution"/> + <arg value="${tool.xml}"/> + </exec> + </target> + + <!--~~~~~~~~~~~~~~~~~~~~~ + ~ PLANEMO CONDA INSTALL ~ + ~~~~~~~~~~~~~~~~~~~~~~--> + + <target name="planemo.conda.install" depends="planemo.conda.init"> + <exec executable="planemo" failonerror="true"> + <arg value="conda_install"/> + <arg value="--conda_prefix"/> + <arg value="${conda.dir}"/> + <arg value="${tool.xml}"/> + </exec> + </target> + + <!--~~~~~~~~~~~~~~~~~~ + ~ PLANEMO CONDA INIT ~ + ~~~~~~~~~~~~~~~~~~~--> + + <target name="planemo.conda.init"> + <exec executable="planemo" failonerror="true"> + <arg value="conda_init"/> + <arg value="--conda_prefix"/> + <arg value="${conda.dir}"/> + </exec> + </target> + + <!--~~~~~~~~~~~~~ + ~ PLANEMO SERVE ~ + ~~~~~~~~~~~~~~--> + + <target name="planemo.serve" depends="planemo.conda.install"> + <exec executable="planemo" failonerror="true"> + <arg value="serve"/> + <arg value="--conda_prefix"/> + <arg value="${conda.dir}"/> + <arg value="--galaxy_branch"/> + <arg value="release_16.01"/> + <arg value="--conda_dependency_resolution"/> + <arg value="${tool.xml}"/> + </exec> + </target> + + + <!--~~~~~ + ~ CLEAN ~ + ~~~~~~--> + + <target name="clean"> + <delete dir="${conda.dir}"/> + </target> + +</project> |
b |
diff -r 000000000000 -r ef64d3752050 docker/Dockerfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docker/Dockerfile Wed Jul 27 11:44:34 2016 -0400 |
[ |
@@ -0,0 +1,28 @@ +FROM ubuntu:14.04 + +MAINTAINER Etienne Thevenot (etienne.thevenot@cea.fr) + +# Setup package repos +RUN echo "deb http://mirrors.ebi.ac.uk/CRAN/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 + +# Update and upgrade system +RUN apt-get update +RUN apt-get -y upgrade + +# Install R and other needed packages +RUN apt-get -y install r-base +RUN R -e "install.packages('batch', lib='/usr/lib/R/library', dependencies = TRUE, repos='http://mirrors.ebi.ac.uk/CRAN')" + +# Clone tool +RUN apt-get -y install git +RUN git clone -b docker https://github.com/workflow4metabolomics/univariate /files/univariate + +# Put univariate folder into PATH +ENV PATH=$PATH:/files/univariate + +# Clean up +RUN apt-get clean && apt-get autoremove -y && rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/* + +# Define Entry point script +ENTRYPOINT ["/files/univariate/univariate_wrapper.R"] |
b |
diff -r 000000000000 -r ef64d3752050 static/images/univariate_workflowPositionImage.png |
b |
Binary file static/images/univariate_workflowPositionImage.png has changed |
b |
diff -r 000000000000 -r ef64d3752050 test-data/dataMatrix.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/dataMatrix.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,4 @@ +profile HU_017 HU_021 HU_027 HU_032 HU_041 HU_048 HU_049 HU_050 HU_052 HU_059 HU_060 HU_066 HU_072 HU_077 HU_090 HU_109 HU_110 HU_125 HU_126 HU_131 HU_134 HU_149 HU_150 HU_173 HU_179 HU_180 HU_182 HU_202 HU_204 HU_209 +HMDB01032 2569204.92420381 6222035.77434915 17070707.9912636 1258838.24348419 13039543.0754619 1909391.77026598 3495.09386434063 2293521.90928998 128503.275117713 81872.5276382213 8103557.56578035 149574887.036181 1544036.41049333 7103429.53933206 14138796.50382 4970265.57952158 263054.73056162 1671332.30008058 88433.1944958815 23602331.2894815 18648126.5206986 1554657.98756878 34152.3646391152 209372.71275317 33187733.370626 202438.591636003 13581070.0886437 354170.810678102 9120781.48986975 43419175.4051586 +HMDB03072 3628416.30251025 65626.9834353751 112170.118946651 3261804.34422417 42228.2787747563 343254.201250707 1958217.69317664 11983270.0435677 5932111.41638028 5511385.83359531 9154521.47755199 2632133.21209418 9500411.14556502 6551644.51726592 7204319.80891836 1273412.04795188 3260583.81592376 8932005.5351622 8340827.52597275 9256460.69197759 11217839.169041 5919262.81433556 11790077.0657915 9567977.80797097 73717.5811684739 9991787.29074293 4208098.14739633 623970.649925847 10904221.2642849 2171793.93621067 +HMDB00792 429568.609438384 3887629.50527037 1330692.11658995 1367446.73023821 844197.447472453 2948090.71886592 1614157.90566884 3740009.19379795 3292251.66531919 2310688.79492013 4404239.59008605 3043289.12780863 825736.467181043 2523241.91730649 6030501.02648005 474901.604069803 2885792.42617652 2955990.64049134 1917716.3427982 1767962.67737699 5926203.40397675 1639065.69474684 346810.763557826 1054776.22313737 2390258.27543894 1831346.37315857 1026696.36904362 7079792.50047866 4368341.01359769 3495986.87280275 |
b |
diff -r 000000000000 -r ef64d3752050 test-data/sampleMetadata.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/sampleMetadata.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,31 @@ +sample age ageGroup +HU_017 41 experienced +HU_021 34 junior +HU_027 37 experienced +HU_032 38 experienced +HU_041 28 junior +HU_048 39 experienced +HU_049 50 senior +HU_050 30 junior +HU_052 51 senior +HU_059 81 senior +HU_060 55 senior +HU_066 25 junior +HU_072 47 experienced +HU_077 27 junior +HU_090 46 experienced +HU_109 32 junior +HU_110 50 senior +HU_125 58 senior +HU_126 45 experienced +HU_131 42 experienced +HU_134 48 experienced +HU_149 35 experienced +HU_150 49 experienced +HU_173 55 senior +HU_179 33 junior +HU_180 53 senior +HU_182 43 experienced +HU_202 42 experienced +HU_204 31 junior +HU_209 17.5 junior |
b |
diff -r 000000000000 -r ef64d3752050 test-data/variableMetadata-output.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/variableMetadata-output.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,4 @@ +variableMetadata name ageGroup_kruskal_fdr ageGroup_kruskal_sig ageGroup_kruskal_junior-experienced_dif ageGroup_kruskal_senior-experienced_dif ageGroup_kruskal_senior-junior_dif ageGroup_kruskal_junior-experienced_pva ageGroup_kruskal_senior-experienced_pva ageGroup_kruskal_senior-junior_pva ageGroup_kruskal_junior-experienced_sig ageGroup_kruskal_senior-experienced_sig ageGroup_kruskal_senior-junior_sig +HMDB01032 Dehydroepiandrosterone sulfate 0.0117826825222329 1 7211389.71960377 -1703486.11807139 -8914875.83767516 0.204550960009346 0.123124593762726 0.00251932966039092 0 0 1 +HMDB03072 Quinic acid 0.461634758626427 0 -3747468.87812489 1512795.66143568 5260264.53956057 NA NA NA NA NA NA +HMDB00792 Sebacic acid 0.469555338459932 0 1404223.43306179 959174.915801485 -445048.517260305 NA NA NA NA NA NA |
b |
diff -r 000000000000 -r ef64d3752050 test-data/variableMetadata.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/variableMetadata.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,4 @@ +variable name +HMDB01032 Dehydroepiandrosterone sulfate +HMDB03072 Quinic acid +HMDB00792 Sebacic acid |
b |
diff -r 000000000000 -r ef64d3752050 tests/example1/dataMatrix.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/example1/dataMatrix.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,4 @@ +dataMatrix Ech10 Ech11 Ech12 Ech13 Ech14 Ech15 +MT1 3.439956551 3.399847335 3.335401704 3.4201777 3.24585851 3.401256321 +MT2 5.008458405 4.461291924 4.068043169 4.42768414 4.406640829 4.500370048 +MT3 3.99527636 4.051758488 4.332552332 4.348474118 4.253679544 4.26823853 |
b |
diff -r 000000000000 -r ef64d3752050 tests/example1/sampleMetadata.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/example1/sampleMetadata.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,7 @@ +sampleMetadata jour +Ech10 J10 +Ech11 J10 +Ech12 J10 +Ech13 J3 +Ech14 J3 +Ech15 J3 |
b |
diff -r 000000000000 -r ef64d3752050 tests/example1/variableMetadata.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/example1/variableMetadata.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,4 @@ +variableMetadata PCA_XLOAD-h1 PCA_XLOAD-h2 +MT1 -0.048723936 0.05648187 +MT2 -0.067609139 0.084300327 +MT3 0.080335733 -0.0215397 |
b |
diff -r 000000000000 -r ef64d3752050 tests/input/dataMatrix.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/input/dataMatrix.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,4 @@ +profile HU_017 HU_021 HU_027 HU_032 HU_041 HU_048 HU_049 HU_050 HU_052 HU_059 HU_060 HU_066 HU_072 HU_077 HU_090 HU_109 HU_110 HU_125 HU_126 HU_131 HU_134 HU_149 HU_150 HU_173 HU_179 HU_180 HU_182 HU_202 HU_204 HU_209 +HMDB01032 2569204.92420381 6222035.77434915 17070707.9912636 1258838.24348419 13039543.0754619 1909391.77026598 3495.09386434063 2293521.90928998 128503.275117713 81872.5276382213 8103557.56578035 149574887.036181 1544036.41049333 7103429.53933206 14138796.50382 4970265.57952158 263054.73056162 1671332.30008058 88433.1944958815 23602331.2894815 18648126.5206986 1554657.98756878 34152.3646391152 209372.71275317 33187733.370626 202438.591636003 13581070.0886437 354170.810678102 9120781.48986975 43419175.4051586 +HMDB03072 3628416.30251025 65626.9834353751 112170.118946651 3261804.34422417 42228.2787747563 343254.201250707 1958217.69317664 11983270.0435677 5932111.41638028 5511385.83359531 9154521.47755199 2632133.21209418 9500411.14556502 6551644.51726592 7204319.80891836 1273412.04795188 3260583.81592376 8932005.5351622 8340827.52597275 9256460.69197759 11217839.169041 5919262.81433556 11790077.0657915 9567977.80797097 73717.5811684739 9991787.29074293 4208098.14739633 623970.649925847 10904221.2642849 2171793.93621067 +HMDB00792 429568.609438384 3887629.50527037 1330692.11658995 1367446.73023821 844197.447472453 2948090.71886592 1614157.90566884 3740009.19379795 3292251.66531919 2310688.79492013 4404239.59008605 3043289.12780863 825736.467181043 2523241.91730649 6030501.02648005 474901.604069803 2885792.42617652 2955990.64049134 1917716.3427982 1767962.67737699 5926203.40397675 1639065.69474684 346810.763557826 1054776.22313737 2390258.27543894 1831346.37315857 1026696.36904362 7079792.50047866 4368341.01359769 3495986.87280275 |
b |
diff -r 000000000000 -r ef64d3752050 tests/input/sampleMetadata.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/input/sampleMetadata.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,31 @@ +sample age ageGroup +HU_017 41 experienced +HU_021 34 junior +HU_027 37 experienced +HU_032 38 experienced +HU_041 28 junior +HU_048 39 experienced +HU_049 50 senior +HU_050 30 junior +HU_052 51 senior +HU_059 81 senior +HU_060 55 senior +HU_066 25 junior +HU_072 47 experienced +HU_077 27 junior +HU_090 46 experienced +HU_109 32 junior +HU_110 50 senior +HU_125 58 senior +HU_126 45 experienced +HU_131 42 experienced +HU_134 48 experienced +HU_149 35 experienced +HU_150 49 experienced +HU_173 55 senior +HU_179 33 junior +HU_180 53 senior +HU_182 43 experienced +HU_202 42 experienced +HU_204 31 junior +HU_209 17.5 junior |
b |
diff -r 000000000000 -r ef64d3752050 tests/input/variableMetadata.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/input/variableMetadata.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,4 @@ +variable name +HMDB01032 Dehydroepiandrosterone sulfate +HMDB03072 Quinic acid +HMDB00792 Sebacic acid |
b |
diff -r 000000000000 -r ef64d3752050 tests/output/information.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/output/information.txt Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,8 @@ + +Start of the 'Univariate' Galaxy module call: sam. 21 mai 2016 20:25:53 + +Performing 'ttest' + +No significant variable found at the selected 0.05 level + +End of 'Univariate' Galaxy module call: 2016-05-21 20:25:53 |
b |
diff -r 000000000000 -r ef64d3752050 tests/output/variableMetadata.tsv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/output/variableMetadata.tsv Wed Jul 27 11:44:34 2016 -0400 |
b |
@@ -0,0 +1,4 @@ +variableMetadata PCA_XLOAD-h1 PCA_XLOAD-h2 jour_ttest_J3-J10_dif jour_ttest_J3-J10_fdr jour_ttest_J3-J10_sig +MT1 -0.048723936 0.05648187 -0.0359710196666665 0.827558403950534 0 +MT2 -0.067609139 0.084300327 -0.0676994936666668 0.827558403950534 0 +MT3 0.080335733 -0.0215397 0.163601670666666 0.760596565270778 0 |
b |
diff -r 000000000000 -r ef64d3752050 tests/univariate_tests.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/univariate_tests.R Wed Jul 27 11:44:34 2016 -0400 |
[ |
@@ -0,0 +1,194 @@ +library(RUnit) + +wrapperF <- function(argVc) { + + + source("../univariate_script.R") + + +#### Start_of_testing_code <- function() {} + + + ##------------------------------ + ## Initializing + ##------------------------------ + + ## options + ##-------- + + strAsFacL <- options()$stringsAsFactors + options(stringsAsFactors = FALSE) + + ## packages + ##--------- + + library(PMCMR) + + ## constants + ##---------- + + modNamC <- "Univariate" ## module name + + topEnvC <- environment() + flagC <- "\n" + + ## functions + ##---------- + + flgF <- function(tesC, + envC = topEnvC, + txtC = NA) { ## management of warning and error messages + + tesL <- eval(parse(text = tesC), envir = envC) + + if(!tesL) { + + sink(NULL) + stpTxtC <- ifelse(is.na(txtC), + paste0(tesC, " is FALSE"), + txtC) + + stop(stpTxtC, + call. = FALSE) + + } + + } ## flgF + + ## log file + ##--------- + + sink(argVc["information"]) + + cat("\nStart of the '", modNamC, "' Galaxy module call: ", + format(Sys.time(), "%a %d %b %Y %X"), "\n", sep="") + + ## loading + ##-------- + + datMN <- t(as.matrix(read.table(argVc["dataMatrix_in"], + check.names = FALSE, + header = TRUE, + row.names = 1, + sep = "\t"))) + + samDF <- read.table(argVc["sampleMetadata_in"], + check.names = FALSE, + header = TRUE, + row.names = 1, + sep = "\t") + + varDF <- read.table(argVc["variableMetadata_in"], + check.names = FALSE, + header = TRUE, + row.names = 1, + sep = "\t") + + tesC <- argVc["tesC"] + + ## checking + ##--------- + + flgF("identical(rownames(datMN), rownames(samDF))", txtC = "Column names of the dataMatrix are not identical to the row names of the sampleMetadata; check your data with the 'Check Format' module in the 'Quality Control' section") + flgF("identical(colnames(datMN), rownames(varDF))", txtC = "Row names of the dataMatrix are not identical to the row names of the variableMetadata; check your data with the 'Check Format' module in the 'Quality Control' section") + + flgF("argVc['facC'] %in% colnames(samDF)", txtC = paste0("Required factor of interest '", argVc['facC'], "' could not be found in the column names of the sampleMetadata")) + flgF("mode(samDF[, argVc['facC']]) %in% c('character', 'numeric')", txtC = paste0("The '", argVc['facC'], "' column of the sampleMetadata should contain either number only, or character only")) + + flgF("!(tesC %in% c('ttest', 'wilcoxon')) || (mode(samDF[, argVc['facC']]) == 'character' && length(unique(samDF[, argVc['facC']])) == 2)", txtC = paste0("For 'ttest' and 'wilcoxon', the chosen factor column ('", argVc['facC'], "') of the sampleMetadata should contain characters with only two different classes")) + flgF("!(tesC %in% c('anova', 'kruskal')) || (mode(samDF[, argVc['facC']]) == 'character' && length(unique(samDF[, argVc['facC']])) > 2)", txtC = paste0("For 'anova' and 'kruskal', the chosen factor column ('", argVc['facC'], "') of the sampleMetadata should contain characters with at least three different classes")) + flgF("!(tesC %in% c('pearson', 'spearman')) || mode(samDF[, argVc['facC']]) == 'numeric'", txtC = paste0("For 'pearson' and 'spearman', the chosen factor column ('", argVc['facC'], "') of the sampleMetadata should contain numbers only")) + + flgF("argVc['adjC'] %in% c('holm', 'hochberg', 'hommel', 'bonferroni', 'BH', 'BY', 'fdr', 'none')") + + flgF("0 <= as.numeric(argVc['thrN']) && as.numeric(argVc['thrN']) <= 1", + txtC = "(corrected) p-value threshold must be between 0 and 1") + + + ##------------------------------ + ## Computation + ##------------------------------ + + + varDF <- univariateF(datMN = datMN, + samDF = samDF, + varDF = varDF, + facC = argVc["facC"], + tesC = tesC, + adjC = argVc["adjC"], + thrN = as.numeric(argVc["thrN"])) + + + ##------------------------------ + ## Ending + ##------------------------------ + + + ## saving + ##-------- + + varDF <- cbind.data.frame(variableMetadata = rownames(varDF), + varDF) + write.table(varDF, + file = argVc["variableMetadata_out"], + quote = FALSE, + row.names = FALSE, + sep = "\t") + + ## closing + ##-------- + + cat("\nEnd of '", modNamC, "' Galaxy module call: ", + as.character(Sys.time()), "\n", sep = "") + + sink() + + options(stringsAsFactors = strAsFacL) + + + +#### End_of_testing_code <- function() {} + + + return(list(varDF = varDF)) + + rm(list = ls()) + +} + +exaDirOutC <- "output" +if(!file.exists(exaDirOutC)) + stop("Please create an 'output' subfolder into the (current) 'tests' folder") + +tesArgLs <- list(input_kruskal = c(facC = "ageGroup", + tesC = "kruskal", + adjC = "fdr", + thrN = "0.05", + .chkC = "checkEqualsNumeric(outLs[['varDF']]['HMDB01032', 'ageGroup_kruskal_senior-experienced_pva'], 0.1231246, tolerance = 1e-6)"), + example1_wilcoxDif = c(facC = "jour", + tesC = "wilcoxon", + adjC = "fdr", + thrN = "0.05", + .chkC = "checkEqualsNumeric(outLs[['varDF']]['MT3', 'jour_wilcoxon_J3-J10_dif'], 0.216480042, tolerance = 1e-8)"), + example1_ttestFdr = c(facC = "jour", + tesC = "ttest", + adjC = "fdr", + thrN = "0.05", + .chkC = "checkEqualsNumeric(outLs[['varDF']]['MT3', 'jour_ttest_J3-J10_fdr'], 0.7605966, tolerance = 1e-6)")) + +for(tesC in names(tesArgLs)) + tesArgLs[[tesC]] <- c(tesArgLs[[tesC]], + dataMatrix_in = file.path(unlist(strsplit(tesC, "_"))[1], "dataMatrix.tsv"), + sampleMetadata_in = file.path(unlist(strsplit(tesC, "_"))[1], "sampleMetadata.tsv"), + variableMetadata_in = file.path(unlist(strsplit(tesC, "_"))[1], "variableMetadata.tsv"), + variableMetadata_out = file.path(exaDirOutC, "variableMetadata.tsv"), + information = file.path(exaDirOutC, "information.txt")) + +for(tesC in names(tesArgLs)) { + print(tesC) + outLs <- wrapperF(tesArgLs[[tesC]]) + if(".chkC" %in% names(tesArgLs[[tesC]])) + stopifnot(eval(parse(text = tesArgLs[[tesC]][[".chkC"]]))) +} + +message("Checks successfully completed") |
b |
diff -r 000000000000 -r ef64d3752050 univariate_config.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/univariate_config.xml Wed Jul 27 11:44:34 2016 -0400 |
[ |
b'@@ -0,0 +1,313 @@\n+<tool id="Univariate" name="Univariate" version="2.1.1">\n+ <description>Univariate statistics</description>\n+\n+\t<requirements>\n+\t\t<requirement type="package" version="3.2.2">R</requirement>\n+\t\t<requirement type="package">r-batch</requirement>\n+\t\t<requirement type="package">r-pmcmr</requirement>\n+\t</requirements>\n+\n+ <command><![CDATA[\n+\t $__tool_directory__/univariate_wrapper.R\n+ dataMatrix_in "$dataMatrix_in"\n+ sampleMetadata_in "$sampleMetadata_in"\n+ variableMetadata_in "$variableMetadata_in"\n+\n+\t facC "$facC"\n+\t tesC "$tesC"\n+\t adjC "$adjC"\n+\t thrN "$thrN"\t \n+\n+ variableMetadata_out "$variableMetadata_out"\n+\t information "$information"\n+ ]]></command>\n+\n+ <inputs>\n+\t<param name="dataMatrix_in" label="Data matrix file" type="data" format="tabular" help="variable x sample, decimal: \'.\', missing: NA, mode: numerical, sep: tabular" />\n+\t<param name="sampleMetadata_in" label="Sample metadata file" type="data" format="tabular" help="sample x metadata, decimal: \'.\', missing: NA, mode: character and numerical, sep: tabular" />\n+\t<param name="variableMetadata_in" label="Variable metadata file" type="data" format="tabular" help="variable x metadata, decimal: \'.\', missing: NA, mode: character and numerical, sep: tabular" />\n+ <param name="facC" label="Factor of interest" type="text" help="Name of the column of the sample metadata table corresponding to the qualitative or quantitative variable"/>\n+ <param name="tesC" label="Test" type="select" help="">\n+\t\t<option value="ttest">ttest (qualitative, 2 levels)</option>\n+ <option value="wilcoxon">Wilcoxon test (qualitative, 2 levels)</option> \n+\t\t<option value="anova">Analysis of variance (qualitative, more than 2 levels)</option>\n+\t\t<option value="kruskal">Kruskal-Wallis rank test (qualitative, more than 2 levels)</option>\n+\t\t<option value="pearson">Pearson correlation test (quantitative)</option>\n+\t\t<option value="spearman">Spearman correlation rank test (quantitative)</option>\n+ </param>\n+ <param name="adjC" label="Method for multiple testing correction" type="select" help="">\n+\t <option value="fdr">fdr</option>\n+\t\t<option value="BH">BH</option>\n+\t\t<option value="bonferroni">bonferroni</option>\n+\t\t<option value="BY">BY</option>\n+\t\t<option value="hochberg">hochberg</option>\n+ <option value="holm">holm</option>\n+\t\t<option value="hommel">hommel</option>\n+\t\t<option value="none">none</option>\n+ </param>\n+ <param name="thrN" type="float" value="0.05" label="(Corrected) p-value significance threshold" help="Must be between 0 and 1"/>\n+ </inputs>\n+\n+ <outputs>\n+ <data name="variableMetadata_out" label="${tool.name}_${variableMetadata_in.name}" format="tabular" ></data>\n+\t<data name="information" label="${tool.name}_information.txt" format="txt"/>\n+ </outputs>\n+\n+ <tests>\n+\t <test>\n+\t\t <param name="dataMatrix_in" value="dataMatrix.tsv"/>\n+\t\t <param name="sampleMetadata_in" value="sampleMetadata.tsv"/>\n+\t\t <param name="variableMetadata_in" value="variableMetadata.tsv"/>\n+\t\t <param name="facC" value="ageGroup"/>\n+\t\t <param name="tesC" value="kruskal"/>\n+\t\t <param name="adjC" value="fdr"/>\n+\t\t <param name="thrN" value="0.05"/>\n+\t\t <output name="variableMetadata_out" file="variableMetadata-output.tsv"/>\n+\t </test>\n+ </tests>\n+\n+ <help>\n+\n+.. class:: infomark\n+\n+| **Tool update: See the \'NEWS\' section at the bottom of the page**\n+\n+---------------------------------------------------\n+\n+.. class:: infomark\n+\n+**Authors**\n+\n+| **Marie Tremblay-Franco (marie.tremblay-franco@toulouse.inra.fr)** and **Etienne Thevenot (etienne.thevenot@cea.fr)** wrote this wrapper of R univariate statistical tests.\n+| MetaboHUB: The French National Infrastructure for Metabolomics and Fluxomics (http://www.metabohub.fr/en)\n+\n+---------------------------------------------------\n+\n+.. class:: infomark\n+\n+**Please cite**\n+\n+R Core Team (2013). R: A language and Environment for Statistical Computing. http://www.r-proj'..b'el from the Galaxy / ABiMS page by choosing:**\n+| **a) File Format: \'tabular\'**\n+| **b) Convert spaces to tabs: \'Yes\'**\n+| \n+\n+**dataMatrix file**::\n+\n+\tdataMatrix HU_017 HU_021 HU_027 HU_032 HU_041 HU_048 HU_049 HU_050 HU_052 HU_059 HU_060 HU_066 HU_072 HU_077 HU_090 HU_109 HU_110 HU_125 HU_126 HU_131 HU_134 HU_149 HU_150 HU_173 HU_179 HU_180 HU_182 HU_202 HU_204 HU_209\n+\tHMDB01032 2569204.92420381 6222035.77434915 17070707.9912636 1258838.24348419 13039543.0754619 1909391.77026598 3495.09386434063 2293521.90928998 128503.275117713 81872.5276382213 8103557.56578035 149574887.036181 1544036.41049333 7103429.53933206 14138796.50382 4970265.57952158 263054.73056162 1671332.30008058 88433.1944958815 23602331.2894815 18648126.5206986 1554657.98756878 34152.3646391152 209372.71275317 33187733.370626 202438.591636003 13581070.0886437 354170.810678102 9120781.48986975 43419175.4051586\n+\tHMDB03072 3628416.30251025 65626.9834353751 112170.118946651 3261804.34422417 42228.2787747563 343254.201250707 1958217.69317664 11983270.0435677 5932111.41638028 5511385.83359531 9154521.47755199 2632133.21209418 9500411.14556502 6551644.51726592 7204319.80891836 1273412.04795188 3260583.81592376 8932005.5351622 8340827.52597275 9256460.69197759 11217839.169041 5919262.81433556 11790077.0657915 9567977.80797097 73717.5811684739 9991787.29074293 4208098.14739633 623970.649925847 10904221.2642849 2171793.93621067\n+\tHMDB00792 429568.609438384 3887629.50527037 1330692.11658995 1367446.73023821 844197.447472453 2948090.71886592 1614157.90566884 3740009.19379795 3292251.66531919 2310688.79492013 4404239.59008605 3043289.12780863 825736.467181043 2523241.91730649 6030501.02648005 474901.604069803 2885792.42617652 2955990.64049134 1917716.3427982 1767962.67737699 5926203.40397675 1639065.69474684 346810.763557826 1054776.22313737 2390258.27543894 1831346.37315857 1026696.36904362 7079792.50047866 4368341.01359769 3495986.87280275\n+\n+\t\n+**sampleMetadata file**::\n+\n+\tsampleMetadata age ageGrp\n+\tHU_017 41 experienced\n+\tHU_021 34 junior\n+\tHU_027 37 experienced\n+\tHU_032 38 experienced\n+\tHU_041 28 junior\n+\tHU_048 39 experienced\n+\tHU_049 50 senior\n+\tHU_050 30 junior\n+\tHU_052 51 senior\n+\tHU_059 81 senior\n+\tHU_060 55 senior\n+\tHU_066 25 junior\n+\tHU_072 47 experienced\n+\tHU_077 27 junior\n+\tHU_090 46 experienced\n+\tHU_109 32 junior\n+\tHU_110 50 senior\n+\tHU_125 58 senior\n+\tHU_126 45 experienced\n+\tHU_131 42 experienced\n+\tHU_134 48 experienced\n+\tHU_149 35 experienced\n+\tHU_150 49 experienced\n+\tHU_173 55 senior\n+\tHU_179 33 junior\n+\tHU_180 53 senior\n+\tHU_182 43 experienced\n+\tHU_202 42 experienced\n+\tHU_204 31 junior\n+\tHU_209 17.5 junior\n+\n+\t\n+**variableMetadata file**::\n+\n+\tvariableMetadata name\n+\tHMDB01032 Dehydroepiandrosterone sulfate\n+\tHMDB03072 Quinic acid\n+\tHMDB00792 Sebacic acid\n+\n+\t\n+Parameters\n+==========\n+\n+**Factor of interest:** "ageGroup"\n+\n+**Test:** "Kruskal-Wallis rank test (qualitative, > 2 levels)"\n+ \n+**Method for multiple testing correction:** "fdr"\n+\n+**(Corrected) p-value significance threshold:** 0.05\n+\n+\n+Output files\n+============\n+\n++------------------------------+------------+\n+| File | Format |\n++==============================+============+\n+| 1) dataMatrix | tabular |\n++------------------------------+------------+\n+| 2) sampleMetadata | tabular |\n++------------------------------+------------+\n+| 3) variableMetadata | tabular |\n++------------------------------+------------+\n+| 4) information | text |\n++------------------------------+------------+\n+\n+\n+---------------------------------------------------\n+\n+----\n+NEWS\n+----\n+\n+CHANGES IN VERSION 2.1.1\n+========================\n+\n+Internal handling of \'NA\' p-values (e.g. when intensities are identical in all samples)\n+\n+CHANGES IN VERSION 2.0.1\n+========================\n+\n+(corrected) p-value threshold can be set to any value between 0 and 1\n+\n+\n+ </help>\n+\n+ <citations/>\n+\n+</tool>\n' |
b |
diff -r 000000000000 -r ef64d3752050 univariate_script.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/univariate_script.R Wed Jul 27 11:44:34 2016 -0400 |
[ |
@@ -0,0 +1,148 @@ +univariateF <- function(datMN, + samDF, + varDF, + facC, + tesC = c("ttest", "wilcoxon", "anova", "kruskal", "pearson", "spearman")[1], + adjC = c("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none")[7], + thrN = 0.05) { + + + ## Option + ##--------------- + + strAsFacL <- options()$stringsAsFactors + options(stingsAsFactors = FALSE) + options(warn = -1) + + if(mode(samDF[, facC]) == "character") { + facFcVn <- factor(samDF[, facC]) + facLevVc <- levels(facFcVn) + } else + facFcVn <- samDF[, facC] + + cat("\nPerforming '", tesC, "'\n", sep="") + + varPfxC <- paste0(make.names(facC), "_", tesC, "_") + + if(tesC %in% c("ttest", "wilcoxon", "pearson", "spearman")) { + + switch(tesC, + ttest = { + staF <- function(y) diff(tapply(y, facFcVn, function(x) mean(x, na.rm = TRUE))) + tesF <- function(y) t.test(y ~ facFcVn)[["p.value"]] + }, + wilcoxon = { + staF <- function(y) diff(tapply(y, facFcVn, function(x) median(x, na.rm = TRUE))) + tesF <- function(y) wilcox.test(y ~ facFcVn)[["p.value"]] + }, + pearson = { + staF <- function(y) cor(facFcVn, y, method = "pearson", use = "pairwise.complete.obs") + tesF <- function(y) cor.test(facFcVn, y, method = "pearson", use = "pairwise.complete.obs")[["p.value"]] + }, + spearman = { + staF <- function(y) cor(facFcVn, y, method = "spearman", use = "pairwise.complete.obs") + tesF <- function(y) cor.test(facFcVn, y, method = "spearman", use = "pairwise.complete.obs")[["p.value"]] + }) + + staVn <- apply(datMN, 2, staF) + + fdrVn <- p.adjust(apply(datMN, + 2, + tesF), + method = adjC) + + sigVn <- as.numeric(fdrVn < thrN) + + if(tesC %in% c("ttest", "wilcoxon")) + varPfxC <- paste0(varPfxC, paste(rev(facLevVc), collapse = "-"), "_") + + varDF[, paste0(varPfxC, ifelse(tesC %in% c("ttest", "wilcoxon"), "dif", "cor"))] <- staVn + + varDF[, paste0(varPfxC, adjC)] <- fdrVn + + varDF[, paste0(varPfxC, "sig")] <- sigVn + + } else if(tesC == "anova") { + + ## getting the names of the pairwise comparisons 'class1Vclass2' + prwVc <- rownames(TukeyHSD(aov(datMN[, 1] ~ facFcVn))[["facFcVn"]]) + + aovMN <- t(apply(datMN, 2, function(varVn) { + + aovMod <- aov(varVn ~ facFcVn) + pvaN <- summary(aovMod)[[1]][1, "Pr(>F)"] + hsdMN <- TukeyHSD(aovMod)[["facFcVn"]] + c(pvaN, c(hsdMN[, c("diff", "p adj")]), as.numeric(hsdMN[, "p adj"] < thrN)) + + })) + + aovMN[, 1] <- p.adjust(aovMN[, 1], method = adjC) + sigVn <- as.numeric(aovMN[, 1] < thrN) + aovMN <- cbind(aovMN[, 1], sigVn, aovMN[, 2:ncol(aovMN)]) + ## aovMN[which(aovMN[, 2] < 1), (3 + length(prwVc)):ncol(aovMN)] <- NA + colnames(aovMN) <- paste0(varPfxC, + c(adjC, + "sig", + paste0(prwVc, "_dif"), + paste0(prwVc, "_pva"), + paste0(prwVc, "_sig"))) + aovMN[which(aovMN[, paste0(varPfxC, "sig")] < 1), paste0(varPfxC, c(paste0(prwVc, "_pva"), paste0(prwVc, "_sig")))] <- NA + + varDF <- cbind.data.frame(varDF, as.data.frame(aovMN)) + + } else if(tesC == "kruskal") { + + ## getting the names of the pairwise comparisons 'class1Vclass2' + nemMN <- posthoc.kruskal.nemenyi.test(datMN[, 1], facFcVn, "Tukey")[["p.value"]] + nemVl <- c(lower.tri(nemMN, diag = TRUE)) + nemClaMC <- cbind(rownames(nemMN)[c(row(nemMN))][nemVl], + colnames(nemMN)[c(col(nemMN))][nemVl]) + nemNamVc <- paste0(nemClaMC[, 1], "-", nemClaMC[, 2]) + nemNamVc <- paste0(varPfxC, nemNamVc) + + nemMN <- t(apply(datMN, 2, function(varVn) { + + pvaN <- kruskal.test(varVn ~ facFcVn)[["p.value"]] + varNemMN <- posthoc.kruskal.nemenyi.test(varVn, facFcVn, "Tukey")[["p.value"]] + c(pvaN, c(varNemMN)) + + })) + pvaVn <- nemMN[, 1] + fdrVn <- p.adjust(pvaVn, method = adjC) + sigVn <- as.numeric(fdrVn < thrN) + nemMN <- nemMN[, c(FALSE, nemVl)] + colnames(nemMN) <- paste0(nemNamVc, "_pva") + nemSigMN <- nemMN < thrN + mode(nemSigMN) <- "numeric" + colnames(nemSigMN) <- paste0(nemNamVc, "_sig") + nemMN[sigVn < 1, ] <- NA + nemSigMN[sigVn < 1, ] <- NA + + difMN <- sapply(1:nrow(nemClaMC), function(prwI) { + prwVc <- nemClaMC[prwI, ] + prwVi <- which(facFcVn %in% prwVc) + prwFacFc <- factor(as.character(facFcVn)[prwVi], levels = prwVc) + apply(datMN[prwVi, ], 2, function(varVn) -diff(as.numeric(tapply(varVn, prwFacFc, function(x) median(x, na.rm = TRUE))))) + }) + colnames(difMN) <- gsub("_sig", "_dif", colnames(nemSigMN)) + + nemMN <- cbind(fdrVn, sigVn, difMN, nemMN, nemSigMN) + colnames(nemMN)[1:2] <- paste0(varPfxC, c(adjC, "sig")) + + varDF <- cbind.data.frame(varDF, as.data.frame(nemMN)) + + } + + names(sigVn) <- rownames(varDF) + sigSumN <- sum(sigVn, na.rm = TRUE) + if(sigSumN) { + cat("\nThe following ", sigSumN, " variable", ifelse(sigSumN > 1, "s", ""), " (", round(sigSumN / length(sigVn) * 100), "%) ", ifelse(sigSumN > 1, "were", "was"), " found significant at the ", thrN, " level:\n", sep = "") + cat(paste(rownames(varDF)[sigVn > 0], collapse = "\n"), "\n", sep = "") + } else + cat("\nNo significant variable found at the selected ", thrN, " level\n", sep = "") + + options(stingsAsFactors = strAsFacL) + + return(varDF) + +} |
b |
diff -r 000000000000 -r ef64d3752050 univariate_wrapper.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/univariate_wrapper.R Wed Jul 27 11:44:34 2016 -0400 |
[ |
@@ -0,0 +1,159 @@ +#!/usr/bin/env Rscript + +library(batch) ## parseCommandArgs + +source_local <- function(fname){ + argv <- commandArgs(trailingOnly = FALSE) + base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) + source(paste(base_dir, fname, sep="/")) +} + +source_local("univariate_script.R") + +argVc <- unlist(parseCommandArgs(evaluate=FALSE)) + + +#### Start_of_tested_code <- function() {} + + +##------------------------------ +## Initializing +##------------------------------ + +## options +##-------- + +strAsFacL <- options()$stringsAsFactors +options(stringsAsFactors = FALSE) + +## packages +##--------- + +library(PMCMR) + +## constants +##---------- + +modNamC <- "Univariate" ## module name + +topEnvC <- environment() +flagC <- "\n" + +## functions +##---------- + +flgF <- function(tesC, + envC = topEnvC, + txtC = NA) { ## management of warning and error messages + + tesL <- eval(parse(text = tesC), envir = envC) + + if(!tesL) { + + sink(NULL) + stpTxtC <- ifelse(is.na(txtC), + paste0(tesC, " is FALSE"), + txtC) + + stop(stpTxtC, + call. = FALSE) + + } + +} ## flgF + +## log file +##--------- + +sink(argVc["information"]) + +cat("\nStart of the '", modNamC, "' Galaxy module call: ", + format(Sys.time(), "%a %d %b %Y %X"), "\n", sep="") + +## loading +##-------- + +datMN <- t(as.matrix(read.table(argVc["dataMatrix_in"], + check.names = FALSE, + header = TRUE, + row.names = 1, + sep = "\t"))) + +samDF <- read.table(argVc["sampleMetadata_in"], + check.names = FALSE, + header = TRUE, + row.names = 1, + sep = "\t") + +varDF <- read.table(argVc["variableMetadata_in"], + check.names = FALSE, + header = TRUE, + row.names = 1, + sep = "\t") + +tesC <- argVc["tesC"] + +## checking +##--------- + +flgF("identical(rownames(datMN), rownames(samDF))", txtC = "Column names of the dataMatrix are not identical to the row names of the sampleMetadata; check your data with the 'Check Format' module in the 'Quality Control' section") +flgF("identical(colnames(datMN), rownames(varDF))", txtC = "Row names of the dataMatrix are not identical to the row names of the variableMetadata; check your data with the 'Check Format' module in the 'Quality Control' section") + +flgF("argVc['facC'] %in% colnames(samDF)", txtC = paste0("Required factor of interest '", argVc['facC'], "' could not be found in the column names of the sampleMetadata")) +flgF("mode(samDF[, argVc['facC']]) %in% c('character', 'numeric')", txtC = paste0("The '", argVc['facC'], "' column of the sampleMetadata should contain either number only, or character only")) + +flgF("!(tesC %in% c('ttest', 'wilcoxon')) || (mode(samDF[, argVc['facC']]) == 'character' && length(unique(samDF[, argVc['facC']])) == 2)", txtC = paste0("For 'ttest' and 'wilcoxon', the chosen factor column ('", argVc['facC'], "') of the sampleMetadata should contain characters with only two different classes")) +flgF("!(tesC %in% c('anova', 'kruskal')) || (mode(samDF[, argVc['facC']]) == 'character' && length(unique(samDF[, argVc['facC']])) > 2)", txtC = paste0("For 'anova' and 'kruskal', the chosen factor column ('", argVc['facC'], "') of the sampleMetadata should contain characters with at least three different classes")) +flgF("!(tesC %in% c('pearson', 'spearman')) || mode(samDF[, argVc['facC']]) == 'numeric'", txtC = paste0("For 'pearson' and 'spearman', the chosen factor column ('", argVc['facC'], "') of the sampleMetadata should contain numbers only")) + +flgF("argVc['adjC'] %in% c('holm', 'hochberg', 'hommel', 'bonferroni', 'BH', 'BY', 'fdr', 'none')") + +flgF("0 <= as.numeric(argVc['thrN']) && as.numeric(argVc['thrN']) <= 1", + txtC = "(corrected) p-value threshold must be between 0 and 1") + + +##------------------------------ +## Computation +##------------------------------ + + +varDF <- univariateF(datMN = datMN, + samDF = samDF, + varDF = varDF, + facC = argVc["facC"], + tesC = tesC, + adjC = argVc["adjC"], + thrN = as.numeric(argVc["thrN"])) + + +##------------------------------ +## Ending +##------------------------------ + + +## saving +##-------- + +varDF <- cbind.data.frame(variableMetadata = rownames(varDF), + varDF) +write.table(varDF, + file = argVc["variableMetadata_out"], + quote = FALSE, + row.names = FALSE, + sep = "\t") + +## closing +##-------- + +cat("\nEnd of '", modNamC, "' Galaxy module call: ", + as.character(Sys.time()), "\n", sep = "") + +sink() + +options(stringsAsFactors = strAsFacL) + + +#### End_of_tested_code <- function() {} + + +rm(list = ls()) |