Mercurial > repos > iuc > table_compute
comparison table_compute.xml @ 0:b38b271a94aa draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/table_compute commit 1ee75135483d5db22c540bc043746cd986f85762"
| author | iuc |
|---|---|
| date | Sat, 17 Aug 2019 16:25:03 -0400 |
| parents | |
| children | 9190f11e46cd |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:b38b271a94aa |
|---|---|
| 1 <tool id="table_compute" name="Table Compute" version="@VERSION@"> | |
| 2 <description>computes operations on table data</description> | |
| 3 <macros> | |
| 4 <token name="@VERSION@">0.8</token> | |
| 5 <token name="@COPEN@"><![CDATA[<code>]]></token> | |
| 6 <token name="@CCLOSE@"><![CDATA[</code>]]></token> | |
| 7 <import>allowed_functions.xml</import> | |
| 8 <!-- text field validators --> | |
| 9 <macro name="validator_text" > | |
| 10 <validator type="regex" message="No special characters allowed">^(?:\w+)?$</validator> | |
| 11 <sanitizer sanitize="false" /> | |
| 12 </macro> | |
| 13 <macro name="validator_text_required" > | |
| 14 <validator type="regex" message="No special characters allowed">^(?:\w+)?$</validator> | |
| 15 <validator type="empty_field" /> | |
| 16 </macro> | |
| 17 <macro name="validator_index_identifiers" > | |
| 18 <validator type="regex" message="Specify a comma-separated list of index names without special characters">^(?:\w+(?:, *\w+)*)?$</validator> | |
| 19 <sanitizer sanitize="false" /> | |
| 20 </macro> | |
| 21 <macro name="validator_index_ranges"> | |
| 22 <validator type="regex" message="Specify a comma-separated list index numbers or ranges">^(?:\d+(?::\d)*(?:, *\d+(?::\d)*)*)?$</validator> | |
| 23 <sanitizer sanitize="false" /> | |
| 24 </macro> | |
| 25 <macro name="validator_functiondef"> | |
| 26 <validator type="regex" message="An expression is required and is allowed to contain only letters, numbers and the characters '_ !-+=/*%.<>()'">^[\w !\-+=/*%,.<>()]+$</validator> | |
| 27 <sanitizer sanitize="false" /> | |
| 28 </macro> | |
| 29 <!-- macro for main input tests --> | |
| 30 <macro name="test_inputs_single" > | |
| 31 <conditional name="singtabop" > | |
| 32 <param name="use_type" value="single" /> | |
| 33 <param name="input" value="small.tsv" /> | |
| 34 <conditional name="user" > | |
| 35 <yield /> | |
| 36 </conditional> | |
| 37 </conditional> | |
| 38 </macro> | |
| 39 <!-- macro for umi to transcript tests --> | |
| 40 <macro name="umi2trans" > | |
| 41 <yield /> | |
| 42 <conditional name="user" > | |
| 43 <param name="mode" value="element" /> | |
| 44 <param name="element_op" value="gt" /> | |
| 45 <param name="element_value" value="0" /> | |
| 46 <conditional name="element" > | |
| 47 <param name="mode" value="custom" /> | |
| 48 <param name="custom_expr" value="-math.log(1 - elem/4096) * 4096 if elem != 4096 else elem - 0.5" /> | |
| 49 </conditional> | |
| 50 </conditional> | |
| 51 </macro> | |
| 52 <!-- macro for file inputs --> | |
| 53 <macro name="file_opts"> | |
| 54 <param name="input" type="data" format="tsv,tabular" label="Table" /> | |
| 55 <param name="col_row_names" type="select" display="checkboxes" multiple="true" optional="true" | |
| 56 label="This input data has"> | |
| 57 <option value="has_col_names" selected="true">Column names on the first row</option> | |
| 58 <option value="has_row_names" selected="true">Row names on the first column"</option> | |
| 59 </param> | |
| 60 </macro> | |
| 61 <!-- element value macro --> | |
| 62 <macro name="elem_val_macro" > | |
| 63 <param name="element_value" type="text" optional="true" label="Filter value" help="This value is converted to numeric if possible, otherwise it is treated as a string" /> | |
| 64 </macro> | |
| 65 </macros> | |
| 66 <requirements> | |
| 67 <requirement type="package" version="0.25">pandas</requirement> | |
| 68 <requirement type="package" version="1.17">numpy</requirement> | |
| 69 </requirements> | |
| 70 | |
| 71 <version_command><![CDATA[ | |
| 72 touch '$__tool_directory__/scripts/userconfig.py' && python '$__tool_directory__/scripts/table_compute.py' --version | |
| 73 ]]></version_command> | |
| 74 | |
| 75 <command detect_errors="exit_code"><![CDATA[ | |
| 76 ## Can only import generated userconfig.py if calling | |
| 77 ## script is in the same directory. Soft-linking does | |
| 78 ## not satisfy importing, so we copy everything. | |
| 79 cp '$userconf' ./userconfig.py && | |
| 80 cp '$__tool_directory__/scripts/safety.py' ./safety.py && | |
| 81 cp '$__tool_directory__/scripts/table_compute.py' ./table_compute.py && | |
| 82 python ./table_compute.py | |
| 83 ]]></command> | |
| 84 <configfiles> | |
| 85 <configfile name="userconf"><![CDATA[ | |
| 86 | |
| 87 ## Range Maker | |
| 88 ## "2:5,11,1:2" specifies "2,3,4,5,11,1,2" which in python is "1,2,3,4,10,0,1" | |
| 89 #def rangemake(tab): | |
| 90 #echo [(n-1) for r in map(lambda y: range(int(y[0]),int(y[-1])+1), map(lambda x: x.split(':'), tab.split(','))) for n in r] | |
| 91 #end def | |
| 92 | |
| 93 ## Strip leading and trailing whitespace off custom functions | |
| 94 | |
| 95 Default = { | |
| 96 "reader_skip": 0, | |
| 97 "precision": $precision, | |
| 98 #if 'ignore_nas' in str($out_opts): | |
| 99 "narm": True, | |
| 100 #else: | |
| 101 "narm": False, | |
| 102 #end if | |
| 103 #if 'output_headers_row' in str($out_opts): | |
| 104 "out_headers_row": True, | |
| 105 #else: | |
| 106 "out_headers_row": False, | |
| 107 #end if | |
| 108 #if 'output_headers_col' in str($out_opts): | |
| 109 "out_headers_col": True, | |
| 110 #else: | |
| 111 "out_headers_col": False, | |
| 112 #end if | |
| 113 "user_mode": '$singtabop.use_type', | |
| 114 "outtable": '$table' | |
| 115 } | |
| 116 | |
| 117 #if str($singtabop.use_type) == "single": | |
| 118 Data = { | |
| 119 "tables": [ | |
| 120 { | |
| 121 "reader_file": '$singtabop.input', | |
| 122 #if 'has_col_names' in str($singtabop.col_row_names): | |
| 123 "reader_header": 0, | |
| 124 #else: | |
| 125 "reader_header": None, | |
| 126 #end if | |
| 127 #if 'has_row_names' in str($singtabop.col_row_names): | |
| 128 "reader_row_col": 0, | |
| 129 #else: | |
| 130 "reader_row_col": False, | |
| 131 #end if | |
| 132 } | |
| 133 ], | |
| 134 "params": { | |
| 135 "user_mode_single": '$singtabop.user.mode.value', | |
| 136 #if $singtabop.user.mode.value == 'precision': | |
| 137 ## Literally do nothing, the user just sets the precision slider | |
| 138 ## at the top default level | |
| 139 } | |
| 140 #elif $singtabop.user.mode.value == 'select': | |
| 141 "select_cols_unique": #echo 'select_cols_keepdupe' in str($singtabop.user.select_keepdupe)#, | |
| 142 "select_rows_unique": #echo 'select_rows_keepdupe' in str($singtabop.user.select_keepdupe)#, | |
| 143 #if $singtabop.user.select_cols_wanted: | |
| 144 "select_cols_wanted": $rangemake(str($singtabop.user.select_cols_wanted)), | |
| 145 #else | |
| 146 "select_cols_wanted": None, | |
| 147 #end if | |
| 148 #if $singtabop.user.select_rows_wanted: | |
| 149 "select_rows_wanted": $rangemake(str($singtabop.user.select_rows_wanted)), | |
| 150 #else | |
| 151 "select_rows_wanted": None, | |
| 152 #end if | |
| 153 } | |
| 154 #elif $singtabop.user.mode.value == 'filtersumval': | |
| 155 "filtersumval_mode": '$singtabop.user.filtersumval_mode.use.value', | |
| 156 "filtersumval_axis": $singtabop.user.axis.value, | |
| 157 #if $singtabop.user.filtersumval_mode.use.value == 'operation': | |
| 158 "filtersumval_compare": '$singtabop.user.filtersumval_mode.compare_op.value', | |
| 159 "filtersumval_op": '$singtabop.user.filtersumval_mode.operation.value', | |
| 160 "filtersumval_against": $singtabop.user.filtersumval_mode.against, | |
| 161 "filtersumval_minmatch": None, | |
| 162 #elif $singtabop.user.filtersumval_mode.use.value == 'element': | |
| 163 "filtersumval_compare": None, | |
| 164 "filtersumval_op": '$singtabop.user.filtersumval_mode.operation.value', | |
| 165 ## against could be string or float, so we parse this in the code | |
| 166 "filtersumval_against": '$singtabop.user.filtersumval_mode.against', | |
| 167 "filtersumval_minmatch": $singtabop.user.filtersumval_mode.minmatch, | |
| 168 #end if | |
| 169 } | |
| 170 #elif $singtabop.user.mode.value == 'matrixapply': | |
| 171 "matrixapply_dimension": $singtabop.user.dimension.value, | |
| 172 #if str($singtabop.user.matrixapply_func.vector_op) == 'custom': | |
| 173 #set $custom_func = str($singtabop.user.matrixapply_func.custom_func).strip() | |
| 174 "matrixapply_custom": True, | |
| 175 "matrixapply_custom_func": '$custom_func', | |
| 176 "matrixapply_op": None, | |
| 177 #else | |
| 178 "matrixapply_custom": False, | |
| 179 "matrixapply_custom_func": None, | |
| 180 "matrixapply_op": '$singtabop.user.matrixapply_func.vector_op', | |
| 181 #end if | |
| 182 } | |
| 183 #elif $singtabop.user.mode.value == 'element': | |
| 184 #if str($singtabop.user.elem_val.element_op) != "None": | |
| 185 "element_op": '$singtabop.user.elem_val.element_op.value', | |
| 186 ## Value is string or float, parsed in code later | |
| 187 "element_value" : '$singtabop.user.elem_val.element_value', | |
| 188 #else: | |
| 189 "element_op": None, | |
| 190 #end if | |
| 191 "element_mode": '$singtabop.user.element.mode.value', | |
| 192 #if str($singtabop.user.element.mode) == "replace": | |
| 193 "element_replace": '$singtabop.user.element.replace_value.value', | |
| 194 #elif str($singtabop.user.element.mode) == "modify": | |
| 195 "element_modify_op": '$singtabop.user.element.modify_op.value', | |
| 196 #elif str($singtabop.user.element.mode) == "scale": | |
| 197 "element_scale_op": '$singtabop.user.element.scale_op.value', | |
| 198 "element_scale_value": $singtabop.user.element.scale_value, | |
| 199 #elif str($singtabop.user.element.mode) == "custom": | |
| 200 #set $custom_func = str($singtabop.user.element.custom_expr).strip() | |
| 201 "element_customop": '$custom_func', | |
| 202 #end if | |
| 203 } | |
| 204 #elif $singtabop.user.mode.value == 'fulltable': | |
| 205 "mode": '$singtabop.user.general.use', | |
| 206 #if str($singtabop.user.general.use) == 'melt': | |
| 207 #if str($singtabop.user.general.id_vars).strip(): | |
| 208 #set $melt_ids = [i.strip() for i in str($singtabop.user.general.id_vars).split(',')] | |
| 209 #else | |
| 210 #set $melt_ids = 'None' | |
| 211 #end if | |
| 212 #if str($singtabop.user.general.value_vars).strip(): | |
| 213 #set $melt_values = [i.strip() for i in str($singtabop.user.general.value_vars).split(',')] | |
| 214 #else | |
| 215 #set $melt_values = 'None' | |
| 216 #end if | |
| 217 "MELT": { | |
| 218 "melt_ids": $melt_ids, | |
| 219 "melt_values": $melt_values, | |
| 220 }, | |
| 221 #elif str($singtabop.user.general.use) == 'pivot': | |
| 222 #set $pivot_index = str($singtabop.user.general.index).strip() | |
| 223 #if $pivot_index: | |
| 224 #set $pivot_index = "'" + $pivot_index + "'" | |
| 225 #else: | |
| 226 #set $pivot_index = 'None' | |
| 227 #end if | |
| 228 #set $pivot_column = "'" + str($singtabop.user.general.column).strip() + "'" | |
| 229 #if str($singtabop.user.general.values).strip(): | |
| 230 #set $pivot_values = [i.strip() for i in str($singtabop.user.general.values).split(',')] | |
| 231 #else | |
| 232 #set $pivot_values = 'None' | |
| 233 #end if | |
| 234 "PIVOT": { | |
| 235 "pivot_index": $pivot_index, | |
| 236 "pivot_column": $pivot_column, | |
| 237 "pivot_values": $pivot_values, | |
| 238 }, | |
| 239 #elif str($singtabop.user.general.use) == 'custom': | |
| 240 #set $custom_func = str($singtabop.user.general.fulltable_custom_expr.value).strip() | |
| 241 "fulltable_customop": '$custom_func', | |
| 242 | |
| 243 #end if | |
| 244 }, | |
| 245 #end if | |
| 246 } | |
| 247 | |
| 248 #elif str($singtabop.use_type) == "multiple": | |
| 249 #set $custom_func = str($singtabop.fulltable_custom_expr).strip() | |
| 250 Data = { | |
| 251 "tables": [ | |
| 252 #for $i, $s in enumerate($singtabop.tables) | |
| 253 { | |
| 254 "file": '${s.input}', | |
| 255 #if 'has_col_names' in str($s.col_row_names): | |
| 256 "header": 0, | |
| 257 #else: | |
| 258 "header": None, | |
| 259 #end if | |
| 260 #if 'has_row_names' in str($s.col_row_names): | |
| 261 "row_names": 0, | |
| 262 #else: | |
| 263 "row_names": False, | |
| 264 #end if | |
| 265 }, | |
| 266 #end for | |
| 267 ], | |
| 268 'params': { | |
| 269 "fulltable_customop" : '$custom_func', | |
| 270 } | |
| 271 } | |
| 272 #end if | |
| 273 | |
| 274 ]]> | |
| 275 </configfile> | |
| 276 </configfiles> | |
| 277 <inputs> | |
| 278 <conditional name="singtabop" > | |
| 279 <param name="use_type" type="select" label="Input Single or Multiple Tables" help="Operations on single tables are better tailored towards more general use-cases. For multiple tables usage, all tables should ideally be of the same dimensions for simple operations, although complex operations are also supported for unequally sized tables (see Help section)." > | |
| 280 <option value="single">Single Table</option> | |
| 281 <option value="multiple">Multiple Tables</option> | |
| 282 </param> | |
| 283 <when value="single"> | |
| 284 <expand macro="file_opts" /> | |
| 285 <conditional name="user" > | |
| 286 <param name="mode" type="select" label="Type of table operation" > | |
| 287 <option value="precision">No operation (just reformat on output)</option> | |
| 288 <option value="select">Drop, keep or duplicate rows and columns</option> | |
| 289 <option value="filtersumval">Filter rows or columns by their properties</option> | |
| 290 <option value="matrixapply">Compute expression across rows or columns</option> | |
| 291 <option value="element">Manipulate selected table elements</option> | |
| 292 <option value="fulltable">Perform a full table operation</option> | |
| 293 </param> | |
| 294 <when value="precision" /> | |
| 295 <when value="select"> | |
| 296 <param name="select_cols_wanted" type="text" optional="true" label="List of columns to select" help="Comma separated. (e.g. @COPEN@3:5,99,2:4@CCLOSE@ will select columns @COPEN@3,4,5,99,2,3,4@CCLOSE@). Columns can be duplicated by specifying them multiple times. Leave blank to retain all columns. See Example #1 for an example of using this mode." > | |
| 297 <expand macro="validator_index_ranges" /> | |
| 298 </param> | |
| 299 <param name="select_rows_wanted" type="text" optional="true" label="List of rows to select" help="The same rules apply as above" > | |
| 300 <expand macro="validator_index_ranges" /> | |
| 301 </param> | |
| 302 <param name="select_keepdupe" type="select" display="checkboxes" multiple="true" label="Duplicate Indices" help="Keep duplicates when specifying ranges (e.g. if unset, @COPEN@1:3,2:4@CCLOSE@ will yield @COPEN@1,2,3,4@CCLOSE@ instead of @COPEN@1,2,3,2,3,4@CCLOSE@)" > | |
| 303 <option value="select_cols_keepdupe" selected="true" >Keep duplicate columns</option> | |
| 304 <option value="select_rows_keepdupe" selected="true" >Keep duplicate rows</option> | |
| 305 </param> | |
| 306 </when> | |
| 307 <when value="filtersumval" > | |
| 308 <param name="axis" type="select" display="radio" | |
| 309 label="Filter" > | |
| 310 <option value="1">Rows</option> | |
| 311 <option value="0">Columns</option> | |
| 312 </param> | |
| 313 <conditional name="filtersumval_mode" > | |
| 314 <param name="use" type="select" label="Filter criterion" help="See Example #2 for an example of using this mode." > | |
| 315 <option value="operation" >Result of function applied to columns/rows</option> | |
| 316 <option value="element" >Number of column/row elements passing filter</option> | |
| 317 </param> | |
| 318 <when value="operation"> | |
| 319 <param name="operation" type="select" label="Keep column/row if its observed" > | |
| 320 <expand macro="select_vectorops" /> | |
| 321 </param> | |
| 322 <param name="compare_op" type="select" label="is" > | |
| 323 <expand macro="select_twovaluebooleanops" /> | |
| 324 </param> | |
| 325 <param name="against" type="float" label="this value" value="0" /> | |
| 326 </when> | |
| 327 <when value="element"> | |
| 328 <param name="minmatch" type="integer" min="1" value="0" label="Keep column/row if at least" /> | |
| 329 <param name="operation" type="select" label="of its element are" > | |
| 330 <expand macro="select_twovaluebooleanops" > | |
| 331 <option value="str_eq" >~ (Matching)</option> | |
| 332 <option value="str_ne" >!~ (not Matching)</option> | |
| 333 </expand> | |
| 334 </param> | |
| 335 <param name="against" type="text" label="this value"> | |
| 336 <expand macro="validator_functiondef" /> | |
| 337 </param> | |
| 338 </when> | |
| 339 </conditional> | |
| 340 </when> | |
| 341 <when value="matrixapply" > | |
| 342 <conditional name="matrixapply_func"> | |
| 343 <param name="vector_op" type="select" label="Calculate"> | |
| 344 <option value="custom">Custom Function</option> | |
| 345 <expand macro="select_vectorops" > | |
| 346 <option value="rank">Ranks</option> | |
| 347 <option value="cumsum" >Cumulative Sum</option> | |
| 348 <option value="cumprod" >Cumulative Product</option> | |
| 349 <option value="cummin" >Cumulative Minimum</option> | |
| 350 <option value="cummax" >Cumulative Maximum</option> | |
| 351 </expand> | |
| 352 </param> | |
| 353 <when value="custom"> | |
| 354 <param name="custom_func" type="text" | |
| 355 label="Custom function on 'vec'" | |
| 356 help="The parameter name is @COPEN@vec@CCLOSE@, referring to a vector of a specific row or column being operated on. Numpy and Pandas DataFrame operators are supported. e.g. @COPEN@np.sum(vec) + np.median(vec)@CCLOSE@, and @COPEN@vec.sum() + vec.median()@CCLOSE@ are equivalent operations." > | |
| 357 <expand macro="validator_functiondef" /> | |
| 358 </param> | |
| 359 </when> | |
| 360 <when value="min" /> | |
| 361 <when value="max" /> | |
| 362 <when value="sum" /> | |
| 363 <when value="count" /> | |
| 364 <when value="nunique" /> | |
| 365 <when value="mean" /> | |
| 366 <when value="median" /> | |
| 367 <when value="std" /> | |
| 368 <when value="sem" /> | |
| 369 <when value="var" /> | |
| 370 <when value="mad" /> | |
| 371 <when value="product" /> | |
| 372 <when value="rank" /> | |
| 373 <when value="cumsum" /> | |
| 374 <when value="cumprod" /> | |
| 375 <when value="cummin" /> | |
| 376 <when value="cummax" /> | |
| 377 </conditional> | |
| 378 <param name="dimension" type="select" label="For each"> | |
| 379 <option value="0">Column</option> | |
| 380 <option value="1">Row</option> | |
| 381 </param> | |
| 382 </when> | |
| 383 <when value="fulltable"> | |
| 384 <conditional name="general" > | |
| 385 <param name="use" type="select" label="Operation" help="See Examples 5, 7, and 8 for usage" > | |
| 386 <option value="melt" >Melt</option> | |
| 387 <option value="pivot" >Pivot</option> | |
| 388 <option value="custom" >Custom</option> | |
| 389 </param> | |
| 390 <when value="melt" > | |
| 391 <param name="id_vars" type="text" value="" label="Variable IDs" | |
| 392 help="Comma-delimited list of column names to use as identifiers" > | |
| 393 <expand macro="validator_index_identifiers" /> | |
| 394 </param> | |
| 395 <param name="value_vars" type="text" value="" label="Unpivoted IDs" | |
| 396 help="Comma-delimited list of column names to un-pivot. Leave blank to use all." > | |
| 397 <expand macro="validator_index_identifiers" /> | |
| 398 </param> | |
| 399 </when> | |
| 400 <when value="pivot" > | |
| 401 <param name="index" type="text" value="" | |
| 402 label="Index" | |
| 403 help="Name of the column to use as new index" > | |
| 404 <expand macro="validator_text" /> | |
| 405 </param> | |
| 406 <param name="column" type="text" value="" | |
| 407 label="Column" | |
| 408 help="Name of the column to use to generate the columns of the new table from" > | |
| 409 <expand macro="validator_text_required" /> | |
| 410 </param> | |
| 411 <param name="values" type="text" value="" | |
| 412 label="Values" | |
| 413 help="Names of the columns to use for populating the cells of the new table. Leave blank to use all." > | |
| 414 <expand macro="validator_index_identifiers" /> | |
| 415 </param> | |
| 416 </when> | |
| 417 <when value="custom" > | |
| 418 <param name="fulltable_custom_expr" type="text" | |
| 419 label="Custom expression on 'table', along 'axis' (0 or 1)" | |
| 420 help="The parameter name is @COPEN@table@CCLOSE@ and @COPEN@axis@CCLOSE@, referring to the table being acted on and the column (@COPEN@0@CCLOSE@) or row (@COPEN@1@CCLOSE@) to perform the operation on. Numpy, math, Pandas DataFrame operators, and inline @COPEN@if else@CCLOSE@ are supported (e.g. @COPEN@np.log(table) - table.mean(0) / table.std(1)@CCLOSE@). See Example #5 in the Help section. "> | |
| 421 <expand macro="validator_functiondef" /> | |
| 422 </param> | |
| 423 </when> | |
| 424 </conditional> | |
| 425 </when> | |
| 426 <when value="element"> | |
| 427 <conditional name="element" > | |
| 428 <param name="mode" type="select" | |
| 429 label="Operation to perform" > | |
| 430 <option value="replace">Replace values</option> | |
| 431 <option value="modify">Transform</option> | |
| 432 <option value="scale">Arithmetic operation</option> | |
| 433 <option value="custom">Custom</option> | |
| 434 </param> | |
| 435 <when value="replace" > | |
| 436 <param name="replace_value" type="text" label="Replacement value" help="This value is converted to numeric if possible, otherwise it is treated as a string" /> | |
| 437 </when> | |
| 438 <when value="modify" > | |
| 439 <param name="modify_op" type="select" label="Transformation function" help="Example: to transform values to their square root, select @COPEN@Square Root@CCLOSE@ here."> | |
| 440 <expand macro="select_onevalueoperator" /> | |
| 441 </param> | |
| 442 </when> | |
| 443 <when value="scale"> | |
| 444 <param name="scale_op" type="select" label="Operation" help="The selected operation will be applied to the table elements as the first operand. The value of the second operand can be provided in the next box. Example: to raise all values to the power of 5, select @COPEN@Power@CCLOSE@ here and type @COPEN@5@CCLOSE@ in the box below." > | |
| 445 <expand macro="select_twovaluenumericoperator" /> | |
| 446 </param> | |
| 447 <param name="scale_value" type="float" value="0" label="Second operand value" /> | |
| 448 </when> | |
| 449 <when value="custom"> | |
| 450 <param name="custom_expr" type="text" | |
| 451 label="Custom expression on 'elem'" | |
| 452 help="The parameter name is @COPEN@elem@CCLOSE@, referring to the element being acted on. Most operators and @COPEN@if@CCLOSE@ @COPEN@else@CCLOSE@ statements are supported. See Examples #3 and #4 in the Help section."> | |
| 453 <expand macro="validator_functiondef" /> | |
| 454 </param> | |
| 455 </when> | |
| 456 </conditional> | |
| 457 <conditional name="elem_val" > | |
| 458 <param name="element_op" type="select" label="Operate on elements" | |
| 459 help="Only selected elements will be manipulated. Other elements will retain their original value." > | |
| 460 <expand macro="select_twovaluebooleanops" > | |
| 461 <option value="None" selected="true">All</option> | |
| 462 </expand> | |
| 463 </param> | |
| 464 <when value="None" /> | |
| 465 <when value="lt"> | |
| 466 <expand macro="elem_val_macro" /> | |
| 467 </when> | |
| 468 <when value="le"> | |
| 469 <expand macro="elem_val_macro" /> | |
| 470 </when> | |
| 471 <when value="gt"> | |
| 472 <expand macro="elem_val_macro" /> | |
| 473 </when> | |
| 474 <when value="ge"> | |
| 475 <expand macro="elem_val_macro" /> | |
| 476 </when> | |
| 477 <when value="eq"> | |
| 478 <expand macro="elem_val_macro" /> | |
| 479 </when> | |
| 480 <when value="ne"> | |
| 481 <expand macro="elem_val_macro" /> | |
| 482 </when> | |
| 483 </conditional> | |
| 484 </when> | |
| 485 </conditional> | |
| 486 </when> | |
| 487 <when value="multiple"> | |
| 488 <repeat name="tables" title="Tables" min="1" default="1"> | |
| 489 <expand macro="file_opts" /> | |
| 490 </repeat> | |
| 491 <param name="fulltable_custom_expr" type="text" | |
| 492 label="Custom expression on 'tableN'" | |
| 493 help="The parameter name is @COPEN@tableN@CCLOSE@, where @COPEN@N@CCLOSE@ refers to a specific table. e.g. @COPEN@table1 + table3 - table2@CCLOSE@, will add the first and third input tables and then subtract the second. Most operators and @COPEN@if@CCLOSE@ @COPEN@else@CCLOSE@ statements are supported. See Example #6 in the Help section for further examples."> | |
| 494 <expand macro="validator_functiondef" /> | |
| 495 </param> | |
| 496 </when> | |
| 497 </conditional> | |
| 498 <param name="out_opts" type="select" display="checkboxes" multiple="true" optional="true" | |
| 499 label="Output formatting options"> | |
| 500 <option value="ignore_nas" selected="true">Ignore NA values</option> | |
| 501 <option value="output_headers_col" selected="true">Output column headers</option> | |
| 502 <option value="output_headers_row" selected="true">Output row headers</option> | |
| 503 </param> | |
| 504 <param name="precision" type="integer" min="0" max="20" value="6" label="Output decimal precision" /> | |
| 505 </inputs> | |
| 506 <outputs> | |
| 507 <data name="table" format="tabular" label="${tool.name} on ${on_string}" /> | |
| 508 </outputs> | |
| 509 <tests> | |
| 510 <test expect_num_outputs="1"> | |
| 511 <!-- Test 1: Select --> | |
| 512 <expand macro="test_inputs_single" > | |
| 513 <param name="mode" value="select" /> | |
| 514 <param name="select_cols_wanted" value="2:4,2,2" /> | |
| 515 <param name="select_rows_wanted" value="2:5,3,3" /> | |
| 516 <param name="select_keepdupe" value="select_cols_keepdupe" /> | |
| 517 </expand> | |
| 518 <param name="precision" value="2" /> | |
| 519 <output name="table" value="small.select.tsv" /> | |
| 520 </test> | |
| 521 <test expect_num_outputs="1"> | |
| 522 <!-- Test 2: Select, cols only --> | |
| 523 <expand macro="test_inputs_single" > | |
| 524 <param name="mode" value="select" /> | |
| 525 <param name="select_cols_wanted" value="2:4,2,2" /> | |
| 526 <param name="select_keepdupe" value="select_cols_keepdupe,select_rows_keepdupe" /> | |
| 527 </expand> | |
| 528 <param name="precision" value="2" /> | |
| 529 <output name="table" value="small.select.colsonly.tsv" /> | |
| 530 </test> | |
| 531 <test expect_num_outputs="1"> | |
| 532 <!-- Test 3: Select, rows only --> | |
| 533 <expand macro="test_inputs_single" > | |
| 534 <param name="mode" value="select" /> | |
| 535 <param name="select_rows_wanted" value="2:5,3,3" /> | |
| 536 <param name="select_keepdupe" value="select_cols_keepdupe" /> | |
| 537 </expand> | |
| 538 <param name="precision" value="2" /> | |
| 539 <output name="table" value="small.select.rowsonly.tsv" /> | |
| 540 </test> | |
| 541 <test expect_num_outputs="1"> | |
| 542 <!-- Test 4: Filtersumval, row --> | |
| 543 <expand macro="test_inputs_single" > | |
| 544 <param name="mode" value="filtersumval" /> | |
| 545 <param name="axis" value="1" /> | |
| 546 <conditional name="filtersumval_mode" > | |
| 547 <param name="use" value="operation" /> | |
| 548 <param name="operation" value="sum" /> | |
| 549 <param name="compare_op" value="gt" /> | |
| 550 <param name="against" value="50" /> | |
| 551 </conditional> | |
| 552 </expand> | |
| 553 <param name="precision" value="2" /> | |
| 554 <output name="table" value="small.fs.rowsum.gt.50.tsv" /> | |
| 555 </test> | |
| 556 <test expect_num_outputs="1"> | |
| 557 <!-- Test 5: Filtersumval, col neq 0 --> | |
| 558 <expand macro="test_inputs_single" > | |
| 559 <param name="mode" value="filtersumval" /> | |
| 560 <param name="axis" value="0" /> | |
| 561 <conditional name="filtersumval_mode" > | |
| 562 <param name="use" value="operation" /> | |
| 563 <param name="operation" value="sum" /> | |
| 564 <param name="compare_op" value="ne" /> | |
| 565 <param name="against" value="0" /> | |
| 566 </conditional> | |
| 567 </expand> | |
| 568 <param name="precision" value="2" /> | |
| 569 <output name="table" value="small.fs.colsum.neq0.tsv" /> | |
| 570 </test> | |
| 571 <test expect_num_outputs="1"> | |
| 572 <!-- Test 6: Filtersumval, col val gt 10 --> | |
| 573 <expand macro="test_inputs_single" > | |
| 574 <param name="mode" value="filtersumval" /> | |
| 575 <param name="axis" value="0" /> | |
| 576 <conditional name="filtersumval_mode" > | |
| 577 <param name="use" value="operation" /> | |
| 578 <param name="operation" value="sum" /> | |
| 579 <param name="compare_op" value="gt" /> | |
| 580 <param name="against" value="10" /> | |
| 581 </conditional> | |
| 582 </expand> | |
| 583 <param name="precision" value="2" /> | |
| 584 <output name="table" value="small.fs.colsum.gt10.tsv" /> | |
| 585 </test> | |
| 586 <test expect_num_outputs="1"> | |
| 587 <!-- Test 7: Filtersumval, median val col >= 2 --> | |
| 588 <expand macro="test_inputs_single" > | |
| 589 <param name="mode" value="filtersumval" /> | |
| 590 <param name="axis" value="0" /> | |
| 591 <conditional name="filtersumval_mode" > | |
| 592 <param name="use" value="operation" /> | |
| 593 <param name="operation" value="median" /> | |
| 594 <param name="compare_op" value="ge" /> | |
| 595 <param name="against" value="2" /> | |
| 596 </conditional> | |
| 597 </expand> | |
| 598 <param name="precision" value="5" /> | |
| 599 <output name="table" value="small.fs.medvalcol.ge2.tsv" /> | |
| 600 </test> | |
| 601 <test expect_num_outputs="1"> | |
| 602 <!-- Test 8: Filtersumval, keep rows with at least | |
| 603 two values > 2 --> | |
| 604 <expand macro="test_inputs_single" > | |
| 605 <param name="mode" value="filtersumval" /> | |
| 606 <param name="axis" value="1" /> | |
| 607 <conditional name="filtersumval_mode" > | |
| 608 <param name="use" value="element" /> | |
| 609 <param name="operation" value="gt" /> | |
| 610 <param name="against" value="2" /> | |
| 611 <param name="minmatch" value="2" /> | |
| 612 </conditional> | |
| 613 </expand> | |
| 614 <param name="precision" value="5" /> | |
| 615 <output name="table" value="small.fs.elemgt2.mm2.tsv" /> | |
| 616 </test> | |
| 617 <test expect_num_outputs="1"> | |
| 618 <!-- Test 9: Filtersumval, keep cols with at least | |
| 619 4 string values matching "0" --> | |
| 620 <expand macro="test_inputs_single" > | |
| 621 <param name="mode" value="filtersumval" /> | |
| 622 <param name="axis" value="0" /> | |
| 623 <conditional name="filtersumval_mode" > | |
| 624 <param name="use" value="element" /> | |
| 625 <param name="operation" value="str_ne" /> | |
| 626 <param name="against" value="0" /> | |
| 627 <param name="minmatch" value="4" /> | |
| 628 </conditional> | |
| 629 </expand> | |
| 630 <param name="precision" value="3" /> | |
| 631 <output name="table" value="small.fs.elemnmatch0.mm4.tsv" /> | |
| 632 </test> | |
| 633 <test expect_num_outputs="1"> | |
| 634 <!-- Test 10: Matrix Apply, row max --> | |
| 635 <expand macro="test_inputs_single" > | |
| 636 <param name="mode" value="matrixapply" /> | |
| 637 <param name="dimension" value="1" /> | |
| 638 <conditional name="matrixapply_func" > | |
| 639 <param name="vector_op" value="max" /> | |
| 640 </conditional> | |
| 641 </expand> | |
| 642 <param name="precision" value="0" /> | |
| 643 <param name="out_opts" value="ignore_nas,output_headers_row" /> | |
| 644 <output name="table" value="small.matapp.rowmax.tsv" /> | |
| 645 </test> | |
| 646 <test expect_num_outputs="1"> | |
| 647 <!-- Test 11: Element, all, scale, remainder 5 --> | |
| 648 <expand macro="test_inputs_single" > | |
| 649 <param name="mode" value="element" /> | |
| 650 <conditional name="elem_val"> | |
| 651 <param name="element_op" value="None" /> | |
| 652 </conditional> | |
| 653 <conditional name="element" > | |
| 654 <param name="mode" value="scale" /> | |
| 655 <param name="scale_op" value="mod" /> | |
| 656 <param name="scale_value" value="5" /> | |
| 657 </conditional> | |
| 658 </expand> | |
| 659 <param name="precision" value="2" /> | |
| 660 <output name="table" value="small.element.scalerem5.tsv" /> | |
| 661 </test> | |
| 662 <test expect_num_outputs="1"> | |
| 663 <!-- Test 12: Matrix Apply, column custom --> | |
| 664 <expand macro="test_inputs_single" > | |
| 665 <param name="mode" value="matrixapply" /> | |
| 666 <param name="dimension" value="0" /> | |
| 667 <conditional name="matrixapply_func" > | |
| 668 <param name="vector_op" value="custom" /> | |
| 669 <param name="custom_func" value="vec.sum()+vec.median()" /> | |
| 670 </conditional> | |
| 671 </expand> | |
| 672 <param name="precision" value="2" /> | |
| 673 <param name="out_opts" value="ignore_nas,output_headers_row" /> | |
| 674 <output name="table" value="small.matapp.colcust.tsv" /> | |
| 675 </test> | |
| 676 <test expect_num_outputs="1"> | |
| 677 <!-- Test 13: Element, non-zero, custom --> | |
| 678 <expand macro="test_inputs_single" > | |
| 679 <param name="mode" value="element" /> | |
| 680 <conditional name="elem_val"> | |
| 681 <param name="element_op" value="gt" /> | |
| 682 <param name="element_value" value="0" /> | |
| 683 </conditional> | |
| 684 <conditional name="element" > | |
| 685 <param name="mode" value="custom" /> | |
| 686 <!-- valid complex expression for non-zero vals --> | |
| 687 <param name="custom_expr" value="(math.log10(elem)+elem)/elem if (elem < math.inf) else 1.0" /> | |
| 688 </conditional> | |
| 689 </expand> | |
| 690 <output name="table" value="small.element.custom.tsv" /> | |
| 691 </test> | |
| 692 <test expect_num_outputs="1"> | |
| 693 <!-- Test 14: umi2transcript test1 --> | |
| 694 <expand macro="umi2trans" > | |
| 695 <param name="input" value="mat1.umi.tsv" /> | |
| 696 <output name="table" value="mat1.trans.tsv" /> | |
| 697 </expand> | |
| 698 </test> | |
| 699 <test expect_num_outputs="1"> | |
| 700 <!-- Test 15: umi2transcript test2 --> | |
| 701 <expand macro="umi2trans" > | |
| 702 <param name="input" value="mat2.umi.tsv" /> | |
| 703 <output name="table" value="mat2.trans.tsv" /> | |
| 704 </expand> | |
| 705 </test> | |
| 706 <test expect_num_outputs="1"> | |
| 707 <!-- Test 16: B-test - mean and sd in custom func --> | |
| 708 <expand macro="test_inputs_single" > | |
| 709 <param name="mode" value="fulltable" /> | |
| 710 <conditional name="general" > | |
| 711 <param name="use" value="custom" /> | |
| 712 <param name="fulltable_custom_expr" | |
| 713 value="table - table.mean(0) / table.std(0)" /> | |
| 714 </conditional> | |
| 715 </expand> | |
| 716 <output name="table" value="small.fulltable.tsv" /> | |
| 717 </test> | |
| 718 <test expect_num_outputs="1"> | |
| 719 <!-- Test 17: Multiple table test --> | |
| 720 <conditional name="singtabop" > | |
| 721 <param name="use_type" value="multiple" /> | |
| 722 <repeat name="tables"> | |
| 723 <param name="input" value="small.tsv" /> | |
| 724 </repeat> | |
| 725 <repeat name="tables"> | |
| 726 <param name="input" value="small.tsv" /> | |
| 727 </repeat> | |
| 728 <repeat name="tables"> | |
| 729 <param name="input" value="small.tsv" /> | |
| 730 </repeat> | |
| 731 <param name="fulltable_custom_expr" value="(3 * table1) + np.log(table3 + 20) - table2" /> </conditional> | |
| 732 <output name="table" value="small.multiple.tsv" /> | |
| 733 </test> | |
| 734 <!-- User tests that failed previously --> | |
| 735 <test expect_num_outputs="1"> | |
| 736 <!-- Test 18 --> | |
| 737 <expand macro="test_inputs_single" > | |
| 738 <param name="mode" value="fulltable" /> | |
| 739 <conditional name="general" > | |
| 740 <param name="use" value="custom" /> | |
| 741 <param name="fulltable_custom_expr" value="table * 2" /> | |
| 742 </conditional> | |
| 743 </expand> | |
| 744 <output name="table" > | |
| 745 <assert_contents> | |
| 746 <has_n_columns n="10" /> | |
| 747 <has_line_matching expression="^gene1\s20\.000000\s0\s12\s-20\.200000\s20\s2\.200000\s0\.000000\s0\s0\.000000$" /> | |
| 748 <has_line_matching expression="gene5\s2\.000000\s0\s0\s-20\.000000\s880\s12\.000000\s0\.000000\s0\s3\.800000" /> | |
| 749 </assert_contents> | |
| 750 </output> | |
| 751 </test> | |
| 752 <test expect_num_outputs="1"> | |
| 753 <!-- Test 19 --> | |
| 754 <expand macro="test_inputs_single" > | |
| 755 <param name="mode" value="fulltable" /> | |
| 756 <conditional name="general" > | |
| 757 <param name="use" value="custom" /> | |
| 758 <param name="fulltable_custom_expr" value="table == 5" /> | |
| 759 </conditional> | |
| 760 </expand> | |
| 761 <output name="table" > | |
| 762 <assert_contents> | |
| 763 <has_n_columns n="10" /> | |
| 764 <has_line_matching expression="^gene1(\sFalse)+$" /> | |
| 765 <has_line_matching expression="gene5(\sFalse)+$" /> | |
| 766 </assert_contents> | |
| 767 </output> | |
| 768 </test> | |
| 769 <test expect_num_outputs="1" expect_failure="true"> | |
| 770 <!-- Test 20 --> | |
| 771 <expand macro="test_inputs_single" > | |
| 772 <param name="mode" value="fulltable" /> | |
| 773 <conditional name="general" > | |
| 774 <param name="use" value="custom" /> | |
| 775 <param name="fulltable_custom_expr" value="for n in table: n = n + 1" /> | |
| 776 </conditional> | |
| 777 </expand> | |
| 778 </test> | |
| 779 <test expect_num_outputs="1" expect_failure="true"> | |
| 780 <!-- Test 21 --> | |
| 781 <expand macro="test_inputs_single" > | |
| 782 <param name="mode" value="fulltable" /> | |
| 783 <conditional name="general" > | |
| 784 <param name="use" value="custom" /> | |
| 785 <param name="fulltable_custom_expr" value="table + table[0,0]" /> | |
| 786 </conditional> | |
| 787 </expand> | |
| 788 </test> | |
| 789 <test expect_num_outputs="1"> | |
| 790 <!-- Test 22: Melt --> | |
| 791 <expand macro="test_inputs_single" > | |
| 792 <param name="mode" value="fulltable" /> | |
| 793 <conditional name="general" > | |
| 794 <param name="use" value="melt" /> | |
| 795 <param name="id_vars" value="cell1,cell3" /> | |
| 796 <param name="value_vars" value="cell5,cell6" /> | |
| 797 </conditional> | |
| 798 </expand> | |
| 799 <param name="out_opts" value="ignore_nas,output_headers_col" /> | |
| 800 <output name="table" > | |
| 801 <assert_contents> | |
| 802 <has_n_columns n="4" /> | |
| 803 <has_line_matching expression="^cell1\scell3\svariable\svalue$" /> | |
| 804 <has_line_matching expression="^1\.0+\s0+\scell6\s6\.0+$" /> | |
| 805 </assert_contents> | |
| 806 </output> | |
| 807 </test> | |
| 808 <test expect_num_outputs="1"> | |
| 809 <!-- Test 23: Pivot --> | |
| 810 <expand macro="test_inputs_single" > | |
| 811 <param name="mode" value="fulltable" /> | |
| 812 <conditional name="general" > | |
| 813 <param name="use" value="pivot" /> | |
| 814 <param name="index" value="cell1" /> | |
| 815 <param name="column" value="cell2" /> | |
| 816 <param name="values" value="cell3,cell7,cell9" /> | |
| 817 </conditional> | |
| 818 </expand> | |
| 819 <output name="table" > | |
| 820 <assert_contents> | |
| 821 <has_n_columns n="4" /> | |
| 822 <has_line_matching expression="^\scell3\scell7\scell9$" /> | |
| 823 <has_line_matching expression="^1\.0+\s0\.0+\s0\.0+\s1\.90+$" /> | |
| 824 <has_line_matching expression="^10\.0+\s6\.0+\s0\.0+\s0\.0+$" /> | |
| 825 </assert_contents> | |
| 826 </output> | |
| 827 </test> | |
| 828 <!-- Add Example Text Tests --> | |
| 829 <test expect_num_outputs="1" > | |
| 830 <!-- Test 24: Ex 1 --> | |
| 831 <conditional name="singtabop" > | |
| 832 <param name="use_type" value="single" /> | |
| 833 <param name="input" value="examples.1.tsv" /> | |
| 834 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 835 <conditional name="user" > | |
| 836 <param name="mode" value="select" /> | |
| 837 <param name="select_cols_wanted" value="1,1,3" /> | |
| 838 <param name="select_rows_wanted" value="1:3,2" /> | |
| 839 <param name="select_keepdupe" value="select_cols_keepdupe,select_rows_keepdupe" /> | |
| 840 </conditional> | |
| 841 </conditional> | |
| 842 <output name="table" > | |
| 843 <assert_contents> | |
| 844 <has_n_columns n="4" /> | |
| 845 <has_line_matching expression="^\s+c1\s+c1\s+c3$" /> | |
| 846 <has_line_matching expression="^g2\s+3\s+3\s+9$" /> | |
| 847 </assert_contents> | |
| 848 </output> | |
| 849 </test> | |
| 850 <test expect_num_outputs="1" > | |
| 851 <!-- Test 25: Ex 2 --> | |
| 852 <conditional name="singtabop" > | |
| 853 <param name="use_type" value="single" /> | |
| 854 <param name="input" value="examples.2.tsv" /> | |
| 855 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 856 <conditional name="user" > | |
| 857 <param name="mode" value="filtersumval" /> | |
| 858 <param name="axis" value="1" /> | |
| 859 <conditional name="filtersumval_mode" > | |
| 860 <param name="use" value="operation" /> | |
| 861 <param name="operation" value="sum" /> | |
| 862 <param name="compare_op" value="lt" /> | |
| 863 <param name="against" value="50" /> | |
| 864 </conditional> | |
| 865 </conditional> | |
| 866 </conditional> | |
| 867 <output name="table" > | |
| 868 <assert_contents> | |
| 869 <has_n_columns n="4" /> | |
| 870 <has_line_matching expression="^\s+c1\s+c2\s+c3$" /> | |
| 871 <has_line_matching expression="^g3\s+4\s+8\s+12$" /> | |
| 872 </assert_contents> | |
| 873 </output> | |
| 874 </test> | |
| 875 <test expect_num_outputs="1" > | |
| 876 <!-- Test 26: Ex 3_P1 --> | |
| 877 <conditional name="singtabop" > | |
| 878 <param name="use_type" value="single" /> | |
| 879 <param name="input" value="examples.3p1.tsv" /> | |
| 880 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 881 <conditional name="user" > | |
| 882 <param name="mode" value="element" /> | |
| 883 <conditional name="element" > | |
| 884 <param name="mode" value="custom" /> | |
| 885 <param name="custom_expr" value="elem < 10" /> | |
| 886 </conditional> | |
| 887 <conditional name="elem_val" > | |
| 888 <param name="element_op" value="None" /> | |
| 889 </conditional> | |
| 890 </conditional> | |
| 891 </conditional> | |
| 892 <output name="table" > | |
| 893 <assert_contents> | |
| 894 <has_n_columns n="4" /> | |
| 895 <has_line_matching expression="^g1\s+False\s+False\s+False$" /> | |
| 896 <has_line_matching expression="^g4\s+False\s+True\s+True$" /> | |
| 897 </assert_contents> | |
| 898 </output> | |
| 899 </test> | |
| 900 <test expect_num_outputs="1" > | |
| 901 <!-- Test 27: Ex 3_P2 --> | |
| 902 <conditional name="singtabop" > | |
| 903 <param name="use_type" value="single" /> | |
| 904 <param name="input" value="examples.3p2.tsv" /> | |
| 905 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 906 <conditional name="user" > | |
| 907 <param name="mode" value="matrixapply" /> | |
| 908 <param name="dimension" value="1" /> | |
| 909 <conditional name="matrixapply_func" > | |
| 910 <param name="vector_op" value="sum" /> | |
| 911 </conditional> | |
| 912 </conditional> | |
| 913 </conditional> | |
| 914 <output name="table" > | |
| 915 <assert_contents> | |
| 916 <has_n_columns n="2" /> | |
| 917 <has_line_matching expression="^g1\s+0$" /> | |
| 918 <has_line_matching expression="^g4\s+2$" /> | |
| 919 </assert_contents> | |
| 920 </output> | |
| 921 </test> | |
| 922 <test expect_num_outputs="1" > | |
| 923 <!-- Test 28: Ex 4 --> | |
| 924 <conditional name="singtabop" > | |
| 925 <param name="use_type" value="single" /> | |
| 926 <param name="input" value="examples.4.tsv" /> | |
| 927 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 928 <conditional name="user" > | |
| 929 <param name="mode" value="element" /> | |
| 930 <conditional name="element" > | |
| 931 <param name="mode" value="custom" /> | |
| 932 <param name="custom_expr" value="(math.log(elem) / elem) if (elem > 5) else 1" /> | |
| 933 </conditional> | |
| 934 <conditional name="elem_val" > | |
| 935 <param name="element_op" value="All" /> | |
| 936 </conditional> | |
| 937 </conditional> | |
| 938 </conditional> | |
| 939 <output name="table" > | |
| 940 <assert_contents> | |
| 941 <has_n_columns n="4" /> | |
| 942 <has_line_matching expression="^g1\s+1\.00\d+\s+0\.149\d+\s+0\.113\d+$" /> | |
| 943 <has_line_matching expression="^g4\s+0\.05\d+\s+1\.000\d+\s+1\.000\d+$" /> | |
| 944 </assert_contents> | |
| 945 </output> | |
| 946 </test> | |
| 947 <test expect_num_outputs="1" > | |
| 948 <!-- Test 29: Ex 5 --> | |
| 949 <conditional name="singtabop" > | |
| 950 <param name="use_type" value="single" /> | |
| 951 <param name="input" value="examples.5.tsv" /> | |
| 952 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 953 <conditional name="user" > | |
| 954 <param name="mode" value="fulltable" /> | |
| 955 <conditional name="general" > | |
| 956 <param name="use" value="custom" /> | |
| 957 <param name="fulltable_custom_expr" value="table - table.mean(0)/table.std(0)" /> | |
| 958 </conditional> | |
| 959 </conditional> | |
| 960 </conditional> | |
| 961 <output name="table" > | |
| 962 <assert_contents> | |
| 963 <has_n_columns n="4" /> | |
| 964 <has_line_matching expression="^g1\s+9\.\d+\s+17\.\d+\s+28\.\d+$" /> | |
| 965 <has_line_matching expression="^g4\s+80\.\d+\s+7\.\d+\s+8\.\d+$" /> | |
| 966 </assert_contents> | |
| 967 </output> | |
| 968 </test> | |
| 969 <test expect_num_outputs="1" > | |
| 970 <!-- Test 30: Ex 6 --> | |
| 971 <conditional name="singtabop" > | |
| 972 <param name="use_type" value="multiple" /> | |
| 973 <repeat name="tables" > | |
| 974 <param name="input" value="examples.6p1.tsv" /> | |
| 975 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 976 </repeat> | |
| 977 <repeat name="tables" > | |
| 978 <param name="input" value="examples.6p2.tsv" /> | |
| 979 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 980 </repeat> | |
| 981 <repeat name="tables" > | |
| 982 <param name="input" value="examples.6p3.tsv" /> | |
| 983 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 984 </repeat> | |
| 985 <param name="fulltable_custom_expr" value="table1 / min(np.max(np.max(table2)), np.max(np.max(table3)))" /> | |
| 986 </conditional> | |
| 987 <output name="table" > | |
| 988 <assert_contents> | |
| 989 <has_n_columns n="4" /> | |
| 990 <has_line_matching expression="^g1\s+3\.3\d+\s+6\.6\d+\s+10\.0\d+$" /> | |
| 991 <has_line_matching expression="^g3\s+1\.3\d+\s+2\.6\d+\s+3\.3\d+$" /> | |
| 992 </assert_contents> | |
| 993 </output> | |
| 994 </test> | |
| 995 <test expect_num_outputs="1" > | |
| 996 <!-- Test 31: Ex 7 --> | |
| 997 <conditional name="singtabop" > | |
| 998 <param name="use_type" value="single" /> | |
| 999 <param name="input" value="examples.7.tsv" /> | |
| 1000 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 1001 <conditional name="user"> | |
| 1002 <param name="mode" value="fulltable" /> | |
| 1003 <conditional name="general" > | |
| 1004 <param name="use" value="melt" /> | |
| 1005 <param name="id_vars" value="A" /> | |
| 1006 <param name="value_vars" value="B,C" /> | |
| 1007 </conditional> | |
| 1008 </conditional> | |
| 1009 </conditional> | |
| 1010 <output name="table" > | |
| 1011 <assert_contents> | |
| 1012 <has_n_columns n="4" /> | |
| 1013 <has_line_matching expression="^0\s+a\s+B\s+B\s*$" /> | |
| 1014 <has_line_matching expression="^5\s+c\s+C\s+5\s*$" /> | |
| 1015 </assert_contents> | |
| 1016 </output> | |
| 1017 </test> | |
| 1018 <test expect_num_outputs="1" > | |
| 1019 <!-- Test 32: Ex 8 --> | |
| 1020 <conditional name="singtabop" > | |
| 1021 <param name="use_type" value="single" /> | |
| 1022 <param name="input" value="examples.8.tsv" /> | |
| 1023 <param name="col_row_names" value="has_col_names,has_row_names" /> | |
| 1024 <conditional name="user" > | |
| 1025 <param name="mode" value="fulltable" /> | |
| 1026 <conditional name="general" > | |
| 1027 <param name="use" value="pivot" /> | |
| 1028 <param name="index" value="foo" /> | |
| 1029 <param name="column" value="bar" /> | |
| 1030 <param name="values" value="baz" /> | |
| 1031 </conditional> | |
| 1032 </conditional> | |
| 1033 </conditional> | |
| 1034 <output name="table" > | |
| 1035 <assert_contents> | |
| 1036 <has_n_columns n="4" /> | |
| 1037 <has_line_matching expression="^one\s+1\s+2\s+3$" /> | |
| 1038 <has_line_matching expression="^two\s+4\s+5\s+6$" /> | |
| 1039 </assert_contents> | |
| 1040 </output> | |
| 1041 </test> | |
| 1042 </tests> | |
| 1043 <help><![CDATA[ | |
| 1044 This tool computes table expressions on the element, row, and column basis. It can sub-select, | |
| 1045 duplicate, as well as perform general and custom expressions on rows, columns or elements. | |
| 1046 | |
| 1047 Only a single operation can be performed on the data. Multiple operations can be performed by | |
| 1048 chaining successive runs of this tool. This is to provide a more transparent workflow for complex operations. | |
| 1049 | |
| 1050 | |
| 1051 | |
| 1052 Examples | |
| 1053 ======== | |
| 1054 | |
| 1055 Example 1: Sub-selecting from a table | |
| 1056 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 1057 | |
| 1058 We have the following table: | |
| 1059 | |
| 1060 === === === === | |
| 1061 . c1 c2 c3 | |
| 1062 === === === === | |
| 1063 g1 10 20 30 | |
| 1064 g2 3 6 9 | |
| 1065 g3 4 8 12 | |
| 1066 g4 81 6 3 | |
| 1067 === === === === | |
| 1068 | |
| 1069 and we want to duplicate c1 and remove c2. Also select g1 to g3 and add g2 at the end as well. This would result in the output table: | |
| 1070 | |
| 1071 === === === === | |
| 1072 . c1 c1 c3 | |
| 1073 === === === === | |
| 1074 g1 10 10 30 | |
| 1075 g2 3 3 9 | |
| 1076 g3 4 4 12 | |
| 1077 g2 3 3 9 | |
| 1078 === === === === | |
| 1079 | |
| 1080 In Galaxy we would select the following: | |
| 1081 | |
| 1082 * *Input Single or Multiple Tables* → **Single Table** | |
| 1083 * *Column names on first row?* → **Yes** | |
| 1084 * *Row names on first column?* → **Yes** | |
| 1085 * *Type of table operation* → **Drop, keep or duplicate rows and columns** | |
| 1086 | |
| 1087 * *List of columns to select* → **1,1,3** | |
| 1088 * *List of rows to select* → **1:3,2** | |
| 1089 * *Keep duplicate columns* → **Yes** | |
| 1090 * *Keep duplicate rows* → **Yes** | |
| 1091 | |
| 1092 Example 2: Filter for rows with row sums less than 50 | |
| 1093 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 1094 | |
| 1095 We have the following table: | |
| 1096 | |
| 1097 === === === === | |
| 1098 . c1 c2 c3 | |
| 1099 === === === === | |
| 1100 g1 10 20 30 | |
| 1101 g2 3 6 9 | |
| 1102 g3 4 8 12 | |
| 1103 g4 81 6 3 | |
| 1104 === === === === | |
| 1105 | |
| 1106 and we want: | |
| 1107 | |
| 1108 === === === === | |
| 1109 . c1 c2 c3 | |
| 1110 === === === === | |
| 1111 g2 3 6 9 | |
| 1112 g3 4 8 12 | |
| 1113 === === === === | |
| 1114 | |
| 1115 In Galaxy we would select the following: | |
| 1116 | |
| 1117 * *Input Single or Multiple Tables* → **Single Table** | |
| 1118 * *Column names on first row?* → **Yes** | |
| 1119 * *Row names on first column?* → **Yes** | |
| 1120 * *Type of table operation* → **Filter rows or columns by their properties** | |
| 1121 | |
| 1122 * *Filter* → **Rows** | |
| 1123 * *Filter Criterion* → **Result of function applied to columns/rows** | |
| 1124 | |
| 1125 * *Keep column/row if its observed* → **Sum** | |
| 1126 * *is* → **< (Less Than)** | |
| 1127 * *this value* → **50** | |
| 1128 | |
| 1129 | |
| 1130 Example 3: Count the number of values per row smaller than a specified value | |
| 1131 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 1132 | |
| 1133 We have the following table: | |
| 1134 | |
| 1135 === === === === | |
| 1136 . c1 c2 c3 | |
| 1137 === === === === | |
| 1138 g1 10 20 30 | |
| 1139 g2 3 6 9 | |
| 1140 g3 4 8 12 | |
| 1141 g4 81 6 3 | |
| 1142 === === === === | |
| 1143 | |
| 1144 and we want to count how many elements in each row are smaller than 10, i.e., | |
| 1145 we want to obtain the following results table: | |
| 1146 | |
| 1147 === === | |
| 1148 . vec | |
| 1149 === === | |
| 1150 g1 0 | |
| 1151 g2 3 | |
| 1152 g3 2 | |
| 1153 g4 2 | |
| 1154 === === | |
| 1155 | |
| 1156 In Galaxy we would select the following: | |
| 1157 | |
| 1158 * *Input Single or Multiple Tables* → **Single Table** | |
| 1159 * *Column names on first row?* → **Yes** | |
| 1160 * *Row names on first column?* → **Yes** | |
| 1161 * *Type of table operation* → **Manipulate selected table elements** | |
| 1162 | |
| 1163 * *Operation to perform* → **Custom** | |
| 1164 | |
| 1165 * *Custom Expression on 'elem'* → **elem < 10** | |
| 1166 | |
| 1167 * *Operate on elements* → **All** | |
| 1168 | |
| 1169 **Note:** *There are actually simpler ways to achieve our purpose, but here we are demonstrating the use of a custom expression.* | |
| 1170 | |
| 1171 After executing, we would then be presented with a table like so: | |
| 1172 | |
| 1173 === ===== ===== ===== | |
| 1174 . c1 c2 c3 | |
| 1175 === ===== ===== ===== | |
| 1176 g1 False False False | |
| 1177 g2 True True True | |
| 1178 g3 True True False | |
| 1179 g4 False True True | |
| 1180 === ===== ===== ===== | |
| 1181 | |
| 1182 To get to our desired table, we would then process this table with the tool again: | |
| 1183 | |
| 1184 * *Input Single or Multiple Tables* → **Single Table** | |
| 1185 * *Column names on first row?* → **Yes** | |
| 1186 * *Row names on first column?* → **Yes** | |
| 1187 * *Type of table operation* → **Compute Expression across Rows or Columns** | |
| 1188 | |
| 1189 * *Calculate* → **Sum** | |
| 1190 * *For each* → **Row** | |
| 1191 | |
| 1192 Executing this will sum all the 'True' values in each row. Note that the values must have no extra whitespace in them for this to work (e.g. 'True ' or ' True' will not be parsed correctly). | |
| 1193 | |
| 1194 | |
| 1195 Example 4: Perform a scaled log-transformation conditionally | |
| 1196 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 1197 | |
| 1198 We want to perform a scaled log transformation on all values greater than 5, and set all other values to 1. | |
| 1199 | |
| 1200 We have the following table: | |
| 1201 | |
| 1202 === === === === | |
| 1203 . c1 c2 c3 | |
| 1204 === === === === | |
| 1205 g1 0 20 30 | |
| 1206 g2 3 0 9 | |
| 1207 g3 4 8 0 | |
| 1208 g4 81 0 0 | |
| 1209 === === === === | |
| 1210 | |
| 1211 and we want: | |
| 1212 | |
| 1213 === ========== ========= ========= | |
| 1214 . c1 c2 c3 | |
| 1215 === ========== ========= ========= | |
| 1216 g1 1.00000000 0.1497866 0.1133732 | |
| 1217 g2 1.00000000 1.0000000 0.2441361 | |
| 1218 g3 1.00000000 0.2599302 1.0000000 | |
| 1219 g4 0.05425246 1.0000000 1.0000000 | |
| 1220 === ========== ========= ========= | |
| 1221 | |
| 1222 In Galaxy we would select the following: | |
| 1223 | |
| 1224 * *Input Single or Multiple Tables* → **Single Table** | |
| 1225 * *Column names on first row?* → **Yes** | |
| 1226 * *Row names on first column?* → **Yes** | |
| 1227 * *Type of table operation* → **Manipulate selected table elements** | |
| 1228 | |
| 1229 * *Operation to perform* → **Custom** | |
| 1230 | |
| 1231 * *Custom Expression* → :: | |
| 1232 | |
| 1233 (math.log(elem) / elem) if (elem > 5) else 1 | |
| 1234 | |
| 1235 * *Operate on elements* → **All** | |
| 1236 | |
| 1237 | |
| 1238 Example 5: Perform a Full table operation | |
| 1239 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 1240 | |
| 1241 We have the following table: | |
| 1242 | |
| 1243 === === === === | |
| 1244 . c1 c2 c3 | |
| 1245 === === === === | |
| 1246 g1 10 20 30 | |
| 1247 g2 3 10 9 | |
| 1248 g3 4 8 10 | |
| 1249 g4 81 10 10 | |
| 1250 === === === === | |
| 1251 | |
| 1252 and we want to subtract from each column the mean of that column divided by the standard deviation of it to yield: | |
| 1253 | |
| 1254 | |
| 1255 === ========= ========= ========= | |
| 1256 . c1 c2 c3 | |
| 1257 === ========= ========= ========= | |
| 1258 g1 9.351737 17.784353 28.550737 | |
| 1259 g2 2.351737 7.784353 7.550737 | |
| 1260 g3 3.351737 5.784353 8.550737 | |
| 1261 g4 80.351737 7.784353 8.550737 | |
| 1262 === ========= ========= ========= | |
| 1263 | |
| 1264 In Galaxy we would select the following: | |
| 1265 | |
| 1266 * *Input Single or Multiple Tables* → **Single Table** | |
| 1267 * *Column names on first row?* → **Yes** | |
| 1268 * *Row names on first column?* → **Yes** | |
| 1269 * *Type of table operation* → **Perform a Full Table Operation** | |
| 1270 | |
| 1271 * *Operation* → **Custom** | |
| 1272 | |
| 1273 * *Custom Expression on 'table' along axis (0 or 1)* → :: | |
| 1274 | |
| 1275 table - table.mean(0)/table.std(0) | |
| 1276 | |
| 1277 | |
| 1278 Example 6: Perform operations on multiple tables | |
| 1279 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 1280 | |
| 1281 We have the following three input tables: | |
| 1282 | |
| 1283 Table 1 | |
| 1284 | |
| 1285 === === === === | |
| 1286 . c1 c2 c3 | |
| 1287 === === === === | |
| 1288 g1 10 20 30 | |
| 1289 g2 3 10 9 | |
| 1290 g3 4 8 10 | |
| 1291 === === === === | |
| 1292 | |
| 1293 Table 2 | |
| 1294 | |
| 1295 === === === | |
| 1296 . c1 c2 | |
| 1297 === === === | |
| 1298 g1 1 2 | |
| 1299 g2 3 4 | |
| 1300 g3 6 5 | |
| 1301 === === === | |
| 1302 | |
| 1303 Table 3 | |
| 1304 | |
| 1305 === === === === | |
| 1306 . c1 c2 c3 | |
| 1307 === === === === | |
| 1308 g1 1 2 3 | |
| 1309 g2 1 2 3 | |
| 1310 === === === === | |
| 1311 | |
| 1312 | |
| 1313 *Note that the dimensions of these tables do not match.* | |
| 1314 | |
| 1315 Dimensions: | |
| 1316 * Table1 [3,3] | |
| 1317 * Table2 [3,2] | |
| 1318 * Table3 [2,3] | |
| 1319 | |
| 1320 In order to perform simple operations between Tables, they must be of the same dimensions. | |
| 1321 | |
| 1322 To add Table2 to Table3 we would have to transpose one of the tables using the in-built `T` method:: | |
| 1323 | |
| 1324 table2 + table3.T | |
| 1325 | |
| 1326 or:: | |
| 1327 | |
| 1328 table2.T + table3 | |
| 1329 | |
| 1330 We can also perform more general operations using all 3 tables, such as taking the minimum value of | |
| 1331 the maximum values of Table2 and Table3, and dividing the Table1 values by it:: | |
| 1332 | |
| 1333 table1 / min(table2.values.max(), table3.values.max()) | |
| 1334 | |
| 1335 | |
| 1336 To perform these types of operations in Galaxy we would select the following: | |
| 1337 | |
| 1338 * *Input Single or Multiple Tables* → **Multiple Tables** | |
| 1339 * *(For each inserted table)* | |
| 1340 * *Column names on first row?* → **Yes** | |
| 1341 * *Row names on first column?* → **Yes** | |
| 1342 * *Custom Expression* → :: | |
| 1343 | |
| 1344 <insert your desired function> | |
| 1345 | |
| 1346 Please note that the last example shown above was chosen to illustrate the | |
| 1347 limitations of the tool. Nested attributes like `table2.values.max` are | |
| 1348 disallowed in expressions in the tool so the above would have to be replaced | |
| 1349 with the harder to read workaround:: | |
| 1350 | |
| 1351 table1 / min(np.max(np.max(table2)), np.max(np.max(table3))) | |
| 1352 | |
| 1353 Also note that, currently `min()`, `max()` and `sum()` are the only built-in | |
| 1354 Python functions that can be used inside expressions. If you want to use | |
| 1355 additional functions, these have to be qualified functions from the `math`, | |
| 1356 `np` or `pd` libraries. | |
| 1357 | |
| 1358 | |
| 1359 Example 7: Melt | |
| 1360 ~~~~~~~~~~~~~~~ | |
| 1361 | |
| 1362 We have the following table | |
| 1363 | |
| 1364 === === === === | |
| 1365 . A B C | |
| 1366 === === === === | |
| 1367 0 a B 1 | |
| 1368 1 b B 3 | |
| 1369 2 c B 5 | |
| 1370 === === === === | |
| 1371 | |
| 1372 and we want: | |
| 1373 | |
| 1374 === === ======== ===== | |
| 1375 . A variable value | |
| 1376 === === ======== ===== | |
| 1377 0 a B B | |
| 1378 1 b B B | |
| 1379 2 c B B | |
| 1380 3 a C 1 | |
| 1381 4 b C 3 | |
| 1382 5 c C 5 | |
| 1383 === === ======== ===== | |
| 1384 | |
| 1385 | |
| 1386 In Galaxy we would select the following: | |
| 1387 | |
| 1388 * *Input Single or Multiple Tables* → **Single Table** | |
| 1389 * *Column names on first row?* → **Yes** | |
| 1390 * *Row names on first column?* → **Yes** | |
| 1391 * *Type of table operation* → **Perform a Full Table Operation** | |
| 1392 | |
| 1393 * *Operation* → **Melt** | |
| 1394 * *Variable IDs* → "A" | |
| 1395 * *Unpivoted IDs* → "B,C" | |
| 1396 | |
| 1397 This converts the "B" and "C" columns into variables. | |
| 1398 | |
| 1399 | |
| 1400 Example 8: Pivot | |
| 1401 ~~~~~~~~~~~~~~~~ | |
| 1402 | |
| 1403 We have the following table | |
| 1404 | |
| 1405 === === === === === | |
| 1406 . foo bar baz zoo | |
| 1407 === === === === === | |
| 1408 0 one A 1 x | |
| 1409 1 one B 2 y | |
| 1410 2 one C 3 z | |
| 1411 3 two A 4 q | |
| 1412 4 two B 5 w | |
| 1413 5 two C 6 t | |
| 1414 === === === === === | |
| 1415 | |
| 1416 and we want: | |
| 1417 | |
| 1418 === === === === | |
| 1419 . A B C | |
| 1420 === === === === | |
| 1421 one 1 2 3 | |
| 1422 two 4 5 6 | |
| 1423 === === === === | |
| 1424 | |
| 1425 In Galaxy we would select the following: | |
| 1426 | |
| 1427 * *Input Single or Multiple Tables* → **Single Table** | |
| 1428 * *Column names on first row?* → **Yes** | |
| 1429 * *Row names on first column?* → **Yes** | |
| 1430 * *Type of table operation* → **Perform a Full Table Operation** | |
| 1431 | |
| 1432 * *Operation* → **Pivot** | |
| 1433 * *Index* → "foo" | |
| 1434 * *Column* → "bar" | |
| 1435 * *Values* → "baz" | |
| 1436 | |
| 1437 This splits the matrix using "foo" and "bar" using only the values from "baz". Header values may contain extra information. | |
| 1438 | |
| 1439 ]]></help> | |
| 1440 <citations></citations> | |
| 1441 </tool> |
