diff --git a/CHANGELOG.md b/CHANGELOG.md index fc243f3..de9b088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Initial release of nf-core/seqinspector, created with the [nf-core](https://nf-c - [#96](https://github.com/nf-core/seqinspector/pull/96) Added missing citations to citation tool - [#103](https://github.com/nf-core/seqinspector/pull/103) Configure full-tests - [#110](https://github.com/nf-core/seqinspector/pull/110) Update input schema to accept either tar file or directory as rundir, and fastq messages and patterns. +- [#135](https://github.com/nf-core/seqinspector/pull/135) Added index section to MultiQC reports to facilitate report navigation (#125) ### `Fixed` diff --git a/assets/multiqc_config.yml b/assets/multiqc_config.yml index e960d07..df9da74 100644 --- a/assets/multiqc_config.yml +++ b/assets/multiqc_config.yml @@ -3,9 +3,11 @@ report_comment: > analysis pipeline. For information about how to interpret these results, please see the documentation. report_section_order: + "nf-core-seqinspector-index": + order: -999 "nf-core-seqinspector-methods-description": order: -1000 - software_versions: + multiqc_software_versions: order: -1001 "nf-core-seqinspector-summary": order: -1002 diff --git a/subworkflows/local/utils_nfcore_seqinspector_pipeline/main.nf b/subworkflows/local/utils_nfcore_seqinspector_pipeline/main.nf index 36b1860..a594093 100644 --- a/subworkflows/local/utils_nfcore_seqinspector_pipeline/main.nf +++ b/subworkflows/local/utils_nfcore_seqinspector_pipeline/main.nf @@ -275,3 +275,34 @@ def methodsDescriptionText(mqc_methods_yaml) { return description_html.toString() } +// +// Generate report index for MultiQC +// +def reportIndexMultiqc(tags, global=true) { + def relative_path = global ? ".." : "../.." + + def a_attrs = "target=\"_blank\" class=\"list-group-item list-group-item-action\"" + + // Global report path + def index_section = " Global report\n" + + // Group report paths + tags + .each { tag -> + index_section += " Group report: ${tag}\n" + } + + def yaml_file_text = "id: '${workflow.manifest.name.replace('/', '-')}-index'\n" as String + yaml_file_text += "description: 'MultiQC reports collected from running the pipeline.'\n" + yaml_file_text += "section_name: '${workflow.manifest.name} MultiQC Reports Index'\n" + yaml_file_text += "section_href: 'https://github.com/${workflow.manifest.name}'\n" + yaml_file_text += "plot_type: 'html'\n" + yaml_file_text += "data: |\n" + yaml_file_text += "

Reports

\n" + yaml_file_text += "

Select a report to view (open in a new tab):

\n" + yaml_file_text += "
\n" + yaml_file_text += "${index_section}" + yaml_file_text += "
\n" + + return yaml_file_text +} diff --git a/workflows/seqinspector.nf b/workflows/seqinspector.nf index 5aaa34f..4512042 100644 --- a/workflows/seqinspector.nf +++ b/workflows/seqinspector.nf @@ -20,6 +20,7 @@ include { paramsSummaryMap } from 'plugin/nf-schema' include { paramsSummaryMultiqc } from '../subworkflows/nf-core/utils_nfcore_pipeline' include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pipeline' include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_seqinspector_pipeline' +include { reportIndexMultiqc } from '../subworkflows/local/utils_nfcore_seqinspector_pipeline' /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -148,6 +149,11 @@ workflow SEQINSPECTOR { // // MODULE: MultiQC // + ch_tags = ch_multiqc_files + .map { meta, _sample -> meta.tags } + .flatten() + .unique() + ch_multiqc_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config, checkIfExists: true) : Channel.fromPath("$projectDir/assets/multiqc_config.yml", checkIfExists: true) @@ -174,11 +180,22 @@ workflow SEQINSPECTOR { sort: true ) ) + // Add index to other MultiQC reports + //ch_multiqc_extra_files_global = Channel.empty() + ch_multiqc_extra_files_global = ch_multiqc_extra_files.mix( + ch_tags.toList() + .map { tag_list -> + reportIndexMultiqc(tag_list) + } + .collectFile( + name: 'multiqc_index_mqc.yaml', + ) + ) MULTIQC_GLOBAL ( ch_multiqc_files .map { meta, file -> file } - .mix(ch_multiqc_extra_files) + .mix(ch_multiqc_extra_files_global) .collect(), ch_multiqc_config.toList(), [], @@ -187,13 +204,18 @@ workflow SEQINSPECTOR { [] ) - ch_tags = ch_multiqc_files - .map { meta, _sample -> meta.tags } - .flatten() - .unique() + ch_multiqc_extra_files_tag = ch_multiqc_extra_files.mix( + ch_tags.toList() + .map { tag_list -> + reportIndexMultiqc(tag_list, false) + } + .collectFile( + name: 'multiqc_index_mqc.yaml', + ) + ) multiqc_extra_files_per_tag = ch_tags - .combine(ch_multiqc_extra_files) + .combine(ch_multiqc_extra_files_tag) // Group samples by tag tagged_mqc_files = ch_tags @@ -221,6 +243,7 @@ workflow SEQINSPECTOR { samples_per_tag: samples.flatten() config: config } + MULTIQC_PER_TAG( tagged_mqc_files.samples_per_tag,