Skip to content

Commit

Permalink
🎨📸 Add download plot buttons
Browse files Browse the repository at this point in the history
Add download plot button for each figure. Each plot is svg formatted for download.
  • Loading branch information
evanroyrees committed Oct 19, 2023
1 parent f3ba0a9 commit 1c31a8e
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ def subset_coverage_boxplot_by_scatterplot_selection(
fig = metric_boxplot(data, boxmean="sd")
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-refinement-coverage-boxplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
[
html.Label("Figure 4: MAG Refinement Coverage Boxplot"),
Expand All @@ -46,7 +63,7 @@ def subset_coverage_boxplot_by_scatterplot_selection(
children=[
dcc.Graph(
id=ids.MAG_REFINEMENT_COVERAGE_BOXPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
)
],
type="dot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ def subset_gc_content_boxplot_by_scatterplot_selection(
fig = metric_boxplot(data, boxmean="sd")
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-refinement-gc-content-boxplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
[
html.Label("Figure 5: MAG Refinement GC Content Boxplot"),
Expand All @@ -48,7 +65,7 @@ def subset_gc_content_boxplot_by_scatterplot_selection(
children=[
dcc.Graph(
id=ids.MAG_REFINEMENT_GC_CONTENT_BOXPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
)
],
type="dot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ def subset_length_boxplot_by_scatterplot_selection(
fig = metric_boxplot(data=data)
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-refinement-length-boxplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
[
html.Label("Figure 6: MAG Refinement Length Boxplot"),
Expand All @@ -50,7 +67,7 @@ def subset_length_boxplot_by_scatterplot_selection(
children=[
dcc.Graph(
id=ids.MAG_REFINEMENT_LENGTH_BOXPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
)
],
type="dot",
Expand Down
11 changes: 10 additions & 1 deletion automappa/pages/mag_refinement/components/scatterplot_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,23 @@ def format_title(axis: str) -> str:
)
return go.Figure(data=traces, layout=layout)

graph_config = {
"toImageButtonOptions": dict(
format="svg",
filename="mag-refinement-scatterplot2d-figure",
),
"displayModeBar": True,
"displaylogo": False,
}

return html.Div(
[
html.Label("Figure 1: 2D Metagenome Overview"),
dcc.Loading(
dcc.Graph(
id=ids.SCATTERPLOT_2D_FIGURE,
clear_on_unhover=True,
config={"displayModeBar": True, "displaylogo": False},
config=graph_config,
mathjax=True,
),
id=ids.LOADING_SCATTERPLOT_2D,
Expand Down
23 changes: 18 additions & 5 deletions automappa/pages/mag_refinement/components/taxonomy_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,30 @@ def taxonomy_distribution_figure_callback(
fig = taxonomy_sankey(df)
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-refinement-taxonomy-sankey",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
[
html.Label("Figure 3: Taxonomic Distribution"),
dcc.Loading(
dcc.Graph(
id=ids.TAXONOMY_DISTRIBUTION,
config={
"displayModeBar": False,
"displaylogo": False,
"staticPlot": False,
},
config=graph_config,
),
id=ids.LOADING_TAXONOMY_DISTRIBUTION,
type="graph",
Expand Down
19 changes: 18 additions & 1 deletion automappa/pages/mag_summary/components/mag_coverage_boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,30 @@ def mag_summary_coverage_boxplot_callback(
fig = metric_boxplot(data)
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-summary-MAG-coverage-boxplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
dcc.Loading(
id=ids.LOADING_MAG_COVERAGE_BOXPLOT,
children=[
dcc.Graph(
id=ids.MAG_COVERAGE_BOXPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
)
],
type="default",
Expand Down
19 changes: 18 additions & 1 deletion automappa/pages/mag_summary/components/mag_gc_content_boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,29 @@ def mag_summary_gc_content_boxplot_callback(
fig = metric_boxplot(data)
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-summary-MAG-gc-content-boxplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
[
dcc.Loading(
dcc.Graph(
id=ids.MAG_GC_CONTENT_BOXPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
),
id=ids.LOADING_MAG_GC_CONTENT_BOXPLOT,
type="default",
Expand Down
19 changes: 18 additions & 1 deletion automappa/pages/mag_summary/components/mag_length_boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,31 @@ def mag_summary_gc_content_boxplot_callback(
fig = metric_boxplot(data)
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-summary-MAG-length-boxplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
children=[
dcc.Loading(
id=ids.LOADING_MAG_LENGTH_BOXPLOT,
children=[
dcc.Graph(
id=ids.MAG_LENGTH_BOXPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
)
],
type="dot",
Expand Down
19 changes: 18 additions & 1 deletion automappa/pages/mag_summary/components/mag_metrics_barplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,31 @@ def mag_metrics_callback(metagenome_id: int, refinement_id: int) -> go.Figure:
fig = metric_barplot(data)
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-summary-MAG-metrics-barplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
children=[
dcc.Loading(
id=ids.LOADING_MAG_METRICS_BARPLOT,
children=[
dcc.Graph(
id=ids.MAG_METRICS_BARPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
)
],
type="dot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,31 @@ def mag_overview_coverage_boxplot_callback(metagenome_id: int) -> go.Figure:
fig = metric_boxplot(data)
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-summary-coverage-boxplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
children=[
dcc.Loading(
id=ids.LOADING_MAG_COVERAGE_BOXPLOT,
children=[
dcc.Graph(
id=ids.MAG_OVERVIEW_COVERAGE_BOXPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
)
],
type="dot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,31 @@ def mag_overview_gc_content_boxplot_callback(metagenome_id: int) -> go.Figure:
fig = metric_boxplot(data=data)
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-summary-gc-content-boxplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
children=[
dcc.Loading(
id=ids.LOADING_MAG_OVERVIEW_GC_CONTENT_BOXPLOT,
children=[
dcc.Graph(
id=ids.MAG_OVERVIEW_GC_CONTENT_BOXPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
)
],
type="dot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,31 @@ def mag_overview_length_boxplot_callback(metagenome_id: int) -> go.Figure:
fig = metric_boxplot(data)
return fig

graph_config = dict(
toImageButtonOptions=dict(
format="svg",
filename="mag-summary-length-boxplot",
),
displayModeBar="hover",
displaylogo=False,
modeBarButtonsToAdd=["toImage"],
modeBarButtonsToRemove=[
"pan2d",
"select2d",
"lasso2d",
"resetScale2d",
"zoomOut2d",
],
)

return html.Div(
children=[
dcc.Loading(
id=ids.LOADING_MAG_OVERVIEW_LENGTH_BOXPLOT,
children=[
dcc.Graph(
id=ids.MAG_OVERVIEW_LENGTH_BOXPLOT,
config={"displayModeBar": False, "displaylogo": False},
config=graph_config,
)
],
type="default",
Expand Down
Loading

0 comments on commit 1c31a8e

Please sign in to comment.