Skip to content

Example sample sheet schema

nf-core/rnaseq example

The nf-core/rnaseq pipeline was one of the first to have a sample sheet schema. You can see this, used for validating sample sheets with --input here: assets/schema_input.json.

Tip

Note the approach used for validating filenames in the fastq_2 column. The column is optional, so if a pattern was supplied by itself then validation would fail when no string is supplied.

Instead, we say that the string must either match that pattern or it must have a maxLength of 0 (an empty string).

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/nf-core/rnaseq/master/assets/schema_input.json",
  "title": "nf-core/rnaseq pipeline - params.input schema",
  "description": "Schema for the file provided with params.input",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "sample": {
        "type": "string",
        "pattern": "^\\S+$",
        "errorMessage": "Sample name must be provided and cannot contain spaces",
        "meta": ["my_sample"]
      },
      "fastq_1": {
        "type": "string",
        "pattern": "^\\S+\\.f(ast)?q\\.gz$",
        "format": "file-path",
        "errorMessage": "FastQ file for reads 1 must be provided, cannot contain spaces and must have extension '.fq.gz' or '.fastq.gz'"
      },
      "fastq_2": {
        "errorMessage": "FastQ file for reads 2 cannot contain spaces and must have extension '.fq.gz' or '.fastq.gz'",
        "type": "string",
        "pattern": "^\\S+\\.f(ast)?q\\.gz$",
        "format": "file-path"
      },
      "strandedness": {
        "type": "string",
        "errorMessage": "Strandedness must be provided and be one of 'forward', 'reverse' or 'unstranded'",
        "enum": ["forward", "reverse", "unstranded"],
        "meta": ["my_strandedness"]
      }
    },
    "required": ["sample", "fastq_1", "strandedness"]
  }
}

nf-schema test case

You can see a very feature-complete example JSON Schema for a sample sheet schema file below.

It is used as a test fixture in the nf-schema package here.

Note

More examples can be found in the plugin testResources directory.

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://raw.githubusercontent.com/nextflow-io/nf-schema/master/plugins/nf-schema/src/testResources/schema_input.json",
    "title": "Samplesheet validation schema",
    "description": "Schema for the samplesheet used in this pipeline",
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "field_1": {
                "type": "string",
                "meta": ["string1","string2"],
                "default": "value"
            },
            "field_2": {
                "type": "integer",
                "meta": ["integer1","integer2"],
                "default": 0
            },
            "field_3": {
                "type": "boolean",
                "meta": ["boolean1","boolean2"],
                "default": true
            },
            "field_4": {
                "type": "string"
            },
            "field_5": {
                "type": "number"
            },
            "field_6": {
                "type": "boolean"
            },
            "field_7": {
                "type": "string",
                "format": "file-path",
                "exists": true,
                "pattern": "^.*\\.txt$"
            },
            "field_8": {
                "type": "string",
                "format": "directory-path",
                "exists": true
            },
            "field_9": {
                "type": "string",
                "format": "path",
                "exists": true
            },
            "field_10": {
                "type": "string"
            },
            "field_11": {
                "type": "integer"
            },
            "field_12": {
                "type": "string",
                "default": "itDoesExist"
            }
        },
        "required": ["field_4", "field_6"],
        "dependentRequired": {
            "field_1": ["field_2", "field_3"]
        }
    },
    "allOf": [
        {"uniqueEntries": ["field_11", "field_10"]},
        {"uniqueEntries": ["field_10"]}
    ]
}