Skip to content

Commit

Permalink
colors option added
Browse files Browse the repository at this point in the history
  • Loading branch information
tomarovsky committed Jan 2, 2024
1 parent a963388 commit a72b6e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion workflow/rules/visualization.smk
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ rule busco_histogram:
busco_dir_path / "busco_summaries.tsv"
output:
busco_dir_path / "busco_summaries.svg"
params:
colors=config["busco_histogram_colors"]
log:
std=log_dir_path / "busco_histogram.log",
cluster_log=cluster_log_dir_path / "busco_histogram.cluster.log",
Expand All @@ -220,6 +222,6 @@ rule busco_histogram:
threads:
config["processing_threads"]
shell:
" workflow/scripts/busco_histogram.py -i {input} -o {output} > {log.std} 2>&1; "
" workflow/scripts/busco_histogram.py -i {input} -o {output} -c '{params.colors}' > {log.std} 2>&1; "


12 changes: 8 additions & 4 deletions workflow/scripts/busco_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def main():

position = range(len(data))
bar_width = 0.8
plt.barh(position, data['S'], height=bar_width, label='Complete and single-copy BUSCOs (S)', color='#23b4e8')
plt.barh(position, data['D'], height=bar_width, left=data['S'], label='Complete and duplicated BUSCOs (D)', color='#008dbf')
plt.barh(position, data['F'], height=bar_width, left=data['S'] + data['D'], label='Fragmented BUSCOs (F)', color='#fbbc04')
plt.barh(position, data['M'], height=bar_width, left=data['S'] + data['D'] + data['F'], label='Missing BUSCOs (M)', color='#ea4335')
plt.barh(position, data['S'], height=bar_width, label='Complete and single-copy BUSCOs (S)', color=args.colors[0])
plt.barh(position, data['D'], height=bar_width, left=data['S'], label='Complete and duplicated BUSCOs (D)', color=args.colors[1])
plt.barh(position, data['F'], height=bar_width, left=data['S'] + data['D'], label='Fragmented BUSCOs (F)', color=args.colors[2])
plt.barh(position, data['M'], height=bar_width, left=data['S'] + data['D'] + data['F'], label='Missing BUSCOs (M)', color=args.colors[3])

plt.legend(ncol=4, loc=(-0.005, 0.97), handlelength=0.8, frameon=False)

Expand All @@ -41,5 +41,9 @@ def main():
group_required = parser.add_argument_group('Required options')
group_required.add_argument('-i', '--input', type=str, help="input TSV file from busco_summaries_to_tsv.py")
group_required.add_argument('-o', '--output', type=str, help="output SVG file name")
group_additional = parser.add_argument_group('Additional options')
group_additional.add_argument('-c', '--colors', type=lambda s: list(map(str, s.split(","))),
default=['#23b4e8', '#008dbf', '#fbbc04', '#ea4335'],
help="comma-separated list of colors per BUSCO metrics")
args = parser.parse_args()
main()

0 comments on commit a72b6e1

Please sign in to comment.