Skip to content

Commit

Permalink
Move parameter validation to nextflow schema
Browse files Browse the repository at this point in the history
  • Loading branch information
grst committed Mar 7, 2024
1 parent 5da7682 commit 070f123
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 95 deletions.
13 changes: 10 additions & 3 deletions assets/schema_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,24 @@
"expected_cells": {
"type": "integer",
"errorMessage": "Expected cells must be an Integer",
"meta": "expected_cells"
"meta": [
"expected_cells"
]
},
"seq_center": {
"type": "string",
"meta": "seq_center"
"meta": [
"seq_center"
]
},
"sample_type": {
"type": "string",
"enum": [
"atac",
"gex"
],
"meta": [
"sample_type"
]
}
},
Expand All @@ -52,4 +59,4 @@
"fastq_2"
]
}
}
}
21 changes: 21 additions & 0 deletions lib/WorkflowScrnaseq.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import groovy.json.JsonSlurper


class WorkflowScrnaseq {
// Retrieve the aligner-specific protocol based on the specified protocol.
// Returns a map ["protocol": protocol, "extra_args": <extra args>, "whitelist": <path to whitelist>]
// extra_args and whitelist are optional.
public static Map getProtocol(workflow, log, aligner, protocol) {
def jsonSlurper = new JsonSlurper()
def json = new File("${workflow.projectDir}/assets/protocols.json").text
def protocols = jsonSlurper.parseText(json)
def aligner_map = protocols[aligner]
if(aligner_map.containsKey(protocol)) {
return aligner_map[protocol]
} else {
log.warn("Protocol '${protocol}' not recognized by the pipeline. Passing on the protocol to the aligner unmodified.")
return ["protocol": protocol]
}
}

}
40 changes: 21 additions & 19 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,27 @@ workflow {
params.input
)

//
// WORKFLOW: Run main workflow
//
NFCORE_SCRNASEQ (
PIPELINE_INITIALISATION.out.samplesheet
)

//
// SUBWORKFLOW: Run completion tasks
//
PIPELINE_COMPLETION (
params.email,
params.email_on_fail,
params.plaintext_email,
params.outdir,
params.monochrome_logs,
params.hook_url,
NFCORE_SCRNASEQ.out.multiqc_report
)
PIPELINE_INITIALISATION.out.samplesheet.view()

// //
// // WORKFLOW: Run main workflow
// //
// NFCORE_SCRNASEQ (
// PIPELINE_INITIALISATION.out.samplesheet.view()
// )

// //
// // SUBWORKFLOW: Run completion tasks
// //
// PIPELINE_COMPLETION (
// params.email,
// params.email_on_fail,
// params.plaintext_email,
// params.outdir,
// params.monochrome_logs,
// params.hook_url,
// NFCORE_SCRNASEQ.out.multiqc_report
// )
}

