Introduction

An nf-core module is an opinionated open-source Nextflow ‘wrapper’ around a command-line tool command or script. A collection of these modules are stored in a central community repository of more than 1000 modules that can be used by anyone in their own pipelines.

This chapter describes what an nf-core module is, and what makes them different from a ‘standard’ Nextflow process.

Contents of an nf-core module

For each ‘wrapper’, nf-core modules usually follow the rule of one tool command, or one tool with a single subcommand, per wrapper.

Comparison with Nextflow modules

A Nextflow process or module has no restrictions on the the number of tools or subcommands it can execute.

An nf-core module strictly aims to have a single ‘analysis’ command per module for simplicity and lego-block like construction of pipelines. While this atomic nature is not always the most resource efficient, it makes modules easier to understand, share, and test.

Each nf-core module consists of a set of files where the structure and contents of each follow strict specifications. These specifications are designed based on the consensus opinions of the wider nf-core community and span multiple areas, such as:

  • Naming and formatting conventions
  • What software environment to use
  • Use of standardised tags
  • What input and output channels are used
  • How to allow pipeline developers to use specific tool parameters
  • Use of ‘meta maps’
  • Use of stubs

and many more.

Furthermore, the nf-core specifications also expands the number files from just a single Nextflow .nf script file to a minimum of 5 required files. This is due to the nf-core initiative’s focus on standardisation, reproducibility, and high quality documentation.

For example, a ‘complete’ nf-core/module directory can consist up to the following 6 files:

├── environment.yml
├── main.nf
├── meta.yml
└── tests/
    ├── main.nf.test
    ├── main.nf.test.snap
    └── nextflow.config ## optional!

These can be split up into three main categories:

  • Module execution
  • Module documentation
  • Module testing

The relationship between these files is shown in the following diagram:

Diagram of three main categories of files in an nf-core module. The central 'execution' box includes two files icons, one called main.nf and an arrow pointing into it from a second file icon called 'environment.yml'. In the left 'Documentation' box an arrow points from the previous main.nf to a file in this section called 'meta.yaml'. On the right 'Testing' box, there are three file icons, an icon called 'main.nf.test' with an arrow coming from the execution section's main.nf, an arrow pointing into the main.nf.test icon from another file icon called 'nextflow.config', and an arrow pointing to a final file icon from the 'main.nf.test' to the final icon 'main.nf.test.snap'.

Diagram showing the relationship between the three main categories of files in an nf-core module

  • The main.nf file is the main Nextflow script that defines the process executed by Nextflow itself
  • The environment.yml file is a Conda environment file that is loaded by the main.nf specifies the software dependencies for the module when a pipeline run is executed with -profile conda
  • The meta.yaml file documents the contents of the main.nf, such as tool metadata, input and output specifications etc.
  • The main.nf.test describes an nf-test unit test for the main.nf process.
  • The main.nf.test.snap is a snapshot file that is generated by nf-test test and is used to compare the output of one test run with another, to ensure that the process is reproducible.
  • The nextflow.config file is a Nextflow configuration file that is used by the test executed when main.nf.test is run (optional)

Writing an nf-core module involves creating and populating these files with content that follows the nf-core specifications.

Summary

In this chapter we’ve briefly introduced what distinguishes an nf-core module versus a typical Nextflow process, and given an overview of what a typical nf-core module looks like.

In the next chapter we will explain how to use nf-core tooling to generate partially completed boilerplate template files you can use to speed up the development of your nf-core module.