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

2.0.0-beta.3 #349

Merged
merged 22 commits into from
Aug 9, 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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: CI
on:
push:
paths-ignore:
- 'docs/**'
branches:
- dev
- main
- ci
pull_request:
paths-ignore:
- 'docs/**'
branches:
- dev
- main
Expand Down
13 changes: 13 additions & 0 deletions assets/examples/scorefiles/PGS001229_22_duplicate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pgs_id=duplicatetest
#pgs_name=duplicatetest
#trait_reported=duplicate test
#genome_build=GRCh37
rsID chr_name chr_position effect_allele other_allele effect_weight is_haplotype imputation_method locus_name variant_description
rs5746679 22 17080378 A G 1.045457e-02 False
rs2192430 22 17300230 A G 1.411475e-04 False
rs165636 22 17318864 A C 8.166266e-03 False
rs165808 22 17327595 T C 7.791641e-03 False
rs5748743 22 17409813 A G 3.108784e-04 False
rs11703655 22 17450952 G A -3.033983e-02 False
rs2192155 22 17492533 G A 3.889990e-03 False
rs2845402 22 17542810 C T 8.036290e-03 False
8 changes: 4 additions & 4 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ process {
ext.conda = "$projectDir/environments/pgscatalog_utils/environment.yml"
ext.docker = 'ghcr.io/pgscatalog/pygscatalog'
ext.singularity = 'oras://ghcr.io/pgscatalog/pygscatalog'
ext.docker_version = ':pgscatalog-utils-1.2.0'
ext.singularity_version = ':pgscatalog-utils-1.2.0-singularity'
ext.docker_version = ':pgscatalog-utils-1.3.1'
ext.singularity_version = ':pgscatalog-utils-1.3.1-singularity'
}

