Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly declare plugins in nextflow.config #315

Merged
merged 9 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions docs/how-to/offline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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 <https://www.nextflow.io/docs/latest/plugins.html#offline-usage>`_:

1. Run the test profile of the calculator with ``nextflow run pgscatalog/pgsc_calc -r test,<docker/singularity/conda>``

.. 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
------------------------

Expand Down
3 changes: 2 additions & 1 deletion lib/WorkflowMain.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}


Expand Down
10 changes: 5 additions & 5 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions modules/local/match_variants.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -42,7 +41,6 @@ process MATCH_VARIANTS {
$match_chrom \
$ambig \
$multi \
$fast \
--outdir \$PWD \
-v

Expand Down
38 changes: 24 additions & 14 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ params {
normalization_method = "empirical mean mean+var"
n_normalization = 4


// compatibility params
liftover = false
target_build = null
Expand All @@ -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
Expand All @@ -68,9 +65,6 @@ params {
only_score = false
skip_ancestry = true

// deprecated params
platform = null

// Boilerplate options
outdir = "$launchDir/results"
publish_dir_mode = 'copy'
Expand All @@ -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
Expand Down Expand Up @@ -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
}
47 changes: 15 additions & 32 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -442,15 +434,6 @@
},
"config_profile_url": {
"type": "string"
},
"validationFailUnrecognisedParams": {
"type": "boolean"
},
"validationLenientMode": {
"type": "boolean"
},
"validationShowHiddenParams": {
"type": "boolean"
}
}
}
19 changes: 5 additions & 14 deletions workflows/pgsc_calc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down