Skip to content

Commit

Permalink
Plotly 3.6.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
alubbock committed Feb 11, 2019
1 parent 36d3a6c commit 5efae11
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def main():
author_email='code@alexlubbock.com',
url='https://www.thunor.net',
packages=['thunor'],
install_requires=['numpy', 'scipy', 'pandas', 'plotly==2.0.10', 'seaborn', 'tables'],
install_requires=['numpy', 'scipy', 'pandas', 'plotly==3.6.1', 'seaborn', 'tables'],
tests_require=['pytest', 'nbval', 'django'],
cmdclass=versioneer.get_cmdclass(),
zip_safe=True,
Expand Down
4 changes: 2 additions & 2 deletions thunor/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def _plotly_scatter_to_dataframe(plot_fig):

rows = []
try:
xaxis_name = strip_tags(plot_fig['layout']['xaxis']['title'])
xaxis_name = strip_tags(plot_fig['layout']['xaxis']['title']['text'])
except KeyError:
xaxis_name = 'x'
try:
yaxis_name = strip_tags(plot_fig['layout']['yaxis']['title'])
yaxis_name = strip_tags(plot_fig['layout']['yaxis']['title']['text'])
except KeyError:
yaxis_name = 'y'
for trace in plot_fig['data']:
Expand Down
36 changes: 25 additions & 11 deletions thunor/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def plot_drc(fit_params, is_absolute=False, color_by=None, color_groups=None,
# No effect null hypothesis
dip_rate_fit = [1 if not is_absolute else fp.fit_obj.divisor] * \
len(dose_x_range)
line_dash = 5
line_dash = 'longdash'
else:
# Fit succeeded
if is_absolute:
Expand Down Expand Up @@ -460,7 +460,7 @@ def plot_drc(fit_params, is_absolute=False, color_by=None, color_groups=None,
'hovertext': hovertext,
'text': annotation_label
})
data = go.Data(traces)

yaxis_range = None
yaxis_rangemode = 'tozero' if is_viability else 'normal'
if not is_absolute:
Expand All @@ -481,7 +481,7 @@ def plot_drc(fit_params, is_absolute=False, color_by=None, color_groups=None,
annotations=annotations,
)

return go.Figure(data=data, layout=layout)
return go.Figure(data=traces, layout=layout)


def plot_drug_combination_heatmap(ctrl_resp_data, expt_resp_data,
Expand Down Expand Up @@ -990,6 +990,13 @@ def plot_drc_params(df_params, fit_param,
'p-value: {:0.4g} '.format(r_value ** 2, p_value)
}]

custom_data = [
{'c': cl, 'd': dr} for cl, dr in zip(
df_params.index.get_level_values('cell_line'),
df_params.index.get_level_values('drug')
)
]

if color_by:
for idx, tag_name in enumerate(color_groups):
location = df_params.index.get_level_values(color_by_col).isin(color_groups[tag_name])
Expand All @@ -1006,6 +1013,7 @@ def plot_drc_params(df_params, fit_param,
hovertext=hovertext,
hoverinfo="text+x+y",
mode='markers',
customdata=custom_data,
marker={'symbol': symbols,
'color': colours[idx]},
name=tag_name
Expand All @@ -1020,6 +1028,7 @@ def plot_drc_params(df_params, fit_param,
hovertext=hovertext,
hoverinfo="text+x+y",
mode='markers',
customdata=custom_data,
marker={'symbol': symbols,
'color': colour_list},
name='{} vs {}'.format(xaxis_param_name,
Expand Down Expand Up @@ -1100,10 +1109,18 @@ def plot_drc_params(df_params, fit_param,
_get_param_name(fit_param)
)

custom_data = [
{'c': cl, 'd': dr} for cl, dr in zip(
df_params.index.get_level_values('cell_line'),
df_params.index.get_level_values('drug')
)
]

data = [go.Bar(x=groups,
y=yvals,
text=text,
name='',
customdata=custom_data,
showlegend=False,
marker={'color': marker_cols}
)]
Expand Down Expand Up @@ -1510,7 +1527,7 @@ def plot_time_course(hts_pandas,
'dash': 'dot' if show_dip_fit else None},
marker={'size': 5},
name=dose_str,
customdata={'csvname': dose},
customdata=({'csvname': dose}, ),
legendgroup=dose_str,
showlegend=well_idx == 0
))
Expand All @@ -1529,12 +1546,12 @@ def plot_time_course(hts_pandas,
line={'color': this_colour},
marker={'size': 5},
name=dose_str,
customdata={'csvname': 'DIP fit ' + dose_str},
customdata=({'csvname': 'DIP fit ' + dose_str}, ),
legendgroup=dose_str,
showlegend=False
))

data = go.Data(traces + traces_fits)
data = (traces + traces_fits)
if log_yaxis:
assay_name = "Change in log<sub>2</sub> {}".format(assay_name)
max_time = df_vals.index.get_level_values('timepoint').max()
Expand Down Expand Up @@ -1597,10 +1614,9 @@ def plot_ctrl_dip_by_plate(df_controls, title=None, subtitle=None):
name=grp
))

data = go.Data(traces)
layout = go.Layout(title=title,
yaxis={'title': 'DIP Rate (h<sup>-1</sup>)'})
return go.Figure(data=data, layout=layout)
return go.Figure(data=traces, layout=layout)


def plot_plate_map(plate_data, color_by='dip_rates',
Expand Down Expand Up @@ -1722,18 +1738,16 @@ def plot_plate_map(plate_data, color_by='dip_rates',
)
)

data = go.Data([well_objs, col_labels, row_labels])
data = (well_objs, col_labels, row_labels)

layout = go.Layout({
'xaxis': {
'showticklabels': False,
'autotick': False,
'showgrid': False,
'zeroline': False,
},
'yaxis': {
'showticklabels': False,
'autotick': False,
'showgrid': False,
'zeroline': False,
'scaleanchor': 'x'
Expand Down

0 comments on commit 5efae11

Please sign in to comment.