0
|
1 <tool id="GroupCompute" name="Group and Compute" version="1.0.3">
|
|
2 <description>operations on tabular data.</description>
|
|
3
|
|
4 <requirements>
|
|
5 <requirement type="package" version="1.0.3">compute</requirement>
|
|
6 </requirements>
|
|
7
|
|
8 <command>
|
|
9 compute
|
|
10 $header_in
|
|
11 $header_out
|
|
12 $need_sort
|
|
13 $print_full_line
|
|
14 $ignore_case
|
|
15 #if str($grouping)>0
|
|
16 --group '$grouping'
|
|
17 #end if
|
|
18 -T
|
|
19 #for $oper in $operations
|
|
20 ${oper.op_name}
|
|
21 ${oper.op_column}
|
|
22 #end for
|
|
23 < $in_file > $out_file
|
|
24 </command>
|
|
25 <inputs>
|
|
26 <param format="tabular" name="in_file" type="data" label="Select Input Data" help=""/>
|
|
27
|
|
28 <param name="grouping" label="Group by fields" type="text" help="Example: 1,4 - To group by the first and fourth fields. Leave empty to perform operation on entire file as one group."/>
|
|
29
|
|
30 <param name="header_in" type="boolean" truevalue="--header-in" falsevalue=""
|
|
31 label="Input file has a header line" help="Mark this if the input file's first line is a header line" />
|
|
32
|
|
33 <param name="header_out" type="boolean" truevalue="--header-out" falsevalue=""
|
|
34 label="Print header line" help="Mark this if you want the first line to show the field names" />
|
|
35
|
|
36 <param name="need_sort" type="boolean" truevalue="--sort" falsevalue=""
|
|
37 label="Sort input" help="Mark if the input file is not sorted. If the input file is already sorted, unmark this option to reduce computing time." />
|
|
38
|
|
39 <param name="print_full_line" type="boolean" truevalue="--full" falsevalue=""
|
|
40 label="Print all fields from input file" help="If set, all input fields will be printed. If unset, only fields used for grouping will be printed." />
|
|
41
|
|
42 <param name="ignore_case" type="boolean" truevalue="--ignore-case" falsevalue=""
|
|
43 label="Ignore case when grouping" help="If set, upper/lowercase differences will be ignored when grouping fields." />
|
|
44
|
|
45 <repeat name="operations" title="Operation to perform on each group">
|
|
46 <param name="op_name" type="select" label="Type">
|
|
47 <option value="count">count</option>
|
|
48 <option value="sum">sum</option>
|
|
49 <option value="min">minimum</option>
|
|
50 <option value="max">maximum</option>
|
|
51 <option value="absmin">Absolute minimum</option>
|
|
52 <option value="absmax">Absolute maximum</option>
|
|
53 <option value="mean">Mean</option>
|
|
54 <option value="median">Median</option>
|
|
55 <option value="mode">Mode</option>
|
|
56 <option value="antimode">Anti-Mode</option>
|
|
57 <option value="pstdev">Population Standard deviantion</option>
|
|
58 <option value="sstdev">Sample Standard deviantion</option>
|
|
59 <option value="unique">Combine all unique values</option>
|
|
60 <option value="collapse">Combine all values</option>
|
|
61 <option value="countunique">Count Unique values</option>
|
|
62 </param>
|
|
63 <param name="op_column" label="On column" type="data_column" data_ref="in_file" />
|
|
64 </repeat>
|
|
65 </inputs>
|
|
66
|
|
67 <outputs>
|
|
68 <data format="tabular" name="out_file" />
|
|
69 </outputs>
|
|
70
|
|
71 <tests>
|
|
72 <test>
|
|
73 <param name="in_file" value="group_compute_input.txt" />
|
|
74 <param name="grouping" value="2" />
|
|
75 <param name="header_in" value="true" />
|
|
76 <param name="header_out" value="true" />
|
|
77 <param name="need_sort" value="true" />
|
|
78 <param name="print_full_line" value="false" />
|
|
79 <param name="op_column" value="3" />
|
|
80 <param name="op_name" value="sum" />
|
|
81 <param name="ignore_case" value="false" />
|
|
82 <output name="out_file" file="group_compute_output.txt" />
|
|
83 </test>
|
|
84 </tests>
|
|
85 <help>
|
|
86
|
|
87 .. class:: infomark
|
|
88
|
|
89 **TIP:** Input data must be TAB delimited. If the desired dataset does not appear in the input list, use *Text Manipulation->Convert* to convert it to **Tabular** type.
|
|
90
|
|
91 -----
|
|
92
|
|
93 **Syntax**
|
|
94
|
|
95 This tools performs common operations (such as summing, counting, mean, standard-deviation) on input file, based on tabular data. The tool can also optionaly group the input based on a given field.
|
|
96
|
|
97 -----
|
|
98
|
|
99 **Example 1**
|
|
100
|
|
101 - Find the average score in statistics course of college students, grouped by their college major. The input file has three fields (Name,Major,Score) and a header line::
|
|
102
|
|
103 Name Major Score
|
|
104 Bryan Arts 68
|
|
105 Isaiah Arts 80
|
|
106 Gabriel Health-Medicine 100
|
|
107 Tysza Business 92
|
|
108 Zackery Engineering 54
|
|
109 ...
|
|
110 ...
|
|
111
|
|
112 - Grouping the input by the second column (*Major*), and performing operations **mean** and **sample standard deviation** on the third column (*Score*), gives::
|
|
113
|
|
114 GroupBy(Major) mean(Score) sstdev(Score)
|
|
115 Arts 68.9474 10.4215
|
|
116 Business 87.3636 5.18214
|
|
117 Engineering 66.5385 19.8814
|
|
118 Health-Medicine 90.6154 9.22441
|
|
119 Life-Sciences 55.3333 20.606
|
|
120 Social-Sciences 60.2667 17.2273
|
|
121
|
|
122 This sample file is available at http://agordon.github.io/compute/examples.html .
|
|
123
|
|
124 **Example 2**
|
|
125
|
|
126 - Using the UCSC RefSeq Human Gene Track, available at: http://hgdownload.soe.ucsc.edu/goldenPath/hg38/database/refGene.txt.gz
|
|
127
|
|
128 - List the number and identifiers of isoforms per gene. The gene identifier is in column 13, the isoform/transcript identifier is in column 2. Grouping by column 13 and performing **count** and **Combine all values** on column 2, gives::
|
|
129
|
|
130 GroupBy(field-13) count(field-2) collapse(field-2)
|
|
131 A1BG 1 NM_130786
|
|
132 A1BG-AS1 1 NR_015380
|
|
133 A1CF 6 NM_001198818,NM_001198819,NM_001198820,NM_014576,NM_138932,NM_138933
|
|
134 A2M 1 NM_000014
|
|
135 A2M-AS1 1 NR_026971
|
|
136 A2ML1 2 NM_001282424,NM_144670
|
|
137 ...
|
|
138
|
|
139 - Count how many transcripts are listed for each chromosome and strand. Chromosome is on column 3, Strand is in column 4. Transcript identifiers are in column 2. Grouping by columns **3,4** and performing operation **count** on column 2, gives::
|
|
140
|
|
141 GroupBy(field-3) GroupBy(field-4) count(field-2)
|
|
142 chr1 + 2456
|
|
143 chr1 - 2431
|
|
144 chr2 + 1599
|
|
145 chr2 - 1419
|
|
146 chr3 + 1287
|
|
147 chr3 - 1249
|
|
148 ...
|
|
149
|
|
150 -----
|
|
151
|
|
152 **Compute** is an open-sourced program, see more details on the Compute_ Website.
|
|
153
|
|
154 **Compute** is also available as a command-line program, see http://agordon.github.io/compute/examples.html .
|
|
155
|
|
156 .. _Compute: http://agordon.github.io/compute/
|
|
157
|
|
158 </help>
|
|
159 </tool>
|