/*
Expand Down
74 changes: 60 additions & 14 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"type": "object",
"fa_icon": "fas fa-terminal",
"description": "Define where the pipeline should find input data and save output data.",
"required": ["input", "outdir"],
"required": [
"input",
"outdir"
],
"properties": {
"input": {
"type": "string",
Expand Down Expand Up @@ -51,15 +54,24 @@
"barcode_whitelist": {
"type": "string",
"description": "If not using the 10X Genomics platform, a custom barcode whitelist can be used with `--barcode_whitelist`.",
"fa_icon": "fas fa-barcode"
"fa_icon": "fas fa-barcode",
"format": "file-path",
"exists": true
},
"aligner": {
"type": "string",
"description": "Name of the tool to use for scRNA (pseudo-) alignment.",
"default": "alevin",
"help_text": "The workflow can handle three types of methods:\n\n- Kallisto/Bustools\n- Salmon Alevin + AlevinQC\n- STARsolo\n\nTo choose which one to use, please specify either `alevin`, `star` or `kallisto` as a parameter option for `--aligner`. By default, the pipeline runs the `alevin` option. Note that specifying another aligner option also requires choosing appropriate parameters (see below) for the selected option.",
"fa_icon": "fas fa-align-center",
"enum": ["kallisto", "star", "alevin", "cellranger", "cellrangerarc", "universc"]
"enum": [
"kallisto",
"star",
"alevin",
"cellranger",
"cellrangerarc",
"universc"
]
},
"protocol": {
"type": "string",
Expand Down Expand Up @@ -120,12 +132,16 @@
"transcript_fasta": {
"type": "string",
"description": "A cDNA FASTA file",
"fa_icon": "fas fa-dna"
"fa_icon": "fas fa-dna",
"format": "file-path",
"exists": true
},
"gtf": {
"type": "string",
"description": "Reference GTF annotation file",
"fa_icon": "fas fa-code-branch"
"fa_icon": "fas fa-code-branch",
"format": "file-path",
"exists": true
},
"save_reference": {
"type": "boolean",
Expand All @@ -151,13 +167,17 @@
"salmon_index": {
"type": "string",
"description": "This can be used to specify a precomputed Salmon index in the pipeline, in order to skip the generation of required indices by Salmon itself.",
"fa_icon": "fas fa-fish"
"fa_icon": "fas fa-fish",
"format": "file-path",
"exists": true
},
"txp2gene": {
"type": "string",
"description": "Path to transcript to gene mapping file. This allows the specification of a transcript to gene mapping file for Salmon Alevin and AlevinQC.",
"help_text": "> This is not the same as the `kallisto_gene_map` parameter down below and is only used by the Salmon Alevin workflow.",
"fa_icon": "fas fa-map-marked-alt"
"fa_icon": "fas fa-map-marked-alt",
"format": "file-path",
"exists": true
},
"simpleaf_rlen": {
"type": "integer",
Expand All @@ -177,7 +197,9 @@
"type": "string",
"description": "Specify a path to the precomputed STAR index.",
"help_text": "> NB: This has to be computed with STAR Version 2.7 or later, as STARsolo was only first supported by STAR Version 2.7.",
"fa_icon": "fas fa-asterisk"
"fa_icon": "fas fa-asterisk",
"format": "file-path",
"exists": true
},
"star_ignore_sjdbgtf": {
"type": "string",
Expand All @@ -190,7 +212,11 @@
"star_feature": {
"type": "string",
"default": "Gene",
"enum": ["Gene", "GeneFull", "Gene Velocyto"],
"enum": [
"Gene",
"GeneFull",
"Gene Velocyto"
],
"description": "Quantification type of different transcriptomic feature. Use `GeneFull` on pre-mRNA count for single-nucleus RNA-seq reads. Use `Gene Velocyto` to generate RNA velocity matrix.",
"fa_icon": "fas fa-asterisk"
}
Expand All @@ -212,14 +238,22 @@
"kallisto_index": {
"type": "string",
"description": "Specify a path to the precomputed Kallisto index.",
"fa_icon": "fas fa-fish"
"fa_icon": "fas fa-fish",
"format": "file-path",
"exists": true
},
"kb_workflow": {
"type": "string",
"default": "standard",
"description": "Type of workflow. Use `lamanno` for RNA velocity based on La Manno et al. 2018 logic. Use `nucleus` for RNA velocity on single-nucleus RNA-seq reads. Use `kite` for feature barcoding. Use `kite: 10xFB` for 10x Genomics Feature Barcoding technology. (default: standard)",
"fa_icon": "fas fa-fish",
"enum": ["standard", "lamanno", "nucleus", "kite", "kite: 10xFB"]
"enum": [
"standard",
"lamanno",
"nucleus",
"kite",
"kite: 10xFB"
]
}
}
},
Expand All @@ -231,7 +265,9 @@
"properties": {
"cellranger_index": {
"type": "string",
"description": "Specify a pre-calculated cellranger index. Readily prepared indexes can be obtained from the 10x Genomics website. "
"description": "Specify a pre-calculated cellranger index. Readily prepared indexes can be obtained from the 10x Genomics website. ",
"format": "file-path",
"exists": true
}
}
},
Expand Down Expand Up @@ -263,7 +299,9 @@
"properties": {
"universc_index": {
"type": "string",
"description": "Specify a pre-calculated cellranger index. Readily prepared indexes can be obtained from the 10x Genomics website."
"description": "Specify a pre-calculated cellranger index. Readily prepared indexes can be obtained from the 10x Genomics website.",
"format": "file-path",
"exists": true
}
}
},
Expand Down Expand Up @@ -375,7 +413,14 @@
"description": "Method used to save pipeline results to output directory.",
"help_text": "The Nextflow `publishDir` option specifies which intermediate files should be saved to the output directory. This option tells the pipeline what method should be used to move these files. See [Nextflow docs](https://www.nextflow.io/docs/latest/process.html#publishdir) for details.",
"fa_icon": "fas fa-copy",
"enum": ["symlink", "rellink", "link", "copy", "copyNoFollow", "move"],
"enum": [
"symlink",
"rellink",
"link",
"copy",
"copyNoFollow",
"move"
],
"hidden": true
},
"email_on_fail": {
Expand Down Expand Up @@ -417,6 +462,7 @@
"type": "string",
"format": "file-path",
"description": "Custom config file to supply to MultiQC.",
"exists": true,
"fa_icon": "fas fa-cog",
"hidden": true
},
Expand Down
Loading

0 comments on commit 070f123

Please sign in to comment.