Home Pattern

Tabular: concatenate collection to table

Stack compatible tabular collection elements into one dataset, with one header and a sample column when needed.

Revised
2026-09-30
Rev
3

Pattern health

ok
  • IWC exemplar anchors

    4 abstract workflow anchors declared.

  • Foundry verification fixture

    1 verification path declared.

  • Pattern map coverage

    2 pattern maps link here.

  • Metadata contract

    Pattern frontmatter matches the site contract.

Tabular: concatenate collection to table

Connect a list collection of compatible tabular datasets to collapse_dataset when a downstream step needs one table containing their rows. Decide whether the output needs a column identifying the source element and whether each input has a header. The tool appends elements in collection order. It does not join rows by a key or put each element in a separate column. For the latter shape, use tabular-pivot-collection-to-wide.

Build a table with sample names

The checked-in example under verification/workflows/tabular-concatenate-collection-to-table/ has two collection elements named alpha and beta, each with the same two-column header:

alpha:             beta:
feature  count     feature  count
x        2         x        5
y        3

Connect the collection to input_list and use these step settings. The collection connection belongs in the workflow’s in: entry for input_list.

tool_id: toolshed.g2.bx.psu.edu/repos/nml/collapse_collections/collapse_dataset/5.1.0
tool_state:
  input_list: { __class__: ConnectedValue }
  filename:
    add_name: true
    place_name: same_multiple
  one_header: true

The output is one table:

Sample  feature  count
alpha   x        2
alpha   y        3
beta    x        5

Spaces in these displays align columns. The actual separator is a tab, and the workflow test compares the full output with the committed expected file. same_multiple prefixes every data row with its collection element identifier. With one_header: true, the tool copies the first element’s first line once, prefixes it with Sample when names are enabled, and skips the first line of every element before writing data rows. The variation-reporting workflow uses this combination before further table processing.

Choose header and name handling

Input and desired outputSettingsEffect
Headered tables, one output header, row provenanceone_header: true, add_name: true, place_name: same_multipleOne Sample column plus one copy of the first header
Headered tables with identity already in their rowsone_header: true, add_name: falseOne copy of the first header, no extra column
Headerless tables, no new provenance columnone_header: false, add_name: falseAll lines copied in collection order
Headerless tables, row provenanceone_header: false, add_name: true, place_name: same_multipleElement identifier prefixed to every line, with no generated header

The verification workflow also checks the third shape with headerless alpha and beta elements, producing exactly a\t1 and b\t2 as two rows. The MAPseq-to-ampvis2 workflow uses the third shape. The influenza consensus and subtyping workflow uses the fourth shape in some branches and same_once in another. The PathoGFAIR workflow also keeps one header without adding element names for one of its tabular outputs.

same_once writes the element identifier before only the first retained line of each element. above writes it on a separate line. Those modes mark blocks, so their output is not the rectangular table shown above. Choose them only when the next tool expects that layout. The pinned wrapper defines all three modes.

Check the result before using it

  • Confirm every input has the same columns in the same order. one_header discards later headers without comparing them, so mismatched columns can pass through under the first element’s labels.
  • Enable one_header only when every element has a header. With headerless inputs it removes a real first data row from each element. With one_header: false, any existing input headers remain among the output rows.
  • If downstream grouping or filtering needs the source sample, check that each output row has the expected element identifier. add_name: false is appropriate when that identity is already in the data or unnecessary.
  • Check the output column count and a row from each element. A name column shifts subsequent one-based column positions, and block-label modes do not produce the same table shape.

For two ordinary file inputs rather than a collection, tp_cat or cat1 may fit the workflow. For grouping rows already in one table, use tabular-group-and-aggregate-with-datamash. See iwc-tabular-operations-survey for the wider tool inventory and tabular-cut-and-reorder-columns for downstream column selection.

IWC exemplars 4 anchors

IWC Exemplars

sars-cov-2-variant-calling/sars-cov-2-variation-reporting/variation-reporting high

Stacks per-element tables, keeps one header, and repeats each element identifier in a Sample column.

amplicon/amplicon-mgnify/mapseq-to-ampvis2/mapseq-to-ampvis2 high

Stacks a collection without adding element names or removing first lines.

virology/influenza-isolates-consensus-and-subtyping/influenza-consensus-and-subtyping high

Uses both per-row element names and block labels in separate collection concatenations.

microbiome/pathogen-identification/pathogen-detection-pathogfair-samples-aggregation-and-visualisation/Pathogen-Detection-PathoGFAIR-Samples-Aggregation-and-Visualisation high

Stacks tabular results with one header and no added name, alongside other collection concatenations.

Incoming References (13)

  • Collection: build named bundle related pattern — Use BUILD_LIST to assemble named outputs into a collection bundle for publishing or downstream fan-in.
  • Fan-in bundle, consume, and flatten related pattern — Bundle parallel outputs into a collection consumer, then flatten nested results for pooled downstream processing.
  • Galaxy: collection patterns related pattern — Choose a Galaxy collection operation or map-over recipe from the current and required data shapes.
  • Galaxy: tabular patterns related pattern — Use this MOC to choose corpus-grounded Galaxy tabular transformation patterns.
  • Tabular: pivot collection to wide related pattern — Join a collection of keyed tabular datasets into a wide table, choosing missing-cell fill and output headers to fit the data.
  • Tabular: prepend header related pattern — Add a fixed first line with tp_awk_tool, choosing whether to keep or replace the input's first row and whether to rewrite its fields.
  • Tabular: relabel by row counter related pattern — Use tp_awk_tool and awk NR to replace each input line with a row-order label, with explicit header and numbering choices.
  • Tabular: split into collection by key related pattern — Split a tabular file into a list collection by column value, grouping rows that share an identifier.
  • Iwc Map Over Lifecycle Survey related pattern — Survey of IWC map-over lifecycle recipes, with a Nextflow-to-Galaxy crosswalk for collection construction, cleanup, reshape, reduce, and publish phases.
  • Iwc Tabular Operations Survey related note — Corpus survey of tabular tools and operations across IWC workflows. Evidence for the operation pattern hierarchy on row/column data manipulation.
  • Nextflow-to-Galaxy channel shape mapping related note — Maps common Nextflow channel, tuple, and path shapes to Galaxy dataset and collection shapes.
  • Nextflow: mapped output cleanup and publishing implemented_by_patterns — Route Nextflow mapped-output cleanup and publishDir-style intent to Galaxy filtering, relabeling, gating, bundling, and reports.
  • Nextflow: mix and collect to report aggregation implemented_by_patterns — Route Nextflow mix, collect, toList, and collectFile report fan-in idioms to Galaxy aggregation and bundle patterns.