diff --git a/modules/local/combinebeds/reads/main.nf b/modules/local/combinebeds/reads/main.nf index 4b80dfa1..eb2bc5f7 100644 --- a/modules/local/combinebeds/reads/main.nf +++ b/modules/local/combinebeds/reads/main.nf @@ -12,8 +12,8 @@ process COMBINEBEDS_READS { output: tuple val(meta), path("${prefix}.bed"), emit: combined - path "*.png" , emit: plots - path "*.json" , emit: multiqc + path "*.png" , emit: plots, optional: true + path "*.json" , emit: multiqc, optional: true path "versions.yml" , emit: versions script: diff --git a/modules/local/combinebeds/reads/templates/reads.py b/modules/local/combinebeds/reads/templates/reads.py index 9218a53c..1c0e7338 100644 --- a/modules/local/combinebeds/reads/templates/reads.py +++ b/modules/local/combinebeds/reads/templates/reads.py @@ -38,31 +38,32 @@ # Investigate read-level agreement df_bsj_groups = df.group_by(*bsj_columns, "reads").agg(pl.col("tool").unique()).collect() -# Plot read-level agreement -bsj_upset_data = from_memberships(df_bsj_groups["tool"].to_list()) -bsj_upset = UpSet(bsj_upset_data, show_counts=True, subset_size="count") -bsj_upset.plot() -plot_file = "${prefix}:read_agreement.png" -plt.savefig(plot_file) -plt.close() - -# MultiQC -image_string = base64.b64encode(open(plot_file, "rb").read()).decode("utf-8") -image_html = f'
' - -multiqc = { - 'id': f"{meta_id}_read_agreement", - 'parent_id': "read_agreement", - 'parent_name': 'Read agreement', - 'parent_description': 'While different tools may agree on the presence of a BSJ, they may disagree on the reads that support it. These plots show the read-level agreement between tools for each BSJ.', - 'section_name': meta_id, - 'description': f'UpSet plot showing the read-level agreement between tools for each BSJ in {meta_id}', - 'plot_type': 'image', - 'data': image_html -} +if len(tools) > 1: + # Plot read-level agreement + bsj_upset_data = from_memberships(df_bsj_groups["tool"].to_list()) + bsj_upset = UpSet(bsj_upset_data, show_counts=True, subset_size="count") + bsj_upset.plot() + plot_file = "${prefix}:read_agreement.png" + plt.savefig(plot_file) + plt.close() + + # MultiQC + image_string = base64.b64encode(open(plot_file, "rb").read()).decode("utf-8") + image_html = f'
' + + multiqc = { + 'id': f"{meta_id}_read_agreement", + 'parent_id': "read_agreement", + 'parent_name': 'Read agreement', + 'parent_description': 'While different tools may agree on the presence of a BSJ, they may disagree on the reads that support it. These plots show the read-level agreement between tools for each BSJ.', + 'section_name': meta_id, + 'description': f'UpSet plot showing the read-level agreement between tools for each BSJ in {meta_id}', + 'plot_type': 'image', + 'data': image_html + } -with open(f"{meta_id}_read_agreement_mqc.json", "w") as f: - f.write(json.dumps(multiqc, indent=4)) + with open(f"{meta_id}_read_agreement_mqc.json", "w") as f: + f.write(json.dumps(multiqc, indent=4)) df_bsj_groups = df_bsj_groups.with_columns( tool_count = pl.col("tool").list.len() diff --git a/subworkflows/local/combine_transcriptomes.nf b/subworkflows/local/combine_transcriptomes.nf index 0a60cd46..4a8cbf8a 100644 --- a/subworkflows/local/combine_transcriptomes.nf +++ b/subworkflows/local/combine_transcriptomes.nf @@ -27,10 +27,6 @@ workflow COMBINE_TRANSCRIPTOMES { ) ch_versions = ch_versions.mix(TRANSCRIPTOME.out.versions) - TRANSCRIPTOME.out.gffread_fasta.ifEmpty { - error 'No transcriptome fasta file produced.' - } - emit: fasta = TRANSCRIPTOME.out.gffread_fasta gtf = EXCLUDE_OVERLONG_TRANSCRIPTS.out.output diff --git a/subworkflows/local/prepare_genome.nf b/subworkflows/local/prepare_genome.nf index 1ef2a692..818fe592 100644 --- a/subworkflows/local/prepare_genome.nf +++ b/subworkflows/local/prepare_genome.nf @@ -108,12 +108,10 @@ workflow PREPARE_GENOME { SAMTOOLS_FAIDX(ch_fasta, [[], []]) ch_versions = ch_versions.mix(SAMTOOLS_FAIDX.out.versions) - ch_circexplorer2_reference = Channel.empty() - if (detection_tools.intersect(['circexplorer2', 'mapsplice']).size() > 0) { - CIRCEXPLORER2_REFERENCE(UCSC_GTFTOGENEPRED.out.genepred, [], false) - ch_circexplorer2_reference = CIRCEXPLORER2_REFERENCE.out.output.map { _meta, file -> file }.collect() - ch_versions = ch_versions.mix(CIRCEXPLORER2_REFERENCE.out.versions) - } + // Circexplorer2 reference is needed for annotation + CIRCEXPLORER2_REFERENCE(UCSC_GTFTOGENEPRED.out.genepred, [], false) + ch_circexplorer2_reference = CIRCEXPLORER2_REFERENCE.out.output.map { _meta, file -> file }.collect() + ch_versions = ch_versions.mix(CIRCEXPLORER2_REFERENCE.out.versions) emit: gtf = ch_gtf