Home Pattern

Collection: flatten after fan-out

Use FLATTEN to collapse nested collection outputs to a flat list once the outer axis no longer matters.

draft pattern
Revised
2026-05-03
Rev
2

Pattern health

warn
  • IWC exemplar anchors

    3 abstract workflow anchors declared.

  • Foundry verification fixture

    No structural verification fixture yet.

  • Pattern map coverage

    No pattern map links to this leaf yet.

  • Metadata contract

    Pattern frontmatter matches the site contract.

Collection: flatten after fan-out

Tool

Use Galaxy built-in __FLATTEN__.

The corpus-attested operation is simple: collapse a nested collection such as list:list or list:paired into a flat list when the outer grouping axis has served its purpose.

When to reach for it

Use this after a tool fans out within each sample/group and downstream no longer needs that grouping.

Typical shape: a domain tool maps over a collection and produces nested outputs, the outer axis becomes only organizational, and __FLATTEN__ produces one flat list for pooling, relabeling, reporting, or MultiQC-style consumption.

Do not flatten if downstream needs to know which outer sample/group produced each element.

Parameters

tool_id: __FLATTEN__
tool_state:
  input: { __class__: ConnectedValue }

The useful authoring decision is input collection type and whether the outer axis is truly no longer meaningful.

Pitfalls

  • Flattening discards structure. Element identifiers may retain hints, but the Galaxy collection type no longer encodes the outer axis.
  • Flatten only after the outer axis is done.
  • If flattened identifiers collide or become unreadable, add an explicit relabel step.
  • Do not use Apply Rules for plain flattening; the survey found __FLATTEN__ dominates simple cases.

See also

IWC exemplars3 anchors

IWC Exemplars

microbiome/mags-building/MAGs-generationhigh

Flattens a list:list of bins from all samples for pool-level processing.

transcriptomics/rnaseq-pe/rnaseq-pehigh

Flattens a paired collection to a flat list for MultiQC.

microbiome/metagenomic-raw-reads-amr-analysis/metagenomic-raw-reads-amr-analysishigh

Flattens list:list output from sylph_profile before relabeling.

Incoming References (10)