# Tips & Tricks

**URL:** https://community.seqera.io/c/tips-and-tricks/36.md

[Latest](https://community.seqera.io/latest.md) · [Categories](https://community.seqera.io/categories.md) · [Tags](https://community.seqera.io/tags.md)

---

## [About the Tips & Tricks category](https://community.seqera.io/t/about-the-tips-tricks-category/123)

<div class="topic-metadata">

**Author:** [@ewels](https://community.seqera.io/u/ewels)\
**Replies:** 0\
**Last updated:** [October 2, 2023, 7:36am UTC](https://community.seqera.io/t/about-the-tips-tricks-category/123 "2023-10-02T07:36:59Z")

</div>

Share and browse tips and tricks related to using Nextflow and related resources effectively. This is a great place for those code recipes and nuggets of information gleaned from experience that you don’t find in docume…

---

## [Cleaning output directory when workflow fails](https://community.seqera.io/t/cleaning-output-directory-when-workflow-fails/360)

<div class="topic-metadata">

**Author:** [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Replies:** 0\
**Last updated:** [January 3, 2024, 6:41pm UTC](https://community.seqera.io/t/cleaning-output-directory-when-workflow-fails/360 "2024-01-03T18:41:40Z")

</div>

Quite often we hear users asking for a way to only publish files if the workflow finished successfully. After all, if it didn’t, most people would delete the output directory with the results of your analysis and run the…

---

## [Get first N elements from a channel](https://community.seqera.io/t/get-first-n-elements-from-a-channel/125)

<div class="topic-metadata">

**Author:** [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Replies:** 0\
**Last updated:** [October 2, 2023, 7:44am UTC](https://community.seqera.io/t/get-first-n-elements-from-a-channel/125 "2023-10-02T07:44:13Z")

</div>

You may want to consume the first N elements from a channel and don’t know how to do it. Even though there is an operator for that (take, check details here), I think this is a nice opportunity to try to reproduce its b…

---

## [Nf-test: Get the relative paths of all files in a pipeline output folder](https://community.seqera.io/t/nf-test-get-the-relative-paths-of-all-files-in-a-pipeline-output-folder/609)

<div class="topic-metadata">

**Author:** [@nvnieuwk](https://community.seqera.io/u/nvnieuwk)\
**Replies:** 0\
**Last updated:** [March 28, 2024, 12:41pm UTC](https://community.seqera.io/t/nf-test-get-the-relative-paths-of-all-files-in-a-pipeline-output-folder/609 "2024-03-28T12:41:41Z")

</div>

Sometimes the pipeline outputs are not stable and thus snapshot(path("${outputDir}").list()) will not be enough since the md5sums created will be different. This snippet shows an alternative way to check if all files in …

---

## [Enabling resume for specific processes](https://community.seqera.io/t/enabling-resume-for-specific-processes/546)

<div class="topic-metadata">

**Author:** [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Replies:** 4\
**Last updated:** [September 15, 2025, 8:22am UTC](https://community.seqera.io/t/enabling-resume-for-specific-processes/546 "2025-09-15T08:22:41Z")

</div>

The default option for Nextflow is to start a workflow from the beginning. When a few processes have failed, you often want instead to resume from the last successfully completed processes. This can be done by using -res…

---

## [Running a Nextflow pipeline from a Git repository: Setting defaults](https://community.seqera.io/t/running-a-nextflow-pipeline-from-a-git-repository-setting-defaults/507)

<div class="topic-metadata">

**Author:** [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Replies:** 3\
**Last updated:** [October 1, 2024, 5:54am UTC](https://community.seqera.io/t/running-a-nextflow-pipeline-from-a-git-repository-setting-defaults/507 "2024-10-01T05:54:19Z")

</div>

Nextflow pipelines can be run directly from their Git repository URL. It’s as simple as: nextflow run nextflow-io/hello Under the hood, Nextflow will choose GitHub as Git provider by default (https://github.com/nextflo…

---

## [Skipping processes in an nf-core pipeline](https://community.seqera.io/t/skipping-processes-in-an-nf-core-pipeline/406)

<div class="topic-metadata">

**Author:** [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Replies:** 0\
**Last updated:** [January 18, 2024, 4:24pm UTC](https://community.seqera.io/t/skipping-processes-in-an-nf-core-pipeline/406 "2024-01-18T16:24:14Z")

</div>

You may want to run an nf-core pipeline, without having to go through all the steps. Some pipelines such as sarek will already have you covered with pipeline options such as --skip\_tools (check here), but what if this sp…

---

## [Remove channel entries using a keys/entries from another channel](https://community.seqera.io/t/remove-channel-entries-using-a-keys-entries-from-another-channel/564)

<div class="topic-metadata">

**Author:** [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Replies:** 0\
**Last updated:** [March 14, 2024, 9:04am UTC](https://community.seqera.io/t/remove-channel-entries-using-a-keys-entries-from-another-channel/564 "2024-03-14T09:04:37Z")

</div>

The channel operators join and combine are good for pairing up channel entries with a shared key. However, there are times when you want to exclude entries based what’s in another channel, e.g. similar to grep -v option.…

---

## [Collecting channel entries consisting of tuples and sending it to a process](https://community.seqera.io/t/collecting-channel-entries-consisting-of-tuples-and-sending-it-to-a-process/581)

<div class="topic-metadata">

**Author:** [@Alexander\_Nater](https://community.seqera.io/u/Alexander_Nater)\
**Replies:** 0\
**Last updated:** [March 21, 2024, 12:42pm UTC](https://community.seqera.io/t/collecting-channel-entries-consisting-of-tuples-and-sending-it-to-a-process/581 "2024-03-21T12:42:57Z")

</div>

We often have channel entries in the form of tuples containing some meta data and one or more paths. For a process, we might want to collect all the entries with collect(flat:false) or toList() and send the resulting lis…

---

## [Nf-test: Capture all process/workflow outputs without capturing md5sums of files in snapshots](https://community.seqera.io/t/nf-test-capture-all-process-workflow-outputs-without-capturing-md5sums-of-files-in-snapshots/611)

<div class="topic-metadata">

**Author:** [@nvnieuwk](https://community.seqera.io/u/nvnieuwk)\
**Replies:** 0\
**Last updated:** [March 28, 2024, 3:46pm UTC](https://community.seqera.io/t/nf-test-capture-all-process-workflow-outputs-without-capturing-md5sums-of-files-in-snapshots/611 "2024-03-28T15:46:38Z")

</div>

nf-test snapshots automatically create md5sums of files when they get an absolute path to a file. This can cause some issues when the output files are not 100% stable between reruns (e.g. when the date is included somewh…

---

## [Using a launch script to run nextflow](https://community.seqera.io/t/using-a-launch-script-to-run-nextflow/1543)

<div class="topic-metadata">

**Author:** [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Replies:** 0\
**Last updated:** [December 12, 2024, 2:04pm UTC](https://community.seqera.io/t/using-a-launch-script-to-run-nextflow/1543 "2024-12-12T14:04:02Z")

</div>

Using a launch script can be helpful in automatically running the latest version of a workflow, automatically clean up, or not having to deal with long commands. The suggestions below also allow for testing changes made …

---

## [Native Terminal Notifications on Pipeline completion](https://community.seqera.io/t/native-terminal-notifications-on-pipeline-completion/1289)

<div class="topic-metadata">

**Author:** [@emiller](https://community.seqera.io/u/emiller)\
**Replies:** 2\
**Last updated:** [November 6, 2024, 4:04pm UTC](https://community.seqera.io/t/native-terminal-notifications-on-pipeline-completion/1289 "2024-11-06T16:04:30Z")

</div>

So when running pipeline tests locally, sometimes a test takes a minute or two, and I’ll check the nf-core Slack or something else while waiting. I wanted a native notification when the test was completed, and I had pre…

---

## [Connecting / Chaining existing Nextflow workflows in a meta workflow](https://community.seqera.io/t/connecting-chaining-existing-nextflow-workflows-in-a-meta-workflow/969)

<div class="topic-metadata">

**Author:** [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Replies:** 1\
**Last updated:** [July 25, 2024, 11:06am UTC](https://community.seqera.io/t/connecting-chaining-existing-nextflow-workflows-in-a-meta-workflow/969 "2024-07-25T11:06:14Z")

</div>

nf-core and the wider Nextflow community have written some amazing workflows. Occasionally, users ask if there’s a way to daisy-chain existing Nextflow workflows together in a single workflow. One way to go about it is t…

---

## [Getting the file baseName depending on the file extension](https://community.seqera.io/t/getting-the-file-basename-depending-on-the-file-extension/622)

<div class="topic-metadata">

**Author:** [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Replies:** 2\
**Last updated:** [April 3, 2024, 11:20am UTC](https://community.seqera.io/t/getting-the-file-basename-depending-on-the-file-extension/622 "2024-04-03T11:20:00Z")

</div>

It’s a common need in scripting is to want to retrieve the base name of a file, i.e. the name of the file without the extension. This is often used, for example, as a prefix to name other files you produce. This can be d…

---

## [Turn on printing of all executed bash commands and disable deleting temp folder in work folder](https://community.seqera.io/t/turn-on-printing-of-all-executed-bash-commands-and-disable-deleting-temp-folder-in-work-folder/549)

<div class="topic-metadata">

**Author:** [@shl](https://community.seqera.io/u/shl)\
**Replies:** 2\
**Last updated:** [March 6, 2024, 6:00pm UTC](https://community.seqera.io/t/turn-on-printing-of-all-executed-bash-commands-and-disable-deleting-temp-folder-in-work-folder/549 "2024-03-06T18:00:28Z")

</div>

Sometimes when a Nextflow task fails in mysterious ways, it can be useful to debug the execution of the bash scripts (.command.run and .command.sh) in the task’s work folder extra carefully. I have found two things that…

---

## [Checking the error output of ignored tasks](https://community.seqera.io/t/checking-the-error-output-of-ignored-tasks/424)

<div class="topic-metadata">

**Author:** [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Replies:** 2\
**Last updated:** [February 10, 2024, 12:39pm UTC](https://community.seqera.io/t/checking-the-error-output-of-ignored-tasks/424 "2024-02-10T12:39:52Z")

</div>

It shouldn’t surprise you that when you set the errorStrategy directive to ignore in some processes, and they fail, their failure will be… ignored :laughing:. But what if you want to check what the error messages were? O…

---

## [Group tuples based on two meta map keys, and sort based on another one](https://community.seqera.io/t/group-tuples-based-on-two-meta-map-keys-and-sort-based-on-another-one/130)

<div class="topic-metadata">

**Author:** [@mribeirodantas](https://community.seqera.io/u/mribeirodantas)\
**Replies:** 0\
**Last updated:** [October 2, 2023, 2:56pm UTC](https://community.seqera.io/t/group-tuples-based-on-two-meta-map-keys-and-sort-based-on-another-one/130 "2023-10-02T14:56:35Z")

</div>

Let’s say you have a channel where every element is a tuple that consists of a meta map and a FASTQ file. This meta map, which is the first item of your tuple, contains multiple key-value pairs, and you want to group t…

---

## [Flexible publishDir in Nextflow Using the Same Process](https://community.seqera.io/t/flexible-publishdir-in-nextflow-using-the-same-process/2686)

<div class="topic-metadata">

**Author:** [@Firas\_Zemzem](https://community.seqera.io/u/Firas_Zemzem)\
**Replies:** 0\
**Last updated:** [May 24, 2026, 12:32pm UTC](https://community.seqera.io/t/flexible-publishdir-in-nextflow-using-the-same-process/2686 "2026-05-24T12:32:34Z")

</div>

One thing I like in Nextflow is how “publishDir” can be made dynamic, avoiding duplicated processes. In my “FASTQC” workflow, I wanted the same process to handle both raw and trimmed reads while publishing outputs to d…

---

## [Handling SLURM Node Evictions in Nextflow: A Simple Retry Strategy](https://community.seqera.io/t/handling-slurm-node-evictions-in-nextflow-a-simple-retry-strategy/2575)

<div class="topic-metadata">

**Author:** [@COASD](https://community.seqera.io/u/COASD)\
**Replies:** 1\
**Last updated:** [May 1, 2026, 11:35pm UTC](https://community.seqera.io/t/handling-slurm-node-evictions-in-nextflow-a-simple-retry-strategy/2575 "2026-05-01T23:35:11Z")

</div>

if, like me, you’re running Nextflow with SLURM on a cluster that experiences node evictions, you probably want a way to automatically rerun jobs when they fail due to eviction. According to the documentation on Spot In…

---

## [Writing multi-line strings from input objects to file in Bash scripts](https://community.seqera.io/t/writing-multi-line-strings-from-input-objects-to-file-in-bash-scripts/2184)

<div class="topic-metadata">

**Author:** [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Replies:** 0\
**Last updated:** [June 12, 2025, 6:55pm UTC](https://community.seqera.io/t/writing-multi-line-strings-from-input-objects-to-file-in-bash-scripts/2184 "2025-06-12T18:55:26Z")

</div>

In native processes ( using exec: ), one can write multi-line strings to a file taking advantage of the task.workDir variable. exec: def nested\_object = \[ letters: \[ 'A', 'B', 'C' \], meta: \[ id: 123, str: 'text'…

---

## [Source another R script in the \`bin/\` directory](https://community.seqera.io/t/source-another-r-script-in-the-bin-directory/1059)

<div class="topic-metadata">

**Author:** [@ChrisHakk](https://community.seqera.io/u/ChrisHakk)\
**Replies:** 2\
**Last updated:** [April 23, 2025, 6:47am UTC](https://community.seqera.io/t/source-another-r-script-in-the-bin-directory/1059 "2025-04-23T06:47:27Z")

</div>

When a process runs, your base directory is the working directory and R files are not within the same folder. Instead, the R files have been added to the PATH variable, which means you can call them but they are not dire…

---

## [How to skip specific/failed samples on next \`-resume\`](https://community.seqera.io/t/how-to-skip-specific-failed-samples-on-next-resume/2078)

<div class="topic-metadata">

**Author:** [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Replies:** 2\
**Last updated:** [April 16, 2025, 7:14am UTC](https://community.seqera.io/t/how-to-skip-specific-failed-samples-on-next-resume/2078 "2025-04-16T07:14:21Z")

</div>

Processes fail for different reasons. Sometimes the input is just not viable, and you want to skip that sample when you -resume. By default, nextflow will try those samples again if the input doesn’t change. This can pot…

---

## [Composing strings based on multiple conditions](https://community.seqera.io/t/composing-strings-based-on-multiple-conditions/1832)

<div class="topic-metadata">

**Author:** [@mahesh.binzerpanchal](https://community.seqera.io/u/mahesh.binzerpanchal)\
**Replies:** 0\
**Last updated:** [February 27, 2025, 8:38am UTC](https://community.seqera.io/t/composing-strings-based-on-multiple-conditions/1832 "2025-02-27T08:38:22Z")

</div>

When composing longer strings based on multiple tests in Nextflow workflows, using the ternary operator or string concatenation can lead to long, hard-to-read lines of code. An alternative approach is to use a list to st…

---

## [Divide-and-conquer strategy to call problematic regions](https://community.seqera.io/t/divide-and-conquer-strategy-to-call-problematic-regions/1730)

<div class="topic-metadata">

**Author:** [@lindenb](https://community.seqera.io/u/lindenb)\
**Replies:** 0\
**Last updated:** [February 11, 2025, 2:48pm UTC](https://community.seqera.io/t/divide-and-conquer-strategy-to-call-problematic-regions/1730 "2025-02-11T14:48:52Z")

</div>

Sometime some regions of the genome are hard to call to get VCF files. The following Nextflow workflow use a divide-and-conquer strategy: if the region is hard to call - that is the process fails (here as an example in C…

---

## [Prevent nextflow from running a process if the output file exists](https://community.seqera.io/t/prevent-nextflow-from-running-a-process-if-the-output-file-exists/1723)

<div class="topic-metadata">

**Author:** [@Firas\_Zemzem](https://community.seqera.io/u/Firas_Zemzem)\
**Replies:** 1\
**Last updated:** [February 8, 2025, 9:12pm UTC](https://community.seqera.io/t/prevent-nextflow-from-running-a-process-if-the-output-file-exists/1723 "2025-02-08T21:12:31Z")

</div>

Imagine you’re working on a project where you need to download many files and store them in a specific directory structure. Before downloading the files, you want to ensure that the target directory exists. If it doesn’t…

---

## [Handling Unordered CSV](https://community.seqera.io/t/handling-unordered-csv/1662)

<div class="topic-metadata">

**Author:** [@Firas\_Zemzem](https://community.seqera.io/u/Firas_Zemzem)\
**Replies:** 0\
**Last updated:** [January 26, 2025, 3:18pm UTC](https://community.seqera.io/t/handling-unordered-csv/1662 "2025-01-26T15:18:52Z")

</div>

Ever been frustrated when your input CSV file isn’t ordered, and you want to use it as it is without manually modifying it? A better way ; you can leverage toSortedList and flatMap operators to process your raw input dir…

---

## [How to set docker sudo in Nextflow for your containers](https://community.seqera.io/t/how-to-set-docker-sudo-in-nextflow-for-your-containers/1278)

<div class="topic-metadata">

**Author:** [@Sasha\_Dagayev](https://community.seqera.io/u/Sasha_Dagayev)\
**Replies:** 1\
**Last updated:** [October 11, 2024, 7:29am UTC](https://community.seqera.io/t/how-to-set-docker-sudo-in-nextflow-for-your-containers/1278 "2024-10-11T07:29:17Z")

</div>

Hi! It took me a bit to figure out how to do this so leaving here for others that may experience the same issue: This is the nextflow.config that makes it work: docker { enabled = true } docker.sudo = true wave.e…

---

## [Minimally Reproducible Conda Set Up For Nextflow](https://community.seqera.io/t/minimally-reproducible-conda-set-up-for-nextflow/1279)

<div class="topic-metadata">

**Author:** [@Sasha\_Dagayev](https://community.seqera.io/u/Sasha_Dagayev)\
**Replies:** 1\
**Last updated:** [October 11, 2024, 7:25am UTC](https://community.seqera.io/t/minimally-reproducible-conda-set-up-for-nextflow/1279 "2024-10-11T07:25:52Z")

</div>

I had a bit of difficulty installing conda via a Dockerfile that would be friendly to Nextflow. Got to these run commands that worked for me: # Install Miniconda RUN curl -O https://repo.anaconda.com/miniconda/Miniconda…

---

## [Adding resourceLabels per project and sampe from a config file](https://community.seqera.io/t/adding-resourcelabels-per-project-and-sampe-from-a-config-file/797)

<div class="topic-metadata">

**Author:** [@johandahlberg](https://community.seqera.io/u/johandahlberg)\
**Replies:** 0\
**Last updated:** [May 30, 2024, 7:45am UTC](https://community.seqera.io/t/adding-resourcelabels-per-project-and-sampe-from-a-config-file/797 "2024-05-30T07:45:14Z")

</div>

This is a potential way to solve the problem: “I want to do cost tracking, e.g., in AWS per sample and project for a pipeline where resourceLabels are not added directly in the module(s).” You can achieve this by adding…

---

## [Escaping strings to prevent unexpected interpolation or code injection](https://community.seqera.io/t/escaping-strings-to-prevent-unexpected-interpolation-or-code-injection/589)

<div class="topic-metadata">

**Author:** [@Xophmeister](https://community.seqera.io/u/Xophmeister)\
**Replies:** 2\
**Last updated:** [March 26, 2024, 11:36am UTC](https://community.seqera.io/t/escaping-strings-to-prevent-unexpected-interpolation-or-code-injection/589 "2024-03-26T11:36:37Z")

</div>

Nextflow does not do anything special with strings when they are interpolated into scripts. This makes it a vector for code injection, in the worst case, or at the least, potentially unexpected output when strings contai…

[Next page](https://community.seqera.io/c/tips-and-tricks/36.md?page=1)
