Skip to content

nf-schema

A Nextflow plugin to work with validation of pipeline parameters and sample sheets.

Info

nf-schema is the new version of the now deprecated nf-validation. Please follow the migration guide to migrate your code to this new version.

Introduction

This Nextflow plugin provides a number of functions that can be included into a Nextflow pipeline script to work with parameter and sample sheet schema. Using these functions you can:

  • ๐Ÿ“– Print usage instructions to the terminal (for use with --help)
  • โœ๏ธ Print log output showing parameters with non-default values
  • โœ… Validate supplied parameters against the pipeline schema
  • ๐Ÿ“‹ Validate the contents of supplied sample sheet files
  • ๐Ÿ› ๏ธ Create a Nextflow channel with a parsed sample sheet

Supported sample sheet formats are CSV, TSV, JSON and YAML.

Quick Start

Declare the plugin in your Nextflow pipeline configuration file:

nextflow.config
plugins {
  id 'nf-schema@2.0.0'
}

This is all that is needed - Nextflow will automatically fetch the plugin code at run time.

[!NOTE] The snippet above will always try to install the latest version, good to make sure that the latest bug fixes are included! However, this can cause difficulties if running offline. You can pin a specific release using the syntax nf-schema@2.0.0

You can now include the plugin helper functions into your Nextflow pipeline:

main.nf
include { validateParameters; paramsHelp; paramsSummaryLog; samplesheetToList } from 'plugin/nf-schema'

// Print help message, supply typical command line usage for the pipeline
if (params.help) {
   log.info paramsHelp("nextflow run my_pipeline --input input_file.csv")
   exit 0
}

// Validate input parameters
validateParameters()

// Print summary of supplied parameters
log.info paramsSummaryLog(workflow)

// Create a new channel of metadata from a sample sheet passed to the pipeline through the --input parameter
ch_input = Channel.fromList(samplesheetToList(params.input, "assets/schema_input.json"))

Dependencies

Slack channel

There is a dedicated nf-schema Slack channel in the Nextflow Slack workspace.

Credits

This plugin was written based on code initially written within the nf-core community, as part of the nf-core pipeline template.

We would like to thank the key contributors who include (but are not limited to):