Skip to main content
This tutorial will outline the steps required to launch a Nextflow pipeline on Latch.

Prerequisites

  • Register for an account and log into the Latch Console
  • Install the Latch SDK >= 2.67.5
Example on Ubuntu:
It’s highly recommended to install the Latch SDK in a fresh environment for best behavior.

Step 1: Clone your Nextflow pipeline

We will use nf-core’s rnaseq as an example; however, feel free to follow along with any Nextflow pipeline.

Step 2: Define metadata and workflow graphical interface

The input parameters need to be explicitly defined to construct a graphical interface for a Nextflow pipeline. These parameters will be exposed to scientists in a web interface once the workflow is uploaded to Latch. The Latch SDK provides a command to automatically generate the metadata file from an existing nextflow_schema.json file. When developers change their workflow in the future, they can simply update the nextflow_schema.json file and re-run the generate-metadata command again to update the metadata file.
The command parses parameters defined in the nextflow_schema.json and generates two files:

latch_metadata/generated.py

This file defines workflow parameters and controls how they appear in the UI.
latch_metadata/generated.py
Complex workflows with dozens of parameters can overwhelm scientists when displayed as a simple list. To address this, the file also includes an additional generated_flow parameter that organizes parameters using Section (visible groupings) and Spoiler (collapsible sections) to reduce visual clutter and help users focus on essential parameters while keeping advanced options accessible.

latch_metadata/__init__.py

latch_metadata/__init__.py
This file holds the NextflowMetadata object, which contains relevant fields for the workflow:
  • display_name: The display name of the workflow, as it will appear on the Latch UI.
  • author: Name of the person or organization that publishes the workflow
  • parameters: Input parameters to the workflow, defined as NextflowParameter objects. This will contain a single entry for the WorkflowArgsType dataclass, and should not be modified.
  • runtime_resources: The resources the Nextflow Runtime requires to execute the workflow. The storage_gib field will configure the storage size in GiB for the shared filesystem.
  • log_dir: Latch directory to dump .nextflow.log file on workflow failure.

Overwriting behavior

When re-running the generate-metadata command, the __init__.py file will not be touched and the generated.py file will be overwritten. Any changes should be made to __init__.py so that they can persist across generate-metadata calls.

Step 3: Register the workflow

To register a Nextflow pipeline on Latch, type:
Let’s break down the above command:
  • latch register .: Searches for a Latch workflow in the current directory and registers it to Latch.
  • --nf-script main.nf: Specifies the Nextflow script passed to the Nextflow command at runtime. For this workflow: nextflow run main.nf
  • --nf-execution-profile docker,test: Defines the execution profile to use when running the workflow on Latch. We specify the docker configuration profile to execute processes in a containerized environment.
After running the above command, the Latch SDK will generate two files:
  1. latch.config - a Nextflow configuration file passed to Nextflow via the -config flag.
  2. wf/entrypoint.py - the generated Latch SDK workflow code that executes the Nextflow pipeline.
Once the workflow is registered, click on the link provided in the output of the latch register command. This will take you to an interface like the one below:
As a part of the registration process, we build a docker image which is specified in a Dockerfile. Normally this Dockerfile is autogenerated and stored in .latch, but if there is already a Dockerfile in the workflow directory prior to registering, it will be used to build this image. This can result in errors down the line if the Dockerfile is not generated by Latch.
Nextflow Workflow GUI

Step 4: Execute the workflow

Before executing the workflow, we need to upload test data to Latch. You can find sample test data here. Copy the test data to your Latch workspace by clicking the Copy to Workspace button in the top right corner. Copy to Workspace Now, let’s create the samplesheet in Latch Registry.
  1. Navigate to the Latch Registry and create a new Table. Create Table
  2. Select the table you just created and click “Import CSV”. This will open up the Latch Data filesystem. Import the samplesheet.csv file you copied from the provided test data. Import CSV
Your data is now uploaded to Latch and ready to be processed! Navigate to the Workflows tab in the Latch Console and select the workflow you previously registered. Then, select the appropriate input parameters from the test data you uploaded and click Launch Workflow in the bottom right corner to execute the workflow. Launch Workflow

Step 5: Monitoring the workflow

After launching the workflow, you can monitor progress by clicking on the appropriate execution under the Executions tab of your workflow. Executions Under the Graph & Logs tab, you can view the generated two-stage DAG with the initialization step and the Nextflow runtime task. If you click on the Nextflow runtime node, you can view the runtime logs generated by Nextflow. Graph & Logs Once the Nextflow runtime starts executing the workflow, a Process Nodes tab will appear in the menu bar where you can monitor the status of each process in the workflow. Each node in the DAG represents a process in the Nextflow pipeline.
To more easily navigate the graph, you can filter the process nodes by execution status by clicking the “Filter by Status” button in the top right corner.
Process Nodes Click on a process node to see details of every invocation of that process, including the resources provisioned, execution time, and logs. Process Details Once the workflow is complete, you can view any published outputs in Latch Data. It is convention for Nextflow workflows to use the outdir parameter to prepend publishDir paths. For example, if we set our outdir parameter to latch:///nf-rnaseq/outputs, all pipeline outputs will be published to the nf-rnaseq/outputs directory in Latch Data. Outputs

Step 6 (Optional): Adding Python Tasks for Pre- and Post-Processing

The latch register command generates a Latch workflow that runs your Nextflow pipeline. You can add custom Python tasks that interact with Latch (e.g. modify the workflow execution name on Latch Executions page) without modifying your original Nextflow code. This allows you to extend functionality while keeping your pipeline unchanged. In this tutorial, we will modify the generated wf/entrypoint.py and the latch_metadata/__init__.py files to add a Run Name parameter that will be used to namespace the outputs of the Nextflow pipeline. To do this, add the run_name field to the WorkflowArgsType dataclass in latch_metadata/__init__.py as below:
latch_metadata/__init__.py#
Now, we can update the logic of the nextflow_runtime task to use this new parameter:
We will now re-register the workflow with the above updates. We purposely exclude the --nf-script flag in the latch register command to avoid re-generating the Latch SDK workflow code (which will overwrite our updates).

What You’ve Learned

Core Concepts:
  • Nextflow on Latch allows running containerized pipelines with a graphical web interface.
  • Metadata generation (latch generate-metadata) converts nextflow_schema.json into Python definitions for parameters and UI configuration.
  • Latch Registry integration can replace error-prone CSV inputs with a structured and type-safe Registry UI.
Development Workflow:
  1. Clone your Nextflow pipeline (e.g., nf-core/rnaseq).
  2. Generate metadata from nextflow_schema.json.
  3. Register the pipeline with latch register --nf-script main.nf and required execution profiles.
  4. Upload test data to Latch and select inputs from the Console.
  5. Monitor execution with the Graph & Logs and Process Nodes views.
  6. Customize the generated entrypoint.py for additional pre- or post-processing logic.
  7. Re-register without --nf-script to preserve your code modifications.

Next Steps