Skip to content

Commit

Permalink
Merge pull request #13 from EBI-Metagenomics/feature/multiqc-per-stud…
Browse files Browse the repository at this point in the history
…y-and-run

MultiQC reports per run set and per study
  • Loading branch information
mberacochea authored Jul 11, 2024
2 parents 3b57035 + a8a5131 commit aafd6bf
Show file tree
Hide file tree
Showing 19 changed files with 236 additions and 130 deletions.
40 changes: 33 additions & 7 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,22 @@ process {
cpus = { check_max( 2 * task.attempt, 'cpus' ) }
memory = { check_max( 12.GB * task.attempt, 'memory' ) }
time = { check_max( 4.h * task.attempt, 'time' ) }

ext.args = "--invert-match"
}

// Dummy process to published the filtered and decontaminated contigs
withName: 'PUBLISH_CLEANED_CONTIGS' {
cpus = { check_max( 1 , 'cpus' ) }
memory = { check_max( 250.MB * task.attempt , 'memory' ) }
time = { check_max( 30.m * task.attempt, 'time' ) }
publishDir = [
[
path: "${params.outdir}",
mode: params.publish_dir_mode,
failOnError: true,
saveAs: {
filename -> {
if ( filename.equals('versions.yml') ) {
return null;
}
def output_file = new File(filename);
return "${study_reads_folder( meta )}/assembly/${meta.assembler}/${meta.assembler_version}/${output_file.simpleName}_filtered_contigs.${output_file.extension}";
return "${study_reads_folder( meta )}/assembly/${meta.assembler}/${meta.assembler_version}/${filename}";
}
}
]
Expand Down Expand Up @@ -288,7 +289,32 @@ process {
]
}

withName: 'MULTIQC' {
withName: 'MULTIQC_STUDY' {
cpus = { check_max( 1 , 'cpus' ) }
memory = { check_max( 6.GB * task.attempt, 'memory' ) }
time = { check_max( 4.h * task.attempt, 'time' ) }

ext.args = { params.multiqc_title ? "--title \"$params.multiqc_title\"" : '' }

publishDir = [
[
path: "${params.outdir}",
mode: params.publish_dir_mode,
failOnError: true,
saveAs: {
filename -> {
if ( filename.equals('versions.yml') ) {
return null;
}
def output_file = new File(filename);
return "${study_folder( meta )}/multiqc/${output_file.name}";
}
}
]
]
}

withName: 'MULTIQC_RUN' {
cpus = { check_max( 1 , 'cpus' ) }
memory = { check_max( 6.GB * task.attempt, 'memory' ) }
time = { check_max( 4.h * task.attempt, 'time' ) }
Expand Down
2 changes: 1 addition & 1 deletion modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"custom/dumpsoftwareversions": {
"branch": "master",
"git_sha": "bba7e362e4afead70653f84d8700588ea28d0f9e",
"git_sha": "82024cf6325d2ee194e7f056d841ecad2f6856e9",
"installed_by": ["modules"]
},
"fastp": {
Expand Down
2 changes: 1 addition & 1 deletion modules/local/fetchtool_reads.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ process FETCHTOOL_READS {

label 'process_single'

container "microbiome-informatics/fetch-tool:v0.9.0"
container "quay.io/microbiome-informatics/fetch-tool:v1.0.0rc"

input:
tuple val(meta), val(study_accession), val(reads_accession)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions modules/nf-core/custom/dumpsoftwareversions/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 28 additions & 22 deletions modules/nf-core/custom/dumpsoftwareversions/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion modules/nf-core/multiqc/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,23 @@ includeConfig 'conf/modules.config'

// Function to return study / reads folder SRPXXX/SRPXXXXXX/SRRYYYY/SRRYYYYYY
def study_reads_folder( meta = null ) {
def study_accession = meta?.study_accession ?: params.study_accession
// The reads accession is used as the id for samplesheets
def reads_accession = meta?.id ?: params.reads_accession

return [
study_accession.substring(0, 7),
study_accession,
return study_folder( meta ) + "/" + [
reads_accession.substring(0, 7),
reads_accession,
].join("/")
}

// Function to return study folder SRPXXX/SRPXXXXXX
def study_folder( meta = null ) {
def study_accession = meta?.study_accession ?: params.study_accession
return [
study_accession.substring(0, 7),
study_accession,
].join("/")
}

// Function to ensure that resource requirements don't go beyond
// a maximum limit
Expand Down
18 changes: 18 additions & 0 deletions subworkflows/local/assembly_qc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ include { SEQKIT_GREP as SEQKIT_GREP_HUMAN_PHIX } from '../../modules/nf-core/
include { SEQKIT_GREP as SEQKIT_GREP_HOST } from '../../modules/nf-core/seqkit/grep/main'
include { SEQKIT_SEQ } from '../../modules/nf-core/seqkit/seq/main'

process PUBLISH_CLEANED_CONTIGS {

input:
tuple val(meta), path(cleaned_contigs)

output:
tuple val(meta), path("${meta.id}_cleaned.contigs.fa.gz")

script:
"""
cp ${cleaned_contigs} ${meta.id}_cleaned.contigs.fa.gz
"""
}

workflow ASSEMBLY_QC {

take:
Expand Down Expand Up @@ -69,6 +83,10 @@ workflow ASSEMBLY_QC {
ch_versions = ch_versions.mix(SEQKIT_GREP_HOST.out.versions)
}

PUBLISH_CLEANED_CONTIGS(
filtered_contigs
)

emit:
filtered_contigs = filtered_contigs
versions = ch_versions
Expand Down
49 changes: 25 additions & 24 deletions tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@ nextflow_pipeline {
name "Test Workflow EBIMETAGENOMICS_MIASSEMBLER"
script "main.nf"

test("Samplesheet spades") {

when {
params {
outdir = "tests/results"
assembler = "spades"
bwamem2_reference_genomes_folder = "${projectDir}/tests/human_phix/bwa2mem"
blast_reference_genomes_folder = "${projectDir}/tests/human_phix/blast"
samplesheet = "${projectDir}/tests/samplesheet/test.csv"
}
}

then {
with(workflow) {
assert success
assert trace.succeeded().count{ task -> task.name.contains("SPADES") } == 1
assert trace.succeeded().count{ task -> task.name.contains("MEGAHIT") } == 1
}
}

}
// TODO: re-enable after the tests reads are on the repo
// test("Samplesheet spades") {

// when {
// params {
// outdir = "tests/results"
// assembler = "spades"
// bwamem2_reference_genomes_folder = "${projectDir}/tests/human_phix/bwa2mem"
// blast_reference_genomes_folder = "${projectDir}/tests/human_phix/blast"
// samplesheet = "${projectDir}/tests/samplesheet/test.csv"
// }
// }

// then {
// with(workflow) {
// assert success
// assert trace.succeeded().count{ task -> task.name.contains("SPADES") } == 1
// assert trace.succeeded().count{ task -> task.name.contains("MEGAHIT") } == 1
// }
// }

// }

test("metaSPAdes - paired end") {

Expand All @@ -43,7 +44,7 @@ nextflow_pipeline {
assert success
assert trace.succeeded().count{ task -> task.name.contains("SPADES") } == 1
assert trace.succeeded().count{ task -> task.name.contains("MEGAHIT") } == 0
assert trace.succeeded().size() == 16
assert trace.succeeded().size() == 18
}
}

Expand All @@ -67,7 +68,7 @@ nextflow_pipeline {
assert success
assert trace.succeeded().count{ task -> task.name.contains("SPADES") } == 0
assert trace.succeeded().count{ task -> task.name.contains("MEGAHIT") } == 1
assert trace.tasks().size() == 16
assert trace.tasks().size() == 18
}
}

Expand Down Expand Up @@ -133,7 +134,7 @@ nextflow_pipeline {
assert success
assert trace.succeeded().count{ task -> task.name.contains("SPADES") } == 0
assert trace.succeeded().count{ task -> task.name.contains("MEGAHIT") } == 1
assert trace.tasks().size() == 16
assert trace.tasks().size() == 18
}
}

Expand Down
7 changes: 4 additions & 3 deletions tests/samplesheet/test.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
study_accession,reads_accession,fastq_1,fastq_2,library_layout,library_strategy,assembler
SRP115494,SRR6180434,ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR618/004/SRR6180434/SRR6180434_1.fastq.gz,ftp://ftp.sra.ebi.ac.uk/vol1/fastq/SRR618/004/SRR6180434/SRR6180434_2.fastq.gz,paired,metagenomic
DRP007622,DRR280712,ftp://ftp.sra.ebi.ac.uk/vol1/fastq/DRR280/DRR280712/DRR280712.fastq.gz,,single,metatranscriptomic,megahit
study_accession,reads_accession,fastq_1,fastq_2,library_layout,library_strategy,assembler,assembly_memory
SRP115494,SRR6180434,tests/test_reads/SRR6180434_1.fastq.gz,tests/test_reads/SRR6180434_2.fastq.gz,paired,metagenomic,,
SRP115494,SRR5949318,tests/test_reads/SRR5949318_1.fastq.gz,tests/test_reads/SRR5949318_2.fastq.gz,paired,metagenomic,,
DRP007622,DRR280712,tests/test_reads/DRR280712.fastq.gz,,single,metatranscriptomic,megahit,
Binary file added tests/test_reads/DRR280712.fastq.gz
Binary file not shown.
Binary file added tests/test_reads/SRR5949318_1.fastq.gz
Binary file not shown.
Binary file added tests/test_reads/SRR5949318_2.fastq.gz
Binary file not shown.
Binary file added tests/test_reads/SRR6180434_1.fastq.gz
Binary file not shown.
Binary file added tests/test_reads/SRR6180434_2.fastq.gz
Binary file not shown.
Loading

0 comments on commit aafd6bf

Please sign in to comment.