Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions docs/your-first-script.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This guide details fundamental skills to run a basic Nextflow pipeline. It inclu

You will need the following to get started:

- Nextflow: See {ref}`install-page` for installation instructions.
- Nextflow version 25.10 or later. See {ref}`install-page` for installation instructions. If you have an older version, see {ref}`updating-nextflow` to update.

## Run a pipeline

Expand All @@ -25,11 +25,9 @@ params.str = "Hello world!"

// split process
process split {
publishDir "results/lower"

input:
val x

output:
path 'chunk_*'

Expand All @@ -41,7 +39,6 @@ process split {

// convert_to_upper process
process convert_to_upper {
publishDir "results/upper"
tag "$y"

input:
Expand All @@ -58,9 +55,23 @@ process convert_to_upper {

// Workflow block
workflow {
ch_str = channel.of(params.str) // Create a channel using parameter input
ch_chunks = split(ch_str) // Split string into chunks and create a named channel
convert_to_upper(ch_chunks.flatten()) // Convert lowercase letters to uppercase letters
main:
ch_str = channel.of(params.str) // Create a channel using parameter input
ch_chunks = split(ch_str) // Split string into chunks and create a named channel
ch_upper = convert_to_upper(ch_chunks.flatten()) // Convert lowercase letters to uppercase letters

publish:
lower = ch_chunks.flatten()
upper = ch_upper
}

output {
lower {
path 'lower'
}
upper {
path 'upper'
}
}
```

Expand All @@ -71,7 +82,12 @@ This script defines two processes:

The `split` output is emitted as a single element. The `flatten` operator splits this combined element so that each file is treated as a sole element.

The outputs from both processes are published in subdirectories (`lower` and `upper`) in the `results` directory.
The workflow block is organized into two sections:

- `main:`: defines the workflow logic and how processes are connected via channels
- `publish:`: declares which channels should be published as workflow outputs

The `output` block (outside the workflow) defines where and how each output should be published. In this example, the outputs from both processes are published in subdirectories (`lower` and `upper`) in the default `results` out directory.

To run your pipeline:

Expand All @@ -87,7 +103,7 @@ To run your pipeline:
You will see output similar to the following:

```console
N E X T F L O W ~ version 24.10.3
N E X T F L O W ~ version 25.10.0

Launching `main.nf` [big_wegener] DSL2 - revision: 13a41a8946

Expand All @@ -98,6 +114,15 @@ executor > local (3)

Nextflow creates a `work` directory to store files used during a pipeline run. Each execution of a process is run as a separate task. The `split` process is run as one task and the `convert_to_upper` process is run as two tasks. The hexadecimal string, for example, `82/457482`, is the beginning of a unique hash. It is a prefix used to identify the task directory where the script was executed.

When the pipeline completes, you can view the output files in the `results` directory:

```{code-block} bash
:class: copyable
ls -R results/
```

You will see the published output files organized in the `lower` and `upper` subdirectories.

:::{tip}
Run your pipeline with `-ansi-log false` to see each task printed on a separate line:

Expand All @@ -109,7 +134,7 @@ nextflow run main.nf -ansi-log false
You will see output similar to the following:

```console
N E X T F L O W ~ version 24.10.3
N E X T F L O W ~ version 25.10.0
Launching `main.nf` [peaceful_watson] DSL2 - revision: 13a41a8946
[43/f1f8b5] Submitted process > split (1)
[a2/5aa4b1] Submitted process > convert_to_upper (chunk_ab)
Expand All @@ -132,7 +157,6 @@ You can enable resumability using the `-resume` flag when running a pipeline. To
```{code-block} groovy
:class: copyable
process convert_to_upper {
publishDir "results/upper"
tag "$y"

input:
Expand All @@ -159,7 +183,7 @@ You can enable resumability using the `-resume` flag when running a pipeline. To
You will see output similar to the following:

```console
N E X T F L O W ~ version 24.10.3
N E X T F L O W ~ version 25.10.0

Launching `main.nf` [furious_curie] DSL2 - revision: 5490f13c43

Expand Down Expand Up @@ -190,7 +214,7 @@ You can configure the `str` parameter in your pipeline. To modify your `str` par
You will see output similar to the following:

```console
N E X T F L O W ~ version 24.10.3
N E X T F L O W ~ version 25.10.0

Launching `main.nf` [distracted_kalam] DSL2 - revision: 082867d4d6

Expand Down
Loading