withLabel: plink2 {
Expand Down Expand Up @@ -77,9 +77,9 @@ process {
withLabel: fraposa {
ext.conda = "$projectDir/environments/fraposa/environment.yml"
ext.singularity = 'oras://ghcr.io/pgscatalog/fraposa_pgsc'
ext.singularity_version = ':v1.0.0-singularity'
ext.singularity_version = ':v1.0.2-singularity'
ext.docker = 'ghcr.io/pgscatalog/fraposa_pgsc'
ext.docker_version = ':v1.0.0'
ext.docker_version = ':v1.0.2'
}

// output configuration
Expand Down
2 changes: 1 addition & 1 deletion conf/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ params {

input = "$projectDir/assets/examples/samplesheet.csv"
format = "csv"
scorefile = "$projectDir/assets/examples/scorefiles/PGS001229_22.txt"
scorefile = "$projectDir/assets/examples/scorefiles/PGS001229*.txt"

outdir = "$projectDir/results"
target_build = "GRCh37"
Expand Down
2 changes: 1 addition & 1 deletion environments/fraposa/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ channels:
- bioconda
- nodefaults
dependencies:
- fraposa-pgsc=1.0.0
- fraposa-pgsc=1.0.2
2 changes: 1 addition & 1 deletion environments/pgscatalog_utils/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ channels:
- bioconda
- nodefaults
dependencies:
- pgscatalog-utils=1.2.0
- pgscatalog-utils=1.3.1
8 changes: 8 additions & 0 deletions lib/WorkflowMain.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,13 @@ class WorkflowMain {
if (args[0]) {
log.warn "nf-core pipelines do not accept positional arguments. The positional argument `${args[0]}` has been detected.\n Hint: A common mistake is to provide multiple values to `-profile` separated by spaces. Please use commas to separate profiles instead,e.g., `-profile docker,test`."
}
if (profile.contains("test")) {
def test_warn = """
| INFO: The test profile is used to install the workflow and verify the software is working correctly on your system.
| INFO: Test input data and results are are only useful as examples of outputs, and are not biologically meaningful.
"""
log.info test_warn.stripMargin().stripIndent()
}

}
}
22 changes: 20 additions & 2 deletions modules/local/plink2_score.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ process PLINK2_SCORE {
// labels are defined in conf/modules.config
label 'process_low'
label 'process_long'
label 'error_retry'
label 'plink2' // controls conda, docker, + singularity options

tag "$meta.id chromosome $meta.chrom effect type $scoremeta.effect_type $scoremeta.n"
Expand Down Expand Up @@ -51,7 +50,6 @@ process PLINK2_SCORE {
args2 = [args2, cols, 'list-variants', no_imputation, recessive, dominant, error_on_freq_calc].join(' ')
outmeta = meta + ["n": scoremeta.n, "effect_type": scoremeta.effect_type]
output = "${meta.id}_${meta.chrom}_${scoremeta.effect_type}_${scoremeta.n}"

// speed up the calculation by only considering scoring-file variants for allele frequency calculation (--extract)
if (scoremeta.n_scores.toInteger() == 1)
"""
Expand All @@ -66,6 +64,16 @@ process PLINK2_SCORE {
$input ${geno.baseName} \
--out ${output}

n_missing=\$(comm -3 <(zcat --force $scorefile | tail -n +2 | cut -f 1 | sort) <(sort ${output}.sscore.vars) | wc -l | tr -d ' ')

if [ \$n_missing -gt 0 ]
then
echo "ERROR: \$n_missing variant(s) missing from final calculated score!"
exit 1
else
echo "INFO: Scoring file variants match listed variants in sscore.vars"
fi

cat <<-END_VERSIONS > versions.yml
${task.process.tokenize(':').last()}:
plink2: \$(plink2 --version 2>&1 | sed 's/^PLINK v//; s/ 64.*\$//' )
Expand All @@ -85,6 +93,16 @@ process PLINK2_SCORE {
$input ${geno.baseName} \
--out ${output}

n_missing=\$(comm -3 <(zcat --force $scorefile | tail -n +2 | cut -f 1 | sort) <(sort ${output}.sscore.vars) | wc -l | tr -d ' ')

if [ \$n_missing -gt 0 ]
then
echo "ERROR: \$n_missing variant(s) missing from final calculated score!"
exit 1
else
echo "INFO: Scoring file variants match listed variants in sscore.vars"
fi

cat <<-END_VERSIONS > versions.yml
${task.process.tokenize(':').last()}:
plink2: \$(plink2 --version 2>&1 | sed 's/^PLINK v//; s/ 64.*\$//' )
Expand Down
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ manifest {
description = 'The Polygenic Score Catalog Calculator is a nextflow pipeline for polygenic score calculation'
mainScript = 'main.nf'
nextflowVersion = '>=23.10.0'
version = '2.0.0-beta.2'
version = '2.0.0-beta.3'
}

// Load modules.config for DSL2 module specific options
Expand Down
12 changes: 0 additions & 12 deletions subworkflows/local/ancestry/ancestry_project.nf
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,6 @@ workflow ANCESTRY_PROJECT {
.groupTuple()
.set { ch_projections }

// projections are a mandatory output of the subworkflow
def project_fail = true
FRAPOSA_PROJECT.out.pca.subscribe onNext: { project_fail = false },
onComplete: { projection_error(project_fail) }

emit:
intersection = INTERSECT_VARIANTS.out.intersection
intersect_count = INTERSECT_VARIANTS.out.intersect_count.collect()
Expand All @@ -270,10 +265,3 @@ workflow ANCESTRY_PROJECT {
versions = ch_versions

}

def projection_error(boolean fail) {
if (fail) {
log.error "ERROR: Projection subworkflow failed"
System.exit(1)
}
}
12 changes: 0 additions & 12 deletions subworkflows/local/apply_score.nf
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,11 @@ workflow APPLY_SCORE {
SCORE_AGGREGATE ( ch_scores )
ch_versions = ch_versions.mix(SCORE_AGGREGATE.out.versions)

// aggregated score output from this subworkflow is mandatory
def aggregate_fail = true
SCORE_AGGREGATE.out.scores.subscribe onNext: { aggregate_fail = false },
onComplete: { aggregate_error(aggregate_fail) }

emit:
versions = ch_versions
scores = SCORE_AGGREGATE.out.scores
}

def aggregate_error(boolean fail) {
if (fail) {
log.error "ERROR: No scores calculated!"
System.exit(1)
}
}

def annotate_scorefiles(ArrayList scorefiles) {
// INPUT:
// [[meta], [scorefile_1, ..., scorefile_n]] -> flat list
Expand Down
12 changes: 0 additions & 12 deletions subworkflows/local/match.nf
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,8 @@ workflow MATCH {
MATCH_COMBINE ( ch_match_combine_input )
ch_versions = ch_versions.mix(MATCH_COMBINE.out.versions)

// mandatory output of match subworkflow
def combine_fail = true
MATCH_COMBINE.out.scorefile.subscribe onNext: { combine_fail = false },
onComplete: { combine_error(combine_fail) }

emit:
scorefiles = MATCH_COMBINE.out.scorefile
db = MATCH_COMBINE.out.summary
versions = ch_versions
}

def combine_error(boolean fail) {
if (fail) {
log.error "ERROR: Matching subworkflow failed"
System.exit(1)
}
}
12 changes: 0 additions & 12 deletions subworkflows/local/report.nf
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,10 @@ workflow REPORT {
SCORE_REPORT( ch_report_input, intersect_count, reference_panel_name, report_path )
ch_versions = ch_versions.mix(SCORE_REPORT.out.versions)

// if this workflow runs, the report must be written
report_fail = true
SCORE_REPORT.out.report.subscribe onNext: { report_fail = false },
onComplete: { report_error(report_fail) }

emit:
versions = ch_versions
}

def annotate_sampleset(it) {
[['id': it.getName().tokenize('_')[0]], it]
}

def report_error(boolean fail) {
if (fail) {
log.error "ERROR: No results report written!"
System.exit(1)
}
}
4 changes: 2 additions & 2 deletions tests/modules/match/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
files:
- path: output/test/match/versions.yml
contains:
- "pgscatalog.match: 0.2.3"
- "pgscatalog.match: 0.3.1"
# can't test IPC output (not published)

- name: test match combine module
Expand All @@ -20,7 +20,7 @@
files:
- path: output/test/match/versions.yml
contains:
- "pgscatalog.match: 0.2.3"
- "pgscatalog.match: 0.3.1"
- path: output/test/match/test_ALL_additive_0.scorefile.gz
contains:
- "PGS001229"
Expand Down
6 changes: 6 additions & 0 deletions workflows/pgsc_calc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ if (!run_ancestry_assign && !run_ancestry_adjust) {
run_ancestry_bootstrap = false
}

if (workflow.profile.contains("test")) {
if (params.run_ancestry) {
error "ERROR: The test profile isn't compatible with --run_ancestry. Please use real data."
}
}

/*
========================================================================================
IMPORT LOCAL MODULES/SUBWORKFLOWS
Expand Down