|
38 | 38 | # Investigate read-level agreement |
39 | 39 | df_bsj_groups = df.group_by(*bsj_columns, "reads").agg(pl.col("tool").unique()).collect() |
40 | 40 |
|
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 | + } |
63 | 64 |
|
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)) |
66 | 67 |
|
67 | 68 | df_bsj_groups = df_bsj_groups.with_columns( |
68 | 69 | tool_count = pl.col("tool").list.len() |
|
0 commit comments