Skip to content

Commit 9d76d93

Browse files
authored
Update dashboards to use quickboard v0.4.0 (#165)
1 parent 589c62c commit 9d76d93

File tree

5 files changed

+59
-42
lines changed

5 files changed

+59
-42
lines changed

BenchmarkSVs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The SVisualizer is a python script based on [Dash](https://plotly.com/dash/) and
7070

7171
Follow these steps to ensure your environment is prepared.
7272

73-
1. Make sure you have the Python package `quickboard` installed. It's recommended to pin the version to avoid any breaking changes in the future. The version `quickboard==0.3.5` should work with this current version.
73+
1. Make sure you have the Python package `quickboard` installed. It's recommended to pin the version to avoid any breaking changes in the future. The version `quickboard==0.4.0` should work with this current version.
7474
2. Copy all the files from the [SVisualizer](SVisualizer) directory to a fresh directory on your local system.
7575
3. Copy all the files from the WDL outputs into a subdirectory called `wdl_outputs`. You can also use the gathering script [provided](#optional-data-gathering-script) to make this step easier.
7676

BenchmarkSVs/SVisualizer/SVisualizer.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"outputs": [],
1111
"source": [
1212
"import quickboard.base as qbb\n",
13-
"from quickboard.app import start_app, deploy_app, app"
13+
"from quickboard.app import start_app"
1414
]
1515
},
1616
{
@@ -231,7 +231,7 @@
231231
"metadata": {},
232232
"outputs": [],
233233
"source": [
234-
"start_app(board, app_title='SVisualizer', mode='external', port=8050)"
234+
"start_app(board, app_title='SVisualizer', jupyter_mode='external', port=8050)"
235235
]
236236
},
237237
{
@@ -269,9 +269,9 @@
269269
],
270270
"metadata": {
271271
"kernelspec": {
272-
"display_name": "quickboard_venv",
272+
"display_name": "Python 3 (ipykernel)",
273273
"language": "python",
274-
"name": "quickboard_venv"
274+
"name": "python3"
275275
},
276276
"language_info": {
277277
"codemirror_mode": {
@@ -283,7 +283,7 @@
283283
"name": "python",
284284
"nbconvert_exporter": "python",
285285
"pygments_lexer": "ipython3",
286-
"version": "3.9.6"
286+
"version": "3.10.9"
287287
}
288288
},
289289
"nbformat": 4,

BenchmarkSVs/SVisualizer/truvari_tabs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ def make_closest_plot(df, sort_by, asc, mode, disq_values):
167167
title = f'Counts of Disqualified ({disq_values}) Sites (N = {len(df)})'
168168
asc = asc == 'Ascending'
169169
disq_df = make_disqualified_df(df, dist_threshold=500, size_ratio_threshold=0.7, color='Experiment')
170+
category_orders = {'Experiment': EXPERIMENT_ORDER} if EXPERIMENT_ORDER is not None else None
170171
fig = create_upset(disq_df, title=title, sort_by=sort_by, asc=asc, mode=mode, color='Experiment',
171-
category_orders={'Experiment': EXPERIMENT_ORDER}, color_discrete_sequence=EXPERIMENT_COLORS,
172+
category_orders=category_orders, color_discrete_sequence=EXPERIMENT_COLORS,
172173
color_discrete_map=EXPERIMENT_COLOR_DICT)
173174
return fig
174175

BenchmarkVCFs/BenchmarkBoard/BenchmarkBoard.ipynb

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,28 @@
325325
" return plot_df"
326326
]
327327
},
328+
{
329+
"cell_type": "code",
330+
"execution_count": null,
331+
"id": "6d1433dd-c829-470a-82d5-1eb21cb8b568",
332+
"metadata": {},
333+
"outputs": [],
334+
"source": [
335+
"class SubsetConfig:\n",
336+
" def __init__(self, df):\n",
337+
" self.strat = df['Interval'].iloc[0] if len(df) > 0 and 'Interval' in df.columns else None\n",
338+
" self.type_ = df['Type'].iloc[0] if len(df) > 0 else None\n",
339+
" self.color = None if (len(df) > 0) and (df['Experiment'].iloc[0] == 'No_ExpGroups_Provided') else 'Experiment'\n",
340+
"\n",
341+
" def make_title(self, prefix):\n",
342+
" title = prefix\n",
343+
" if self.strat is not None:\n",
344+
" title += f' over {self.strat}'\n",
345+
" if self.type_ is not None:\n",
346+
" title += f' for {self.type_}'\n",
347+
" return title"
348+
]
349+
},
328350
{
329351
"cell_type": "code",
330352
"execution_count": null,
@@ -349,32 +371,30 @@
349371
"outputs": [],
350372
"source": [
351373
"def make_prec_recall_plot(df, marginal, axes_mode):\n",
352-
" strat = df['Interval'].iloc[0]\n",
353-
" type_ = df['Type'].iloc[0]\n",
354-
" color = None if df['Experiment'].iloc[0] == 'No_ExpGroups_Provided' else 'Experiment'\n",
374+
" cfg = SubsetConfig(df)\n",
375+
" \n",
355376
" if not SINGLE_SAMPLE_MODE:\n",
356377
" marginal = marginal.lower() if marginal != 'None' else None\n",
357-
" fig = px.scatter(df, x='Recall', y='Precision', color=color, marginal_x=marginal, marginal_y=marginal,\n",
358-
" hover_data=['Query_Name'], title=f'Precision vs Recall Plot over {strat} for {type_}', \n",
378+
" fig = px.scatter(df, x='Recall', y='Precision', color=cfg.color, marginal_x=marginal, marginal_y=marginal,\n",
379+
" hover_data=['Query_Name'], title=cfg.make_title(prefix=f'Precision vs Recall Plot'), \n",
359380
" category_orders=CATEGORY_ORDERS, color_discrete_map=EXPERIMENT_COLOR_MAP)\n",
360381
" if axes_mode == 'Fixed':\n",
361382
" fig.update_layout(xaxis_range=[0, 1.1], yaxis_range=[0, 1.1])\n",
362383
" else:\n",
363384
" melted_df = df.melt(id_vars=['Experiment', 'Query_Name', 'Base_Name', 'Interval', 'Type'], value_vars=['Precision', 'Recall', 'F1_Score'])\n",
364385
" melted_df = melted_df.rename(columns={'variable': 'Stat', 'value': 'Value'})\n",
365-
" fig = px.bar(melted_df, x='Stat', y='Value', title=f'Performance Stats over {strat} for {type_}', \n",
386+
" fig = px.bar(melted_df, x='Stat', y='Value', title=cfg.make_title(prefix=f'Performance Stats'), \n",
366387
" category_orders=CATEGORY_ORDERS, color_discrete_map=EXPERIMENT_COLOR_MAP)\n",
367388
" fig.update_layout(yaxis_range=[0, 1.1])\n",
368389
" \n",
369390
" return fig\n",
370391
"\n",
371392
"\n",
372393
"def make_stat_covariate_plot(df, covaraite, stat, axes_mode):\n",
373-
" strat = df['Interval'].iloc[0]\n",
374-
" type_ = df['Type'].iloc[0]\n",
375-
" color = None if df['Experiment'].iloc[0] == 'No_ExpGroups_Provided' else 'Experiment'\n",
376-
" fig = px.scatter(df, x=stat_corr, y=stat, color=color, hover_data=['Query_Name', 'TP_Base', 'TP_Query', 'FP', 'FN'],\n",
377-
" title=f'Plot of {stat} by {covariate} over {strat} for {type_}', \n",
394+
" cfg = SubsetConfig(df)\n",
395+
" \n",
396+
" fig = px.scatter(df, x=stat_corr, y=stat, color=cfg.color, hover_data=['Query_Name', 'TP_Base', 'TP_Query', 'FP', 'FN'],\n",
397+
" title=cfg.make_title(prefix=f'Plot of {stat} by {covariate}'), \n",
378398
" category_orders=CATEGORY_ORDERS, color_discrete_map=EXPERIMENT_COLOR_MAP)\n",
379399
" if axes_mode == 'Fixed':\n",
380400
" fig.update_layout(yaxis_range=[0, 1.1])\n",
@@ -492,7 +512,8 @@
492512
"outputs": [],
493513
"source": [
494514
"def make_roc_plot(df, roc_mode, error_bars, axes_mode):\n",
495-
" type_ = df['Type'].iloc[0]\n",
515+
" cfg = SubsetConfig(df)\n",
516+
"\n",
496517
" if roc_mode in ['Precision', 'Recall']:\n",
497518
" error_y = None\n",
498519
" if not SINGLE_SAMPLE_MODE:\n",
@@ -503,11 +524,11 @@
503524
" \n",
504525
" fig = px.line(plot_df, x='Score', y=f'{roc_mode}_mean', error_y=error_y, \n",
505526
" hover_data=['Score', 'TP_Base_mean', 'TP_Query_mean', 'FP_mean', 'FN_mean'],\n",
506-
" title=f'{roc_mode} Plot for {type_} stratified by Score', color='Experiment',\n",
527+
" title=cfg.make_title(f'{roc_mode} Plot') + ' stratified by Score', color=cfg.color,\n",
507528
" category_orders=CATEGORY_ORDERS, color_discrete_map=EXPERIMENT_COLOR_MAP)\n",
508529
" else:\n",
509-
" fig = px.line(df, x='Recall', y='Precision', color='Experiment', line_group='Query_Name', hover_data=['Score'],\n",
510-
" title=f'ROC Plot for {type_} stratified by Score')\n",
530+
" fig = px.line(df, x='Recall', y='Precision', color=cfg.color, line_group='Query_Name', hover_data=['Score'],\n",
531+
" title=cfg.make_title(f'ROC Plot') + ' stratified by Score')\n",
511532
" fig.update_layout(xaxis_range=[0, 1.1])\n",
512533
"\n",
513534
" if axes_mode == 'Fixed':\n",
@@ -605,9 +626,7 @@
605626
"outputs": [],
606627
"source": [
607628
"def make_titv_plot(df, stat, axes_mode):\n",
608-
" color = None if df['Experiment'].iloc[0] == 'No_ExpGroups_Provided' else 'Experiment'\n",
609-
" strat = df['Interval'].iloc[0]\n",
610-
" type_ = df['Type'].iloc[0]\n",
629+
" cfg = SubsetConfig(df)\n",
611630
"\n",
612631
" error_y = None\n",
613632
" if not SINGLE_SAMPLE_MODE:\n",
@@ -619,17 +638,16 @@
619638
" plot_df = plot_df.replace('Ti', 'Transitions').replace('Tv', 'Transversions')\n",
620639
"\n",
621640
" fig = px.bar(plot_df, x='Substitution_Type', y=f'{stat}_mean', error_y=error_y, \n",
622-
" title=f'Plot of {stat} mean by Substitution Type on {strat} for {type_}', \n",
623-
" hover_data=['TP_Base_mean', 'TP_Query_mean', 'FP_mean', 'FN_mean', 'IGN_mean', 'OUT_mean'], color=color, barmode='group',\n",
641+
" title=cfg.make_title(f'Plot of {stat} mean by Substitution Type'), \n",
642+
" hover_data=['TP_Base_mean', 'TP_Query_mean', 'FP_mean', 'FN_mean', 'IGN_mean', 'OUT_mean'], color=cfg.color, barmode='group',\n",
624643
" category_orders=CATEGORY_ORDERS, color_discrete_map=EXPERIMENT_COLOR_MAP)\n",
625644
" if axes_mode == 'Fixed' and stat in ['Precision', 'Recall', 'F1_Score']:\n",
626645
" fig.update_layout(yaxis_range=[0, 1.1])\n",
627646
" return fig\n",
628647
"\n",
629648
"def make_snp_substitution_plot(df, stat, axes_mode):\n",
630-
" color = None if df['Experiment'].iloc[0] == 'No_ExpGroups_Provided' else 'Experiment'\n",
631-
" strat = df['Interval'].iloc[0]\n",
632-
" type_ = df['Type'].iloc[0]\n",
649+
" cfg = SubsetConfig(df)\n",
650+
"\n",
633651
" df_means = df.groupby(['Experiment', 'Type', 'Substitution_Type', \n",
634652
" 'Ref_Nucleotide', 'Var_Nucleotide'])[['TP_Base', 'TP_Query', \n",
635653
" 'FP', 'FN', 'F1_Score', 'Precision', 'Recall', 'IGN', 'OUT']].mean().reset_index()\n",
@@ -647,9 +665,9 @@
647665
" if EXPERIMENT_ORDER is not None:\n",
648666
" category_orders = {**category_orders, **{'Experiment': EXPERIMENT_ORDER}}\n",
649667
"\n",
650-
" fig = px.scatter_3d(plot_df, x='Ref_Nucleotide', y='Var_Nucleotide', z=f'{stat}_mean', error_z=f'{stat}_conf', color=color, \n",
668+
" fig = px.scatter_3d(plot_df, x='Ref_Nucleotide', y='Var_Nucleotide', z=f'{stat}_mean', error_z=f'{stat}_conf', color=cfg.color, \n",
651669
" hover_data=['TP_Base_mean', 'TP_Query_mean', 'FP_mean', 'FN_mean', 'IGN_mean', 'OUT_mean'],\n",
652-
" title=f'Plot of {stat} per Substitution Type on {strat} for {type_}', \n",
670+
" title=cfg.make_title(f'Plot of {stat} per Substitution Type'), \n",
653671
" category_orders=category_orders, symbol='Substitution_Type_mean', color_discrete_map=EXPERIMENT_COLOR_MAP,\n",
654672
" height=700, width=1000,\n",
655673
" )\n",
@@ -745,9 +763,7 @@
745763
"outputs": [],
746764
"source": [
747765
"def make_idd_plot(df, stat, axes_mode):\n",
748-
" color = None if df['Experiment'].iloc[0] == 'No_ExpGroups_Provided' else 'Experiment'\n",
749-
" strat = df['Interval'].iloc[0]\n",
750-
" type_ = df['Type'].iloc[0]\n",
766+
" cfg = SubsetConfig(df)\n",
751767
"\n",
752768
" error_y = None\n",
753769
" if not SINGLE_SAMPLE_MODE:\n",
@@ -756,8 +772,8 @@
756772
" else:\n",
757773
" plot_df = df\n",
758774
" \n",
759-
" fig = px.line(plot_df, x='INDEL_Length', y=f'{stat}_mean', error_y=error_y, title=f'Plot of {stat} mean by INDEL Length on {strat} for {type_}', \n",
760-
" hover_data=['TP_Base_mean', 'TP_Query_mean', 'FP_mean', 'FN_mean', 'IGN_mean', 'OUT_mean'], color=color, line_group=color, \n",
775+
" fig = px.line(plot_df, x='INDEL_Length', y=f'{stat}_mean', error_y=error_y, title=cfg.make_title(f'Plot of {stat} mean by INDEL Length'), \n",
776+
" hover_data=['TP_Base_mean', 'TP_Query_mean', 'FP_mean', 'FN_mean', 'IGN_mean', 'OUT_mean'], color=cfg.color, line_group=cfg.color, \n",
761777
" category_orders=CATEGORY_ORDERS, color_discrete_map=EXPERIMENT_COLOR_MAP)\n",
762778
" if axes_mode == 'Fixed' and stat in ['Precision', 'Recall', 'F1_Score']:\n",
763779
" fig.update_layout(yaxis_range=[0, 1.1])\n",
@@ -859,7 +875,7 @@
859875
"metadata": {},
860876
"outputs": [],
861877
"source": [
862-
"start_app(board, app_title='BenchmarkBoard', mode='external', port=8055)"
878+
"start_app(board, app_title='BenchmarkBoard', jupyter_mode='external', port=8050)"
863879
]
864880
},
865881
{
@@ -881,9 +897,9 @@
881897
],
882898
"metadata": {
883899
"kernelspec": {
884-
"display_name": "quickboard_venv",
900+
"display_name": "Python 3 (ipykernel)",
885901
"language": "python",
886-
"name": "quickboard_venv"
902+
"name": "python3"
887903
},
888904
"language_info": {
889905
"codemirror_mode": {
@@ -895,7 +911,7 @@
895911
"name": "python",
896912
"nbconvert_exporter": "python",
897913
"pygments_lexer": "ipython3",
898-
"version": "3.9.6"
914+
"version": "3.10.9"
899915
}
900916
},
901917
"nbformat": 4,

BenchmarkVCFs/BenchmarkBoard/BenchmarkBoard_README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ BenchmarkBoard is an interactive visualizer meant to complement the [SimpleBench
55
## Quickstart
66

77
To use the BenchmarkBoard, you must satisfy the following requirements:
8-
1. Have a Python environment with [Quickboard](https://github.com/broadinstitute/quickboard) installed, e.g. `pip install quickboard`. The current version of this app should use `quickboard==0.3.3`.
8+
1. Have a Python environment with [Quickboard](https://github.com/broadinstitute/quickboard) installed, e.g. `pip install quickboard`. The current version of this app should use `quickboard==0.4.0`.
99
2. Have the files output by the SimpleBenchmark tool saved locally with their default names.
1010
3. Have a copy of the `BenchmarkBoard.py` or `BenchmarkBoard.ipynb` file saved in the *same* directory as the files from the WDL.
1111

0 commit comments

Comments
 (0)