diff --git a/docs/how-to/offline.rst b/docs/how-to/offline.rst index 3fb78e25..a77bf118 100644 --- a/docs/how-to/offline.rst +++ b/docs/how-to/offline.rst @@ -7,9 +7,10 @@ pgsc_calc has been deployed on secure platforms like Trusted Research Environments (TREs). Running pgsc_calc is a little bit more difficult in this case. The basic set up approach is to: -1. Download containers -2. Download reference data -3. Download scoring files +1. Set up Nextflow +2. Download containers +3. Download reference data +4. Download scoring files And transfer everything to your offline environment. @@ -22,6 +23,41 @@ if you are having problems and we'll try our best to help you. .. _open a discussion on Github: https://github.com/PGScatalog/pgsc_calc/discussions +Set up Nextflow +---------------- + +From the Nextflow documentation for `offline usage `_: + +1. Run the test profile of the calculator with ``nextflow run pgscatalog/pgsc_calc -r test,`` + +.. tip:: + + It doesn't matter if the profile you use on your computer with internet access is different to the profile you use in the airlocked environment. + + The important thing is that Nextflow automatically configures itself using an internet connection. + +2. Transfer the Nextflow binary and ``$NXF_HOME/.nextflow`` directory to your airlocked environment + +.. tip:: + + ``$NXF_HOME`` is ``$HOME`` by default, so the directory is probably ``~/.nextflow`` + +.. warning:: + + Make sure to transfer the Nextflow binary even if the airlocked environment already has Nextflow installed. It's important that the Nextflow versions match across both environments. + +3. Remember to always set the environment variable ``NXF_OFFLINE='true'`` in the offline environment + + +.. tip:: + + You shouldn't need to: + + 1. Edit any Nextflow configuration files + 2. Manually download any plugins + + Unless you want to use a special plugin in the airlocked environment + Preload container images ------------------------ diff --git a/lib/WorkflowMain.groovy b/lib/WorkflowMain.groovy index 238741a6..f11034e7 100755 --- a/lib/WorkflowMain.groovy +++ b/lib/WorkflowMain.groovy @@ -12,11 +12,12 @@ class WorkflowMain { public static String citation(workflow) { return "If you use ${workflow.manifest.name} for your analysis please cite:\n\n" + "* The Polygenic Score Catalog\n" + + " https://doi.org/10.1101/2024.05.29.24307783\n" + " https://doi.org/10.1038/s41588-021-00783-5\n\n" + "* The nf-core framework\n" + " https://doi.org/10.1038/s41587-020-0439-x\n\n" + "* Software dependencies\n" + - " https://github.com/${workflow.manifest.name}/blob/master/CITATIONS.md" + " https://github.com/${workflow.manifest.name}/blob/main/CITATIONS.md" } diff --git a/main.nf b/main.nf index efea0127..5d07765a 100644 --- a/main.nf +++ b/main.nf @@ -15,13 +15,13 @@ nextflow.enable.dsl = 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +include { paramsHelp } from 'plugin/nf-schema' + // Print help message if needed if (params.help) { - def logo = NfcoreTemplate.logo(workflow, params.monochrome_logs) - def citation = '\n' + WorkflowMain.citation(workflow) + '\n' - def String command = '\n' + "\$ nextflow run ${workflow.manifest.name} -profile test,docker" + '\n' - log.info logo + command + citation + NfcoreTemplate.dashedLine(params.monochrome_logs) - System.exit(0) + log.info paramsHelp("nextflow run pgscatalog/pgsc_calc --input input_file.csv") + log.info "See https://pgsc-calc.readthedocs.io/en/latest/getting-started.html for more help" + exit 0 } WorkflowMain.initialise(workflow, params, log, args) diff --git a/modules/local/match_variants.nf b/modules/local/match_variants.nf index cc094449..0e5d8098 100644 --- a/modules/local/match_variants.nf +++ b/modules/local/match_variants.nf @@ -23,7 +23,6 @@ process MATCH_VARIANTS { script: def args = task.ext.args ?: '' - def fast = params.fast_match ? '--fast' : '' def ambig = params.keep_ambiguous ? '--keep_ambiguous' : '' def multi = params.keep_multiallelic ? '--keep_multiallelic' : '' def match_chrom = meta.chrom.contains("ALL") ? '' : "--chrom $meta.chrom" @@ -42,7 +41,6 @@ process MATCH_VARIANTS { $match_chrom \ $ambig \ $multi \ - $fast \ --outdir \$PWD \ -v diff --git a/nextflow.config b/nextflow.config index a87556a9..67fc935a 100644 --- a/nextflow.config +++ b/nextflow.config @@ -44,7 +44,6 @@ params { normalization_method = "empirical mean mean+var" n_normalization = 4 - // compatibility params liftover = false target_build = null @@ -54,11 +53,9 @@ params { min_overlap = 0.75 keep_ambiguous = false keep_multiallelic = false - fast_match = false copy_genomes = false genotypes_cache = null - // Debug params only_bootstrap = false only_input = false @@ -68,9 +65,6 @@ params { only_score = false skip_ancestry = true - // deprecated params - platform = null - // Boilerplate options outdir = "$launchDir/results" publish_dir_mode = 'copy' @@ -96,14 +90,6 @@ params { max_memory = '128.GB' max_cpus = 16 max_time = '240.h' - - // Schema validation default options - validationFailUnrecognisedParams = false - validationLenientMode = false - validationSchemaIgnoreParams = 'genomes,igenomes_base,platform,only_bootstrap,only_input,only_compatible,only_match,only_score' - validationShowHiddenParams = false - validate_params = true - } // Load base.config by default for all pipelines @@ -308,3 +294,27 @@ def check_max(obj, type) { } } } + +plugins { + id 'nf-schema@2.0.0' // validation of parameters + id 'nf-prov@1.2.2' +} + + prov { + enabled = true + formats { + bco { + file = "${params.outdir}/pipeline_info/manifest_${trace_timestamp}.bco.json" + } + } +} + +validation { + // Schema validation default options + monochromeLogs = params.monochrome_logs + failUnrecognisedParams = false + lenientMode = false + defaultIgnoreParams = ['platform'] + ignoreParams = ['genomes','igenomes_base',',only_bootstrap','only_input','only_compatible','only_match','only_score'] + showHiddenParams = false +} \ No newline at end of file diff --git a/nextflow_schema.json b/nextflow_schema.json index bd5456dd..6caed387 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -1,10 +1,10 @@ { - "$schema": "http://json-schema.org/draft-07/schema", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://raw.githubusercontent.com/pgscatalog/pgsc_calc/master/nextflow_schema.json", "title": "pgscatalog/pgsc_calc pipeline parameters", "description": "This pipeline applies scoring files from the PGS Catalog to target set(s) of genotyped samples", "type": "object", - "definitions": { + "defs": { "input_output_options": { "title": "Input/output options", "type": "object", @@ -31,11 +31,13 @@ }, "pgs_id": { "type": "string", - "description": "A comma separated list of PGS score IDs, e.g. PGS000802" + "description": "A comma separated list of PGS score IDs, e.g. PGS000802", + "pattern": "PGS[0-9]{6}" }, "pgp_id": { "type": "string", - "description": "A comma separated list of PGS Catalog publications, e.g. PGP000001" + "description": "A comma separated list of PGS Catalog publications, e.g. PGP000001", + "pattern": "PGP[0-9]{6}" }, "trait_efo": { "type": "string", @@ -58,7 +60,8 @@ "type": "string", "description": "Path to the output directory where the results will be saved.", "fa_icon": "fas fa-folder-open", - "format": "directory-path" + "format": "directory-path", + "default": "results" }, "email": { "type": "string", @@ -255,10 +258,6 @@ "type": "boolean", "description": "Keep matches of scoring file variants to strand ambiguous variants (e.g. A/T and C/G SNPs) in the target dataset. This assumes the scoring file and target dataset report variants on the same strand." }, - "fast_match": { - "type": "boolean", - "description": "Enable fast matching, which significantly increases RAM usage (32GB minimum recommended)" - }, "min_overlap": { "type": "number", "default": 0.75, @@ -353,38 +352,31 @@ "description": "Do not use coloured log outputs.", "fa_icon": "fas fa-palette", "hidden": true - }, - "validate_params": { - "type": "boolean", - "description": "Boolean whether to validate parameters against the schema at runtime", - "default": true, - "fa_icon": "fas fa-check-square", - "hidden": true } } } }, "allOf": [ { - "$ref": "#/definitions/input_output_options" + "$ref": "#/defs/input_output_options" }, { - "$ref": "#/definitions/ancestry_options" + "$ref": "#/defs/ancestry_options" }, { - "$ref": "#/definitions/reference_options" + "$ref": "#/defs/reference_options" }, { - "$ref": "#/definitions/compatibility_options" + "$ref": "#/defs/compatibility_options" }, { - "$ref": "#/definitions/matching_options" + "$ref": "#/defs/matching_options" }, { - "$ref": "#/definitions/max_job_request_options" + "$ref": "#/defs/max_job_request_options" }, { - "$ref": "#/definitions/generic_options" + "$ref": "#/defs/generic_options" } ], "properties": { @@ -442,15 +434,6 @@ }, "config_profile_url": { "type": "string" - }, - "validationFailUnrecognisedParams": { - "type": "boolean" - }, - "validationLenientMode": { - "type": "boolean" - }, - "validationShowHiddenParams": { - "type": "boolean" } } } diff --git a/workflows/pgsc_calc.nf b/workflows/pgsc_calc.nf index 9d85f2e0..c921b10c 100644 --- a/workflows/pgsc_calc.nf +++ b/workflows/pgsc_calc.nf @@ -4,7 +4,8 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -include { paramsSummaryLog; paramsSummaryMap } from 'plugin/nf-validation' +include { validateParameters; paramsSummaryLog; paramsSummaryMap } from 'plugin/nf-schema' + def logo = NfcoreTemplate.logo(workflow, params.monochrome_logs) def citation = '\n' + WorkflowMain.citation(workflow) + '\n' @@ -15,6 +16,9 @@ log.info logo + paramsSummaryLog(workflow) + citation WorkflowPgscCalc.initialise(params, log) +// new approach to validating parameters +validateParameters() + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEBUG OPTIONS TO HALT WORKFLOW EXECUTION @@ -123,19 +127,6 @@ include { APPLY_SCORE } from '../subworkflows/local/apply_score' include { REPORT } from '../subworkflows/local/report' include { DUMPSOFTWAREVERSIONS } from '../modules/local/dumpsoftwareversions' - -/* -======================================================================================== - DEPRECATION WARNINGS -======================================================================================== -*/ - -if (params.platform) { - System.err.println "--platform has been deprecated to match nf-core framework" - System.err.println "Please use -profile docker,arm instead" - System.exit(1) -} - /* ======================================================================================== RUN MAIN WORKFLOW