Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tsqc/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
39 changes: 17 additions & 22 deletions tsqc/pages/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"],
)

Expand All @@ -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(
Expand All @@ -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):
Expand All @@ -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,
Expand All @@ -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)