Spaces:
Sleeping
Sleeping
Update dashboard.py
Browse files- dashboard.py +22 -3
dashboard.py
CHANGED
@@ -26,6 +26,8 @@ from bokeh.sampledata.les_mis import data
|
|
26 |
from bokeh.io import show
|
27 |
from bokeh.sampledata.les_mis import data
|
28 |
import panel as pn
|
|
|
|
|
29 |
import bokeh
|
30 |
from bokeh.resources import INLINE
|
31 |
from holoviews.operation.timeseries import rolling, rolling_outlier_std
|
@@ -52,6 +54,8 @@ entityTypesFreqMap = read_freq_map('entityTypes.tsv')
|
|
52 |
relationTypesFreqMap = read_freq_map('relationTypes.tsv')
|
53 |
topDrugEntities = read_freq_map('topDrugs.tsv')
|
54 |
topConditionEntities = read_freq_map('topConditions.tsv')
|
|
|
|
|
55 |
|
56 |
|
57 |
grouping_filtered = pd.read_csv(os.path.join(data, 'drugReviewsCausal_relations.tsv'), sep=" ")
|
@@ -76,6 +80,13 @@ def create_ent_bar_charts(ents, **kwargs):
|
|
76 |
dictionary = topConditionEntities
|
77 |
return hv.Bars(dictionary, hv.Dimension('Condition Entities'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600)
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
############################# WIDGETS & CALLBACK ###########################################
|
81 |
|
@@ -112,7 +123,8 @@ def filter_triples(rel):
|
|
112 |
button1 = pn.widgets.Button(name="Introduction", button_type="warning", icon="file-info", styles={"width": "100%"})
|
113 |
button2 = pn.widgets.Button(name="Entity/Relation Types:", button_type="warning", icon="chart-histogram", styles={"width": "100%"})
|
114 |
button3 = pn.widgets.Button(name="Top Key Entities", button_type="warning", icon="chart-bar", styles={"width": "100%"})
|
115 |
-
button4 = pn.widgets.Button(name="
|
|
|
116 |
|
117 |
|
118 |
entRelsButton = pn.widgets.RadioButtonGroup(name='### Select', options=['Entity','Relation'], value = 'Entity' )
|
@@ -141,6 +153,7 @@ button1.on_click(lambda event: show_page("Page1"))
|
|
141 |
button2.on_click(lambda event: show_page("Page2"))
|
142 |
button3.on_click(lambda event: show_page("Page3"))
|
143 |
button4.on_click(lambda event: show_page("Page4"))
|
|
|
144 |
|
145 |
|
146 |
### CREATE PAGE LAYOUTS
|
@@ -178,8 +191,13 @@ def CreatePage3():
|
|
178 |
entTypeButton,
|
179 |
pn.bind(create_ent_bar_charts, entTypeButton),
|
180 |
align="center", )
|
181 |
-
|
182 |
def CreatePage4():
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
return pn.Column(
|
184 |
pn.pane.Markdown("## Causal Relation Chord Diagrams"),
|
185 |
pn.Row(relationTypeButton, pn.bind(filter_triples, relationTypeButton)),
|
@@ -190,6 +208,7 @@ mapping = {
|
|
190 |
"Page2": CreatePage2(),
|
191 |
"Page3": CreatePage3(),
|
192 |
"Page4": CreatePage4(),
|
|
|
193 |
}
|
194 |
|
195 |
#################### SIDEBAR LAYOUT ##########################
|
@@ -205,7 +224,7 @@ template = pn.template.BootstrapTemplate(
|
|
205 |
title=" CausalDrugsKG_Dashboard ",
|
206 |
sidebar=[sidebar],
|
207 |
main=[main_area],
|
208 |
-
header_background="black",
|
209 |
#site="Charting the Landscape of Digital Health",
|
210 |
theme=pn.template.DarkTheme,
|
211 |
sidebar_width=270, ## Default is 330
|
|
|
26 |
from bokeh.io import show
|
27 |
from bokeh.sampledata.les_mis import data
|
28 |
import panel as pn
|
29 |
+
pn.extension(design='material')
|
30 |
+
|
31 |
import bokeh
|
32 |
from bokeh.resources import INLINE
|
33 |
from holoviews.operation.timeseries import rolling, rolling_outlier_std
|
|
|
54 |
relationTypesFreqMap = read_freq_map('relationTypes.tsv')
|
55 |
topDrugEntities = read_freq_map('topDrugs.tsv')
|
56 |
topConditionEntities = read_freq_map('topConditions.tsv')
|
57 |
+
topDrugOnts = read_freq_map('topDrugOntologies.tsv')
|
58 |
+
topConditionOnts = read_freq_map('topConditionOntologies.tsv')
|
59 |
|
60 |
|
61 |
grouping_filtered = pd.read_csv(os.path.join(data, 'drugReviewsCausal_relations.tsv'), sep=" ")
|
|
|
80 |
dictionary = topConditionEntities
|
81 |
return hv.Bars(dictionary, hv.Dimension('Condition Entities'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600)
|
82 |
|
83 |
+
def create_ontology_bar_charts(ents, **kwargs):
|
84 |
+
if ents=='Drug':
|
85 |
+
dictionary = topDrugOnts
|
86 |
+
return hv.Bars(dictionary, hv.Dimension('Drug Ontologies'), 'Frequency').opts( framewise=True, xrotation=45,width=1200, height=600)
|
87 |
+
elif ents=='Condition':
|
88 |
+
dictionary = topConditionOnts
|
89 |
+
return hv.Bars(dictionary, hv.Dimension('Condition Ontologies'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600)
|
90 |
|
91 |
############################# WIDGETS & CALLBACK ###########################################
|
92 |
|
|
|
123 |
button1 = pn.widgets.Button(name="Introduction", button_type="warning", icon="file-info", styles={"width": "100%"})
|
124 |
button2 = pn.widgets.Button(name="Entity/Relation Types:", button_type="warning", icon="chart-histogram", styles={"width": "100%"})
|
125 |
button3 = pn.widgets.Button(name="Top Key Entities", button_type="warning", icon="chart-bar", styles={"width": "100%"})
|
126 |
+
button4 = pn.widgets.Button(name="Ontology Coverage", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
|
127 |
+
button5 = pn.widgets.Button(name="Causal Relation Chord Diagrams", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
|
128 |
|
129 |
|
130 |
entRelsButton = pn.widgets.RadioButtonGroup(name='### Select', options=['Entity','Relation'], value = 'Entity' )
|
|
|
153 |
button2.on_click(lambda event: show_page("Page2"))
|
154 |
button3.on_click(lambda event: show_page("Page3"))
|
155 |
button4.on_click(lambda event: show_page("Page4"))
|
156 |
+
button5.on_click(lambda event: show_page("Page5"))
|
157 |
|
158 |
|
159 |
### CREATE PAGE LAYOUTS
|
|
|
191 |
entTypeButton,
|
192 |
pn.bind(create_ent_bar_charts, entTypeButton),
|
193 |
align="center", )
|
|
|
194 |
def CreatePage4():
|
195 |
+
return pn.Column(
|
196 |
+
pn.pane.Markdown("## Bio Ontology Coverage "),
|
197 |
+
entTypeButton,
|
198 |
+
pn.bind(create_ent_bar_charts, entTypeButton),
|
199 |
+
align="center", )
|
200 |
+
def CreatePage5():
|
201 |
return pn.Column(
|
202 |
pn.pane.Markdown("## Causal Relation Chord Diagrams"),
|
203 |
pn.Row(relationTypeButton, pn.bind(filter_triples, relationTypeButton)),
|
|
|
208 |
"Page2": CreatePage2(),
|
209 |
"Page3": CreatePage3(),
|
210 |
"Page4": CreatePage4(),
|
211 |
+
"Page5": CreatePage5(),
|
212 |
}
|
213 |
|
214 |
#################### SIDEBAR LAYOUT ##########################
|
|
|
224 |
title=" CausalDrugsKG_Dashboard ",
|
225 |
sidebar=[sidebar],
|
226 |
main=[main_area],
|
227 |
+
#header_background="black",
|
228 |
#site="Charting the Landscape of Digital Health",
|
229 |
theme=pn.template.DarkTheme,
|
230 |
sidebar_width=270, ## Default is 330
|