Nextflow: mapped output cleanup and publishing
Use this when a Nextflow source has mapped process outputs, cleanup/filtering around sparse results, final output aggregation, or publishDir/output-layout intent.
Source signal
- Repeated
tuple(meta, path(...))outputs from mapped processes. - Operators like
map,filter,branch,collect,toList,collectFile, andmixnear outputs. publishDirdirectives, outputemit:names, report channels, or version channels.- Naming cleanup via metadata, regex, filenames, or task-derived labels.
Galaxy translation
- Treat mapped process output as a Galaxy collection map-over result.
- Drop unusable per-element outputs with empty/failed collection filters.
- If cleanup changes membership, sync sibling collections from cleaned identifiers.
- Relabel outputs when Nextflow metadata or filenames carried element identity.
- Aggregate report-ready collections into tables, wide matrices, bundles, or singleton outputs.
- Gate report/export steps when the whole result may be empty.
- Translate
publishDirintent to Galaxy output labels, collections, bundles, or reports; do not preserve filesystem layout literally.
Pattern handoffs
- Cleanup: collection-cleanup-after-mapover-failure.
- Cleanup + sibling sync + publishing: cleanup-sync-and-publish-nonempty-results.
- Sibling membership sync: sync-collections-by-identifier.
- Label cleanup: regex-relabel-via-tabular, relabel-via-rules-and-find-replace.
- Non-empty report gate: conditional-gate-on-nonempty-result.
- Publishing bundles/reports: collection-build-named-bundle, tabular-concatenate-collection-to-table, tabular-pivot-collection-to-wide, collection-unbox-singleton.
Pitfalls
- Cleanup is not publishing.
- Dropping bad elements changes collection membership.
- Identifier sync is not order sync.
publishDirpaths are source-side filesystem presentation, not Galaxy workflow structure.- Do not translate arbitrary Groovy output-name logic from syntax alone.
Evidence posture
This page is grounded in existing Foundry lifecycle and source-shape notes. publishDir specifics remain under-supported without direct fixture evidence.