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": "http://json-schema.org/draft-07/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'",
        "anyOf": [
          {
            "type": "string",
            "pattern": "^\\S+\\.f(ast)?q\\.gz$",
            "format": "file-path"
          },
          {
            "type": "string",
            "maxLength": 0
          }
        ]
      },
      "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-validation 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-validation package here.

Note

More examples can be found in the plugin testResources directory.

{
    "$schema": "http://json-schema.org/draft-07/schema",
    "$id": "https://raw.githubusercontent.com/nextflow-io/nf-validation/master/plugins/nf-validation/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",
                "dependentRequired": ["field_2", "field_3"]
            },
            "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",
                "unique": true
            },
            "field_11": {
                "type": "integer",
                "unique": ["field_10"]
            },
            "field_12": {
                "type": "string",
                "default": "itDoesExist"
            }
        },
        "required": ["field_4", "field_6"]
    }
}