Link Search Menu Expand Document

Variables in nextflow.config

CLI arguments and options for specific components/steps in the pipeline are configured in the respective nextflow.config files that are imported in the global one. But that also means that we can not override them from the CLI anymore. For instance, it is not possible to add an argument in the style --component.input.value <value>. That means that all options would either be fixed for the whole pipeline, or to be configured in nextflow.config explicitly. The latter is possible by means of a custom config file that overrides the other settings.

There is, however, an easier approach to this: variables in nextflow.config. The functionality is explained here and is used in DiFlow for allowing us to provide the (scoped) parameter values on the CLI. For instance, this is an excerpt from an existing component’s nextflow.config:

params {
  ...
  cellranger_vdj__id = "cr"
  ...
  cellranger_vdj {
    name = "cellranger_vdj"
    container = "mapping/cellranger_vdj/cellranger_vdj:4.0.0-1"
    command = "cellranger_vdj"
    arguments {
      ...
      id {
        name = "id"
        otype = "--"
        value = "${params.cellranger_vdj__id}"
        ...
      }
      ...

If you look at this one parameter for the cellranger_vdj component, you notice that directly under params, we have the key cellranger_vdj__id. In other words, the component name followed by a double underscore and then the parameter name. Since all arguments are named here, we do not have to have to specify -’s or --’s.