Skip to content

Commit

Permalink
Merge branch 'dashboard-significance'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMichelsen committed Oct 12, 2022
2 parents 99d2fa1 + 2ed91fb commit 18ed5b4
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 35 deletions.
8 changes: 4 additions & 4 deletions src/metaDMG/viz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ def update_sidebar_right_datatable_results(click_data):
bayesian_list = [
"Fit results:",
html.Br(),
f"z: {ds['Bayesian_z']:.2f}",
html.Br(),
f"D-max: {ds['Bayesian_D_max']:.3f} "
f"± {ds['Bayesian_D_max_std']:.3f}" + s_D_max,
html.Br(),
f"P(<1%): {ds['Bayesian_prob_lt_1p_damage']:.2%}",
html.Br(),
f"q: {ds['Bayesian_q']:.3f} " f"± {ds['Bayesian_q_std']:.3f}" + s_q,
html.Br(),
f"phi: {viz_utils.human_format(ds['Bayesian_phi'])} "
Expand Down Expand Up @@ -344,11 +344,11 @@ def update_sidebar_right_datatable_results(click_data):

"MAP results:",
html.Br(),
f"lambda LR: {ds['lambda_LR']:.2f}",
html.Br(),
f"D-max: {ds['D_max']:.3f} "
f"± {ds['D_max_std']:.3f}",
html.Br(),
f"significance: {ds['significance']:.2f}",
html.Br(),
f"q: {ds['q']:.3f} ± {ds['q_std']:.3f}",
html.Br(),
f"phi: {viz_utils.human_format(ds['phi'])} "
Expand Down
2 changes: 1 addition & 1 deletion src/metaDMG/viz/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_content_main(viz_results, start_configuration):
dropdown_x_axis = dcc.Dropdown(
id="xaxis_column",
options=[{"label": i, "value": i} for i in columns],
value="Bayesian_z" if viz_results.Bayesian else "lambda_LR",
value="Bayesian_prob_lt_1p_damage" if viz_results.Bayesian else "significance",
)

dropdown_y_axis = dcc.Dropdown(
Expand Down
4 changes: 2 additions & 2 deletions src/metaDMG/viz/figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def set_opacity_for_trace(
def make_figure(
viz_results,
df=None,
xaxis_column_name="lambda_LR",
xaxis_column_name="significance",
yaxis_column_name="D_max",
d_columns_latex=None,
):
Expand Down Expand Up @@ -391,7 +391,7 @@ def compute_markersize(

def plt_scatterplot(df, viz_results):

x = "Bayesian_z" if viz_results.Bayesian else "lambda_LR"
x = "Bayesian_prob_lt_1p_damage" if viz_results.Bayesian else "significance"
y = "Bayesian_D_max" if viz_results.Bayesian else "D_max"

size_max = df["size"].max()
Expand Down
46 changes: 23 additions & 23 deletions src/metaDMG/viz/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ def _load_df_results(self):
# XXX remove in final version
df["tax_id"] = df["tax_id"].astype("str").astype("category")

for column in ["lambda_LR", "forward_lambda_LR", "reverse_lambda_LR"]:
clip_df(df, column)
# for column in ["lambda_LR", "forward_lambda_LR", "reverse_lambda_LR"]:
# clip_df(df, column)

Bayesian = any(["Bayesian" in column for column in df.columns]) and (
not any(df["Bayesian_z"].isna())
)
self.Bayesian = Bayesian

df["D_max_significance"] = df["D_max"] / df["D_max_std"]
# df["D_max_significance"] = df["D_max"] / df["D_max_std"]
df["rho_Ac_abs"] = np.abs(df["rho_Ac"])
df["variance_scaling"] = compute_variance_scaling(df, phi_string="phi")

Expand All @@ -176,7 +176,7 @@ def _load_df_results(self):
log_columns = [
"N_reads",
"N_alignments",
"lambda_LR",
# "lambda_LR",
"phi",
"k_sum_total",
"N_sum_total",
Expand Down Expand Up @@ -321,9 +321,9 @@ def _set_hover_info(self):
"tax_id",
# Bayesian Fits
# Frequentist fits
"lambda_LR",
"D_max",
"D_max_std",
"significance",
"q",
"q_std",
"phi",
Expand All @@ -338,9 +338,9 @@ def _set_hover_info(self):
]

custom_data_columns_Bayesian = [
"Bayesian_z",
"Bayesian_D_max",
"Bayesian_D_max_std",
"Bayesian_prob_lt_1p_damage",
"Bayesian_q",
"Bayesian_q_std",
"Bayesian_phi",
Expand All @@ -355,27 +355,27 @@ def _set_hover_info(self):
" Rank: %{customdata[_XXX_]} <br>"
" ID: %{customdata[_XXX_]} <br><br>"
"<b>MAP results</b>: <br>"
" LR: %{customdata[_XXX_]:9.2f} <br>"
" D max: %{customdata[_XXX_]:9.2f} ± %{customdata[_XXX_]:.2f} <br>"
" q: %{customdata[_XXX_]:9.2f} ± %{customdata[_XXX_]:.2f} <br>"
" phi: %{customdata[_XXX_]:.3s} ± %{customdata[_XXX_]:.3s} <br>"
" asymmetry:%{customdata[_XXX_]:9.3f} <br>"
" rho_Ac: %{customdata[_XXX_]:9.3f} <br><br>"
" D max: %{customdata[_XXX_]:6.2%} ± %{customdata[_XXX_]:.2%} <br>"
" significance: %{customdata[_XXX_]:6.2f} <br>"
" q: %{customdata[_XXX_]:6.2f} ± %{customdata[_XXX_]:.2f} <br>"
" phi: %{customdata[_XXX_]:.3s} ± %{customdata[_XXX_]:.3s} <br>"
" asymmetry: %{customdata[_XXX_]:6.3f} <br>"
" corr. Ac: %{customdata[_XXX_]:6.3f} <br><br>"
"<b>Counts</b>: <br>"
" N reads: %{customdata[_XXX_]:.3s} <br>"
" N alignments:%{customdata[_XXX_]:.3s} <br>"
" N sum total: %{customdata[_XXX_]:.3s} <br>"
" k sum total: %{customdata[_XXX_]:.3s} <br>"
" N reads: %{customdata[_XXX_]:6.3s} <br>"
" N alignments: %{customdata[_XXX_]:6.3s} <br>"
" N sum total: %{customdata[_XXX_]:6.3s} <br>"
" k sum total: %{customdata[_XXX_]:6.3s} <br>"
"<extra></extra>"
)

hovertemplate_Bayesian = (
"<b>Fit results</b>: <br>"
" z: %{customdata[_XXX_]:9.2f} <br>"
" D max: %{customdata[_XXX_]:9.2f} ± %{customdata[_XXX_]:.2f} <br>"
" q: %{customdata[_XXX_]:9.2f} ± %{customdata[_XXX_]:.2f} <br>"
" phi: %{customdata[_XXX_]:.3s} ± %{customdata[_XXX_]:.3s} <br>"
" rho_Ac: %{customdata[_XXX_]:9.3f} <br><br>"
" D max: %{customdata[_XXX_]:6.2%} ± %{customdata[_XXX_]:.2%} <br>"
" P(<1%): %{customdata[_XXX_]:7.2%} <br>"
" q: %{customdata[_XXX_]:6.2f} ± %{customdata[_XXX_]:.2f} <br>"
" phi: %{customdata[_XXX_]:.3s} ± %{customdata[_XXX_]:.3s} <br>"
" corr. Ac: %{customdata[_XXX_]:6.3f} <br><br>"
)

if self.forward_only:
Expand All @@ -388,7 +388,7 @@ def _set_hover_info(self):

# if Bayesian fits, include these results
if self.Bayesian:
index = self.custom_data_columns.index("lambda_LR")
index = self.custom_data_columns.index("D_max")
self.custom_data_columns[index:index] = custom_data_columns_Bayesian

index = self.hovertemplate.find("<b>MAP results</b>: <br>")
Expand Down Expand Up @@ -547,7 +547,7 @@ def _ds_to_fit_text(self, ds):
)
text += "\n"

fitqual_col = "Bayesian_z" if self.Bayesian else "lambda_LR"
fitqual_col = "Bayesian_prob_lt_1p_damage" if self.Bayesian else "significance"
fitqual_str = sanitize(fitqual_col)
fitqual = ds[fitqual_col].iloc[0]
text += "$" + fitqual_str + f" = {fitqual:.2f} " + r"$"
Expand Down
16 changes: 11 additions & 5 deletions src/metaDMG/viz/viz_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,19 @@ def get_graph_kwargs_no_buttons():

def get_d_columns_latex(viz_results):
d_columns_latex = {
"Bayesian_z": r"$z$",
"Bayesian_D_max": r"$D_\text{max}$",
"D_max": r"$D_\text{max} \,\, \text{(MAP)}$",
#
"lambda_LR": r"$\lambda_\text{LR} \text{(MAP)}$",
"D_max": r"$D_\text{max} \text{(MAP)}$",
"Bayesian_D_max_significance": r"$D_\text{max} \,\, \text{sig.}$",
"significance": r"$\text{significance} \,\, \text{(MAP)}$",
#
"Bayesian_prob_lt_5p_damage": r"$\mathcal{P}(D_\text{max} < 5\%)$",
"Bayesian_prob_lt_2p_damage": r"$\mathcal{P}(D_\text{max} < 2\%)$",
"Bayesian_prob_lt_1p_damage": r"$\mathcal{P}(D_\text{max} < 1\%)$",
"Bayesian_prob_lt_0.1p_damage": r"$\mathcal{P}(D_\text{max} < 0.1\%)$",
"Bayesian_prob_zero_damage": r"$\mathcal{P}(D_\text{max} = 0\%)$",
#
"asymmetry": r"$\text{asymmetry} \text{(MAP)}$",
"Bayesian_D_max_significance": r"$D_\text{max} \,\, \text{sig.}$",
"D_max_significance": r"$D_\text{max} \,\, \text{sig.} \,\, \text{(MAP)}$",
"Bayesian_D_max_CI_low": r"$D_\text{max} \,\, \text{CI. low}$",
"Bayesian_D_max_CI_high": r"$D_\text{max} \,\, \text{CI. high}$",
"D_max_CI_low": r"$D_\text{max} \,\, \text{CI. low} \,\, \text{(MAP)}$",
Expand All @@ -653,6 +657,8 @@ def get_d_columns_latex(viz_results):
"rho_Ac": r"$\rho_{A, c} \text{(MAP)}$",
"Bayesian_rho_Ac_abs": r"$|\rho_{A, c}|$",
"rho_Ac_abs": r"$|\rho_{A, c}| \text{(MAP)}$",
"lambda_LR": r"$\lambda_\text{LR} \text{(MAP)}$",
"Bayesian_z": r"$z$",
#
"N_reads": r"$N_\text{reads}$",
"N_alignments": r"$N_\text{alignments}$",
Expand Down

0 comments on commit 18ed5b4

Please sign in to comment.