From 8187b913b1601e8a3df31b914ca76fdac327dede Mon Sep 17 00:00:00 2001 From: Savita Karthikeyan Date: Tue, 2 Apr 2024 20:24:20 +0100 Subject: [PATCH] 2 column layout, gene rectangle colour --- tsqc/__main__.py | 3 +++ tsqc/pages/mutations.py | 39 +++++++++++++++++---------------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/tsqc/__main__.py b/tsqc/__main__.py index d0daa62..c32dea1 100644 --- a/tsqc/__main__.py +++ b/tsqc/__main__.py @@ -59,6 +59,9 @@ def show(page_name): opts.Bars(color=config.PLOT_COLOURS[0], line_color=config.PLOT_COLOURS[2]), opts.Segments(color=config.PLOT_COLOURS[2]), opts.Curve(color=config.PLOT_COLOURS[2]), + opts.Rectangles( + fill_color=config.PLOT_COLOURS[0], line_color=config.PLOT_COLOURS[2] + ), ) logger.info(f"Showing page {page_name}") yield pn.indicators.LoadingSpinner(value=True, width=50, height=50) diff --git a/tsqc/pages/mutations.py b/tsqc/pages/mutations.py index 2a8a69a..4aba165 100644 --- a/tsqc/pages/mutations.py +++ b/tsqc/pages/mutations.py @@ -46,7 +46,6 @@ def make_muts_panel(log_y, tsm): filtered.opts( color="num_inheritors", alpha="num_inheritors", - colorbar=True, cmap="BuGn", colorbar_position="left", clabel="inheritors", @@ -125,9 +124,8 @@ def get_mut_data(x_range, y_range, index): def update_pop_freq_plot(x_range, y_range, index): if not index: return hv.Bars([], "population", "frequency").opts( - width=int(int(config.PLOT_WIDTH) / 2), - height=400, - title="Tap on a mutation", + title="Population frequencies", + default_tools=[], tools=["hover"], ) @@ -143,37 +141,31 @@ def update_pop_freq_plot(x_range, y_range, index): "frequency": [mut_data[col] for col in pops], } ) - bars = hv.Bars(df, "population", "frequency").opts( - width=int(int(config.PLOT_WIDTH) / 2), - height=400, framewise=True, - title=f"Mutation {mut_data['id']}: population frequencies", + title="Population frequencies", ylim=(0, max(df["frequency"]) * 1.1), xrotation=45, tools=["hover"], + default_tools=[], ) return bars else: return hv.Bars([], "population", "frequency").opts( - width=int(int(config.PLOT_WIDTH) / 2), - height=400, - title=f"No frequencies available for mutation {mut_data['id']}", + default_tools=[], tools=["hover"], ) def update_mut_info_table(x_range, y_range, index): if not index: return hv.Table([], kdims=["Detail"], vdims=["value"]).opts( - width=int(int(config.PLOT_WIDTH) / 2), - title="Tap on a mutation", + title="Tap on a mutation" ) mut_data = get_mut_data(x_range, y_range, index) pops = [col for col in mut_data.index if "pop_" in col] mut_data = mut_data.drop(pops) return hv.Table(mut_data.items(), kdims=["Column"], vdims=["Value"]).opts( - width=int(int(config.PLOT_WIDTH) / 2), - title=f"Mutation {mut_data['id']}: details", + title=f"Mutation {mut_data['id']}" ) pop_data_dynamic = hv.DynamicMap( @@ -183,9 +175,17 @@ def update_mut_info_table(x_range, y_range, index): update_mut_info_table, streams=[range_stream, selection_stream] ) - layout += (pop_data_dynamic + mut_info_table_dynamic).cols(1) + tap_widgets_layout = (mut_info_table_dynamic + pop_data_dynamic).cols(1) - return pn.Column(layout.opts(shared_axes=True).cols(1)) + return pn.Row( + pn.Column(layout.opts(shared_axes=True).cols(1)), + pn.panel( + tap_widgets_layout, + align="center", + sizing_mode="stretch_width", + margin=(0, 0, 0, 200), + ), + ) def make_annotation_plot(tsm, genes_df): @@ -205,9 +205,7 @@ def make_annotation_plot(tsm, genes_df): ) genes_rects.opts( ylabel=None, - line_color=None, shared_axes=True, - color="maroon", hooks=[customise_ticks], width=config.PLOT_WIDTH, height=100, @@ -231,7 +229,4 @@ def page(tsm): log_y_checkbox, ) - # mut_data = tsm.mutations_df.loc[0] - # mut_table = pn.widgets.Tabulator(mut_data.to_frame().T, height=200, width=800) - return pn.Column(plot_options, muts_panel)