Skip to content

Commit fa9075c

Browse files
authored
Merge pull request #207 from nf-core/203-nfcore_circrnacircrnabsj_detectioncombinebeds_reads-attributeerror-index-object-has-no-attribute-levels
Fix failure in BSJ read agreement analysis, if only a single read-yielding tool is enabled
2 parents f1bab3c + a941eb5 commit fa9075c

File tree

4 files changed

+31
-36
lines changed

4 files changed

+31
-36
lines changed

modules/local/combinebeds/reads/main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ process COMBINEBEDS_READS {
1212

1313
output:
1414
tuple val(meta), path("${prefix}.bed"), emit: combined
15-
path "*.png" , emit: plots
16-
path "*.json" , emit: multiqc
15+
path "*.png" , emit: plots, optional: true
16+
path "*.json" , emit: multiqc, optional: true
1717
path "versions.yml" , emit: versions
1818

1919
script:

modules/local/combinebeds/reads/templates/reads.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,32 @@
3838
# Investigate read-level agreement
3939
df_bsj_groups = df.group_by(*bsj_columns, "reads").agg(pl.col("tool").unique()).collect()
4040

41-
# Plot read-level agreement
42-
bsj_upset_data = from_memberships(df_bsj_groups["tool"].to_list())
43-
bsj_upset = UpSet(bsj_upset_data, show_counts=True, subset_size="count")
44-
bsj_upset.plot()
45-
plot_file = "${prefix}:read_agreement.png"
46-
plt.savefig(plot_file)
47-
plt.close()
48-
49-
# MultiQC
50-
image_string = base64.b64encode(open(plot_file, "rb").read()).decode("utf-8")
51-
image_html = f'<div class="mqc-custom-content-image"><img src="data:image/png;base64,{image_string}" /></div>'
52-
53-
multiqc = {
54-
'id': f"{meta_id}_read_agreement",
55-
'parent_id': "read_agreement",
56-
'parent_name': 'Read agreement',
57-
'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.',
58-
'section_name': meta_id,
59-
'description': f'UpSet plot showing the read-level agreement between tools for each BSJ in {meta_id}',
60-
'plot_type': 'image',
61-
'data': image_html
62-
}
41+
if len(tools) > 1:
42+
# Plot read-level agreement
43+
bsj_upset_data = from_memberships(df_bsj_groups["tool"].to_list())
44+
bsj_upset = UpSet(bsj_upset_data, show_counts=True, subset_size="count")
45+
bsj_upset.plot()
46+
plot_file = "${prefix}:read_agreement.png"
47+
plt.savefig(plot_file)
48+
plt.close()
49+
50+
# MultiQC
51+
image_string = base64.b64encode(open(plot_file, "rb").read()).decode("utf-8")
52+
image_html = f'<div class="mqc-custom-content-image"><img src="data:image/png;base64,{image_string}" /></div>'
53+
54+
multiqc = {
55+
'id': f"{meta_id}_read_agreement",
56+
'parent_id': "read_agreement",
57+
'parent_name': 'Read agreement',
58+
'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.',
59+
'section_name': meta_id,
60+
'description': f'UpSet plot showing the read-level agreement between tools for each BSJ in {meta_id}',
61+
'plot_type': 'image',
62+
'data': image_html
63+
}
6364

64-
with open(f"{meta_id}_read_agreement_mqc.json", "w") as f:
65-
f.write(json.dumps(multiqc, indent=4))
65+
with open(f"{meta_id}_read_agreement_mqc.json", "w") as f:
66+
f.write(json.dumps(multiqc, indent=4))
6667

6768
df_bsj_groups = df_bsj_groups.with_columns(
6869
tool_count = pl.col("tool").list.len()

subworkflows/local/combine_transcriptomes.nf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ workflow COMBINE_TRANSCRIPTOMES {
2727
)
2828
ch_versions = ch_versions.mix(TRANSCRIPTOME.out.versions)
2929

30-
TRANSCRIPTOME.out.gffread_fasta.ifEmpty {
31-
error 'No transcriptome fasta file produced.'
32-
}
33-
3430
emit:
3531
fasta = TRANSCRIPTOME.out.gffread_fasta
3632
gtf = EXCLUDE_OVERLONG_TRANSCRIPTS.out.output

subworkflows/local/prepare_genome.nf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,10 @@ workflow PREPARE_GENOME {
108108
SAMTOOLS_FAIDX(ch_fasta, [[], []])
109109
ch_versions = ch_versions.mix(SAMTOOLS_FAIDX.out.versions)
110110

111-
ch_circexplorer2_reference = Channel.empty()
112-
if (detection_tools.intersect(['circexplorer2', 'mapsplice']).size() > 0) {
113-
CIRCEXPLORER2_REFERENCE(UCSC_GTFTOGENEPRED.out.genepred, [], false)
114-
ch_circexplorer2_reference = CIRCEXPLORER2_REFERENCE.out.output.map { _meta, file -> file }.collect()
115-
ch_versions = ch_versions.mix(CIRCEXPLORER2_REFERENCE.out.versions)
116-
}
111+
// Circexplorer2 reference is needed for annotation
112+
CIRCEXPLORER2_REFERENCE(UCSC_GTFTOGENEPRED.out.genepred, [], false)
113+
ch_circexplorer2_reference = CIRCEXPLORER2_REFERENCE.out.output.map { _meta, file -> file }.collect()
114+
ch_versions = ch_versions.mix(CIRCEXPLORER2_REFERENCE.out.versions)
117115

118116
emit:
119117
gtf = ch_gtf

0 commit comments

Comments
 (0)