-
Notifications
You must be signed in to change notification settings - Fork 29
migration of table-merge #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8bb3862
3a3b7b3
b821ebe
0b7cca8
0721149
4c8c135
0c48e22
c81ccae
e5e01e8
1fd4d2b
ecbe939
8fea2f2
b97966e
be0512f
e39d5fa
da42566
fa9a86d
c8a2741
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
tool_test_output.html | ||
tool_test_output.json | ||
.Rhistory |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
categories: | ||
- Metabolomics | ||
description: '[W4M][Utils] Merging dataMatrix with a metadata table.' | ||
homepage_url: http://workflow4metabolomics.org | ||
remote_repository_url: https://github.com/workflow4metabolomics/tools-metabolomics | ||
long_description: 'Part of the W4M project: http://workflow4metabolomics.org / The | ||
R script merges the data matrix with a selected metadata file (sample metadata or | ||
variable metadata) to obtain a single file.' | ||
name: tablemerge | ||
owner: melpetera | ||
type: unrestricted |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Table Merge | ||
|
||
|
||
Metadata | ||
----------- | ||
|
||
* **@name**: Table Merge | ||
* **@galaxyID**: tablemerge | ||
* **@version**: 1.0.2+galaxy1 | ||
* **@authors**: Original code: Melanie Petera (PFEM - INRAE - MetaboHUB) - Maintainer: Melanie Petera (PFEM - INRAE - MetaboHUB) | ||
* **@init date**: 2016, July | ||
* **@main usage**: This tool enables the aggregation of a dataMatrix with one of its metadata (sample or variable metadata). | ||
|
||
|
||
Context | ||
----------- | ||
|
||
This tool is provided as one of the [Workflow4Metabolomics](http://workflow4metabolomics.org) Galaxy instance data handling tools. | ||
W4M is an international infrastructure providing software tools to process, analyse and annotate metabolomics data. | ||
|
||
User interface is based on the Galaxy platform (homepage: https://galaxyproject.org/). It is an open, web-based platform for data intensive biomedical research. | ||
Whether on the free public server or your own instance, you can perform, reproduce, and share complete analyses. | ||
|
||
Configuration | ||
----------- | ||
|
||
### Requirement: | ||
* R software: version = 4.3.3 recommended | ||
* r-w4mrutils = 1.0.0 | ||
|
||
Technical description | ||
----------- | ||
|
||
Main files: | ||
|
||
- tablemerge_script.R: R function (core script) | ||
- tablemerge.xml: XML wrapper (interface for Galaxy) | ||
|
||
|
||
Services provided | ||
----------- | ||
|
||
* Help and support: https://community.france-bioinformatique.fr/c/workflow4metabolomics/10 | ||
|
||
|
||
|
||
License | ||
----------- | ||
|
||
* Cea Cnrs Inria Logiciel Libre License, version 2.1 (CECILL-2.1) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
<tool id="tablemerge" name="Table Merge" version="1.0.2+galaxy1" profile="24.2"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this entire file could need a reformat with the galaxy-language-server There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May I ask what this corresponds to? I am not familiar with galaxy-language-server There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/galaxyproject/galaxy-language-server it will help you write, lint, reformat your tools, its a plugin for Visual Studio Code to work very smoothly with Galaxy tools. You can bootstrap tools, add test sections automatically etc ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The linting passed though ? 🙃 |
||
<description>Merging dataMatrix with a metadata table</description> | ||
<edam_topics> | ||
<edam_topic>topic_0769</edam_topic> | ||
</edam_topics> | ||
<edam_operations> | ||
<edam_operation>operation_3436</edam_operation> | ||
</edam_operations> | ||
<creator> | ||
<organization url="https://workflow4metabolomics.org/" email="[email protected]" name="Workflow4Metabolomics" /> | ||
</creator> | ||
<requirements> | ||
<requirement type="package" version="1.0.0">r-w4mrutils</requirement> | ||
</requirements> | ||
|
||
<required_files> | ||
<include path="tablemerge_script.R" /> | ||
</required_files> | ||
|
||
<command detect_errors="exit_code"><![CDATA[ | ||
Rscript -e 'source("$__tool_directory__/tablemerge_script.R")' -e 'tab.merge("$dataMatrix_in", "$Metadata_in", "$metatype", "$combined_out")' | ||
]]></command> | ||
|
||
<inputs> | ||
<param name="dataMatrix_in" type="data" label="Data matrix file" help="" format="tabular" /> | ||
<param name="Metadata_in" type="data" label="Metadata file" help="Sample metadata or variable metadata" format="tabular" /> | ||
|
||
<param name="metatype" label="Type of metadata" type="select" display="radio" help=""> | ||
<option value="sample">Sample metadata</option> | ||
<option value="variable">Variable metadata</option> | ||
</param> | ||
|
||
</inputs> | ||
|
||
<outputs> | ||
<data name="combined_out" label="Combined_${Metadata_in.name}" format="tabular" ></data> | ||
</outputs> | ||
|
||
<tests> | ||
<test> | ||
<param name="dataMatrix_in" value="input_TM12_dataMatrix.txt"/> | ||
<param name="Metadata_in" value="input_TM1_variableMetadata.txt"/> | ||
<param name="metatype" value="variable"/> | ||
<output name="combined_out" file="output_TM1_expected.tabular"/> | ||
</test> | ||
<test> | ||
<param name="dataMatrix_in" value="input_TM12_dataMatrix.txt"/> | ||
<param name="Metadata_in" value="input_TM2_sampleMetadata.txt"/> | ||
<param name="metatype" value="sample"/> | ||
<output name="combined_out" file="output_TM2_expected.tabular"/> | ||
</test> | ||
</tests> | ||
|
||
|
||
<help><![CDATA[ | ||
|
||
.. class:: infomark | ||
|
||
**Credits** | ||
| **Original tool code & wrapping:** Melanie Petera - PFEM ; INRAE ; MetaboHUB | ||
| **Original tool code & wrapping maintainer:** Melanie Petera - PFEM ; INRAE ; MetaboHUB | ||
|
||
.. class:: infomark | ||
|
||
**Contact:** For any questions or support: community.france-bioinformatique.fr/c/workflow4metabolomics/ | ||
|
||
--------------------------------------------------- | ||
|
||
*********** | ||
Table Merge | ||
*********** | ||
|
||
=========== | ||
DESCRIPTION | ||
=========== | ||
|
||
Merges the data matrix with a selected metadata file (sample metadata or variable metadata) to obtain a single file. | ||
|
||
--------------------------------------------------- | ||
|
||
========================== | ||
ALIGNMENT WITH OTHER TOOLS | ||
========================== | ||
|
||
----------- | ||
INPUT FILES | ||
----------- | ||
|
||
+----------------------------+---------+ | ||
| Parameter : num + label | Format | | ||
+============================+=========+ | ||
| 1 : Data matrix file | tabular | | ||
+----------------------------+---------+ | ||
| 2 : Metadata file | tabular | | ||
+----------------------------+---------+ | ||
|
||
Data matrix file contains the intensity values of the variables. | ||
| | ||
|
||
Metadata file is meant to be chosen from sample metadata and variable metadata files. | ||
| | ||
|
||
.. class:: warningmark | ||
|
||
For more information about input files, refer to the corresponding "W4M HowTo" page: | ||
| `W4M table format for Galaxy <https://nextcloud.inrae.fr/s/qLkNZRf84QQ5YLY>`_ | ||
| | ||
|
||
------------ | ||
OUTPUT FILES | ||
------------ | ||
|
||
Combined_Metadata | ||
| tabular output | ||
| Corresponds to the input metadata file completed as new columns by the intensities in the input data matrix file | ||
| | ||
|
||
---------------------------- | ||
EXAMPLE OF WORKFLOW POSITION | ||
---------------------------- | ||
|
||
Can be used as a last step before leaving galaxy, to gather informations into a single file. Might be handy to make further analysis with Symca for instance. | ||
|
||
--------------------------------------------------- | ||
|
||
=============== | ||
TOOL PARAMETERS | ||
=============== | ||
|
||
Type of metadata | ||
| Specify which type of metadata table is given as Metadata file | ||
| | ||
|
||
--------------------------------------------------- | ||
|
||
========== | ||
CHANGE LOG | ||
========== | ||
-------------------------------------- | ||
Version 1.0.2+galaxy1 - September 2022 | ||
-------------------------------------- | ||
INTERNAL MODIFICATION | ||
- Logic of the tool called from generic repository W4MUtils | ||
- Update of tool wrapper to comply with good practices | ||
- Update of help section | ||
|
||
------------------------------- | ||
Version 1.0.2 - September 2022 | ||
------------------------------- | ||
MINORFIX: removal batch package | ||
|
||
|
||
|
||
hechth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
]]></help> | ||
<citations> | ||
<citation type="doi">10.1093/bioinformatics/btu813</citation> | ||
</citations> | ||
</tool> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
################################################################################################ | ||
# TABLE MERGE # | ||
# # | ||
# User: Galaxy # | ||
# Starting date: 16-04-2015 # | ||
# V-0.1: First version of merge code # | ||
# V-0.2: Addition of data check and handling of special characters # | ||
# # | ||
# # | ||
# Input files: dataMatrix ; Metadata file # | ||
# Output files: dataMatrix ; Metadata file # | ||
# # | ||
# Dependencies: RcheckLibrary.R ; miniTools.R # | ||
# # | ||
################################################################################################ | ||
library(W4MRUtils) | ||
|
||
# Parameters (for dev) | ||
if (FALSE) { | ||
DM.name <- "dataMatrix_CleanIons_CleanEch.txt" | ||
meta.name <- "sampleMetadata_CleanEch.txt" | ||
metype <- "sample" | ||
output <- "Combined_${Metadata_in.name}" | ||
} | ||
|
||
|
||
|
||
tab.merge <- function(DM.name, meta.name, metype, output) { | ||
# This function allows to merge the dataMatrix with one metadata table. | ||
# | ||
# Parameters: | ||
# - DM.name, meta.name: dataMatrix and metadata files' access respectively | ||
# - metype: "sample" or "variable" depending on metadata content | ||
# - output: output file's access | ||
|
||
|
||
# Input -------------------------------------------------------------- | ||
DM <- read.table(DM.name, header = TRUE, sep = "\t", check.names = FALSE) | ||
meta <- read.table(meta.name, header = TRUE, sep = "\t", check.names = FALSE, colClasses = "character", comment.char = "") | ||
|
||
# Table match check | ||
table.check <- match2(DM, meta, metype) | ||
check_err(table.check) | ||
|
||
# StockID | ||
meta.id <- stock_id(DM, meta, metype) | ||
DM <- meta.id$dataMatrix | ||
meta <- meta.id$Metadata | ||
meta.id <- meta.id$id.match | ||
|
||
|
||
# Merging tables ----------------------------------------------------- | ||
|
||
if (metype == "sample") { | ||
ori.DM <- DM | ||
rownames(DM) <- DM[, 1] | ||
DM <- DM[, -1] | ||
DM <- t(DM) | ||
DM <- data.frame(sample = row.names(DM), DM, check.names = FALSE) | ||
rownames(DM) <- NULL | ||
} | ||
|
||
comb.data <- merge(x = meta, y = DM, by.x = 1, by.y = 1) | ||
|
||
|
||
# Output ------------------------------------------------------------- | ||
|
||
# Getting back original identifiers | ||
if (metype == "sample") { | ||
id.ori <- reproduce_id(ori.DM, comb.data, metype, meta.id) | ||
} else { | ||
id.ori <- reproduce_id(DM, comb.data, metype, meta.id) | ||
} | ||
comb.data <- id.ori$Metadata | ||
|
||
# Writing the table | ||
write.table(comb.data, output, sep = "\t", quote = FALSE, row.names = FALSE) | ||
} # End of tab.merge | ||
|
||
|
||
# Typical function call | ||
# tab.merge(DM.name,meta.name,metype,output) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
data j 785 y54j 68y4j6 5-6 4 hrh 5h - 3 t564 t54 66 y6y t6 5h (5y g51 ( 6 98 j7-0 06654h 60 | ||
5d_-kkcùf 0.356426723610756 0.380152310071702 0.0306944207412024 0.334137638848017 0.298147485608469 0.975073793297568 0.129099504745855 0.973451663994064 0.334792719284834 0.0751565260418877 0.322897933010729 0.129033714279026 0.722966330196726 0.580654367692078 0.644502528016206 0.352827235332827 0.511778286438001 | ||
npèt 0.801750949101246 0.535593104115636 0.258351312473067 0.599475573145688 0.0763319665667417 0.504558103160623 0.367963830290116 0.440540211857668 0.158066366765388 0.609574253877002 0.550590276177951 0.232864384033621 0.637065775537391 0.424098276140436 0.662053737304139 0.0217541227637467 0.299053946391647 | ||
5PY4(*3 0.875199970420953 0.0825428101366147 0.253659010703906 0.507762246807195 0.856444177031262 0.291594962324086 0.616538655402613 0.388475672176377 0.914254939740854 0.449607330807756 0.628469388494906 0.436558212905713 0.951198610265672 0.956459387015831 0.0113483457928278 0.611559621193868 0.127393349941781 | ||
k 0.235214515530521 0.50917637648828 0.0303152651414629 0.305595242012361 0.470145996588881 0.356776179776951 0.569840649303474 0.720070419680388 0.875026990189028 0.97246313990283 0.936423978578332 0.810603455355391 0.903046784946495 0.667091730522105 0.0282601148338295 0.276666638740528 0.747503427028951 | ||
t v^ptok!R/; 0.251801918471682 0.871383805557867 0.285183681272061 0.552739436194454 0.863766301215097 0.182656918760194 0.977603710051043 0.204845724382198 0.751690583305025 0.751475804910098 0.938399878874186 0.218163132174348 0.523463794277572 0.987156468237196 0.630938391969655 0.495061607430081 0.815474132321848 | ||
ojt* 0.907412839750932 0.857498273276021 0.370137361785406 0.76678484779183 0.213299689296413 0.521214352529346 0.0851731095099456 0.868227767553325 0.0711706993343434 0.70186429888193 0.700568035764899 0.7467824290166 0.570332959002042 0.23270290523468 0.126423339798572 0.816262268500797 0.466363859676536 | ||
lmtki 0.344288940919619 0.308219131305663 0.218449898667526 0.700869668247368 0.932538878977527 0.396198994630489 0.710306820874376 0.124235068279782 0.56608643523601 0.887647287670482 0.0375011938139768 0.282378766400105 0.757492159558571 0.506567258021703 0.990910788272054 0.326205008250378 0.61003856679129 | ||
1h6-(587 t 0.308709890328272 0.717202505490233 0.777934118812417 0.604807545422864 0.588458968776734 0.940112596977594 0.788662314418432 0.133046934771924 0.891405172730758 0.915119678712577 0.401136527896346 0.996068607925829 0.049077648050296 0.157657286859101 0.598183619914656 0.439531332356748 0.11995300831499 | ||
r154 (54 86 0.0861033910635205 0.243889357950567 0.848801588667359 0.972183114768299 0.311829870889657 0.434854970574638 0.0240613698880671 0.273335646139236 0.902686361056168 0.73479376111027 0.232132726965829 0.471097756642369 0.511949019774828 0.934158039531663 0.60125450357768 0.972297241140637 0.63149263296722 | ||
(h4 0.336373953934809 0.521412085356266 0.281632887739949 0.67004516763179 0.0199332367594847 0.867732114278491 0.973477443505332 0.883197938525362 0.334509105447652 0.793947578560618 0.465167375556954 0.508757674191867 0.983758014396725 0.100582744588671 0.501301982240787 0.789637338939369 0.967382850752139 | ||
2 0.65083934802851 0.915695024588 0.0376667088550816 0.514003854683931 0.274761574286474 0.652108809243866 0.689393057486628 0.262205073769319 0.871958663956254 0.709490850507154 0.854477673591409 0.672918329289054 0.141693817710263 0.00543057257281332 0.273084303937691 0.39570748778882 0.303196826092465 | ||
m(yk 0.798331012769621 0.806128809071498 0.519974578571807 0.0237856823099186 0.396426673475168 0.75979784245693 0.0589336105092753 0.763144123705766 0.16086904822931 0.301000258395631 0.321186481311644 0.0091434029302796 0.0346149352313591 0.276366137673702 0.686099471259438 0.0548240244354505 0.909361338008149 | ||
-546 -3 -3 0.981561422839383 0.755973696318293 0.328878596436459 0.233341270249666 0.14569201922932 0.458105216271765 0.191023237667199 0.775603857680909 0.146769440956804 0.86812372109824 0.601678275863019 0.782019307745586 0.955614654474782 0.836058192741214 0.454550085076576 0.181788519803465 0.325277631599655 | ||
nz^à t 0.920089977342539 0.249031996586174 0.105577675363886 0.805216649434891 0.505774902707566 0.619612431793644 0.337662179244335 0.672829320507873 0.387228581340173 0.209795853201976 0.0403285073621635 0.540614252108851 0.43362855410287 0.160204078494507 0.924783730297701 0.116837628312753 0.58763473928668 | ||
kzjù 0.418651623550921 0.668434005412235 0.845525871017258 0.567468950919516 0.111441846749533 0.411424602517146 0.0743349602270699 0.583730221710347 0.0105008018078939 0.918789674284249 0.808643595994088 0.33578972219198 0.536848200622412 0.898842910125025 0.333954421105444 0.0390509357521919 0.159857705429294 | ||
. Glk(ôepjg$ 0.3266193089274 0.806668730531573 0.87265879590923 0.934940869880726 0.548967615908753 0.250539517744596 0.75436043048449 0.597444122305604 0.343955002787363 0.560987092777944 0.134929631392942 0.958047956861493 0.870429681664852 0.66286672214456 0.441523248613101 0.437073092741238 0.265031623006715 | ||
rmlgj*lr , 0.462672931523031 0.74679446664976 0.151929368261195 0.165870989887449 0.90931621240424 0.423706631494886 0.337742032589001 0.184993498717115 0.0792523932129463 0.071353352835237 0.525247607449536 0.647744088759121 0.158725526449032 0.203927461340644 0.20055683200405 0.897053444943847 0.506954538974894 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
variable A B C D | ||
5d_-kkcùf 0 a ze$ùj 0 | ||
npèt 1 b g 0 | ||
5PY4(*3 2 c 15j-è, 0 | ||
k 3 a 6jè 1 | ||
t v^ptok!R/; 4 b 8j4, 1 | ||
ojt* 5 c 5èj1 1 | ||
lmtki 6 a j84 2 | ||
1h6-(587 t 7 b j4e54 2 | ||
r154 (54 86 8 c j 2 | ||
(h4 9 a 54j6@44èu6(è4 3 | ||
2 10 b (51h 3 | ||
m(yk 11 c 8-1 3 | ||
-546 -3 -3 12 a hy-81u 4 | ||
nz^à t 13 b zs5-hj1 4 | ||
kzjù 14 c 861h 4 | ||
. Glk(ôepjg$ 15 a (8168(h1 9 | ||
rmlgj*lr , 16 b 8hjè1 9 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
sample A B C D E F | ||
j 785 1 y z 1.2 F jkh52è16 | ||
y54j 68y4j6 3 y e 1.6 F 1è5hj4- | ||
5-6 4 5 y z 1.5 F - | ||
hrh 9 y e 6.3 F è1484j | ||
5h - 8 y z 6.9 F h3254 | ||
3 7 y e 0 F | ||
t564 4 y z 2 F th651 | ||
t54 66 5 y e 6 F h4+ | ||
y6y 6 y z 8 F he+65+( | ||
t6 5h 8 y e 4 F h56h4+ | ||
(5y 5 y z 5 F | ||
g51 1 y e 7 F | ||
( 2 y z 6 F 5h4te+4 | ||
6 6 y e 5 F yhe6 | ||
98 j7-0 4 y z 3 F theh | ||
06654h 4 y e 7 F 56 | ||
60 2 y z 3 F |
Uh oh!
There was an error while loading. Please reload this page.