Skip to content

Commit

Permalink
Added button in enrichment tab to open figure in new tab
Browse files Browse the repository at this point in the history
Also fixed bug when selecting a single enrichment method
  • Loading branch information
npalacioescat committed Jun 24, 2024
1 parent 8097052 commit c8d6bd7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/funki/pages/enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from dash.exceptions import PreventUpdate
from dash.dash_table import DataTable
import plotly.express as px
import plotly.graph_objects as go
import decoupler as dc

from utils import serial_to_dataset
Expand Down Expand Up @@ -191,6 +192,10 @@
),
html.Br(),
dcc.Loading(dcc.Graph(id='plot-enrich')),
html.Button(
'Open plot in new tab',
id='nw-plot-enrich',
),
],
style={
'width': '46.5%',
Expand Down Expand Up @@ -330,6 +335,8 @@ def plot_enrich(n_clicks, data, gset_data, meth, gset):
dset = serial_to_dataset(data)
net.drop_duplicates(subset=['genesymbol', gset], inplace=True)

meth = meth if type(meth) is list else [meth]

fan.enrich(
dset,
net,
Expand All @@ -350,4 +357,12 @@ def plot_enrich(n_clicks, data, gset_data, meth, gset):

fig.update_layout(showlegend=False)

return fig, dataset_to_serial(dset)
return fig, dataset_to_serial(dset)

@callback(
Input('nw-plot-enrich', 'n_clicks'),
State('plot-enrich', 'figure')
)
def plot_enrich_new_tab(n_clicks, fig):
if fig:
return go.Figure(fig).show()

0 comments on commit c8d6bd7

Please sign in to comment.