zavavan commited on
Commit
2774625
·
verified ·
1 Parent(s): 3618400

Update dashboard.py

Browse files
Files changed (1) hide show
  1. dashboard.py +43 -14
dashboard.py CHANGED
@@ -48,6 +48,7 @@ def read_freq_map(filename):
48
  freqmap = dict(zip(df[column_0], df[column_1]))
49
  return freqmap
50
 
 
51
  def read_ont_freq_dataframe(filename):
52
  df = pd.read_csv(os.path.join(data,filename), sep=' ')
53
  #print(df)
@@ -82,12 +83,38 @@ def create_type_bar_charts(entRelsButton, **kwargs):
82
 
83
 
84
  def create_ent_bar_charts(ents, **kwargs):
85
- if ents=='Drug':
86
- dictionary = topDrugEntities
87
- return hv.Bars(dictionary, hv.Dimension('Drug Entities'), 'Frequency').opts( framewise=True, xrotation=45,width=1200, height=600)
88
- elif ents=='Condition':
89
- dictionary = topConditionEntities
90
- return hv.Bars(dictionary, hv.Dimension('Condition Entities'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
  def create_ontology_bar_charts(ents, **kwargs):
93
  if ents=='Drug':
@@ -248,19 +275,21 @@ Entity Chord Diagrams represent the most frequently connected entity pairs withi
248
  """, width=800), align="center")
249
 
250
  def CreatePage2():
 
 
 
 
 
 
 
 
251
  return pn.Column(
252
  pn.pane.Markdown("## Entity/Relation Types "),
253
- entRelsButton,
254
  pn.bind(create_type_bar_charts, entRelsButton),
255
  align="center",
256
  )
257
 
258
- def CreatePage3():
259
- return pn.Column(
260
- pn.pane.Markdown("## Top Entities "),
261
- entTypeButton,
262
- pn.bind(create_ent_bar_charts, entTypeButton),
263
- align="center", )
264
  def CreatePage4():
265
  return pn.Column(
266
  pn.pane.Markdown("## Bio Ontology Coverage "),
@@ -312,7 +341,7 @@ mapping = {
312
  "Page2": CreatePage2(),
313
  "Page3": CreatePage3(),
314
  "Page4": CreatePage4(),
315
- "Page5": CreatePage5(),
316
  "Page5a": CreatePage5a(),
317
  "Page5b": CreatePage5b(),
318
  "Page5c": CreatePage5c(),
 
48
  freqmap = dict(zip(df[column_0], df[column_1]))
49
  return freqmap
50
 
51
+
52
  def read_ont_freq_dataframe(filename):
53
  df = pd.read_csv(os.path.join(data,filename), sep=' ')
54
  #print(df)
 
83
 
84
 
85
  def create_ent_bar_charts(ents, **kwargs):
86
+ # Create button widgets for each label
87
+ drug_buttons = []
88
+ condition_buttons = []
89
+ for i, drg in enumerate(list(topDrugEntities.keys())):
90
+ button = pn.widgets.Button(name=drg, width=150)
91
+ ## Open the associated URL in a new tab when button is clicked
92
+ button.js_on_click(code=f'window.open("https://api-vast.jrc.service.ec.europa.eu/describe/?url=http://causaldrugskg.org/causaldrugskg/resource/{drg}", "_blank");')
93
+ drug_buttons.append(button)
94
+ for i, cnd in enumerate(list(topConditionEntities.keys())):
95
+ button = pn.widgets.Button(name=cnd, width=150)
96
+ ## Open the associated URL in a new tab when button is clicked
97
+ button.js_on_click(
98
+ code=f'window.open("https://api-vast.jrc.service.ec.europa.eu/describe/?url=http://causaldrugskg.org/causaldrugskg/resource/{cnd}", "_blank");')
99
+ condition_buttons.append(button)
100
+
101
+ # Stack the buttons vertically (or wrap in a GridBox for nicer layout)
102
+ drug_button_column = pn.Column(*drug_buttons, sizing_mode='stretch_width')
103
+ condition_button_column = pn.Column(*condition_buttons, sizing_mode='stretch_width')
104
+
105
+
106
+ if ents=='Drug':
107
+ dictionary = topDrugEntities
108
+ bars = hv.Bars(dictionary, hv.Dimension('Drug Entities'), 'Frequency').opts( framewise=True, xrotation=45,width=1200, height=600)
109
+ # Combine everything into a Panel layout
110
+ layout = pn.Row(bars, drug_button_column)
111
+ return layout
112
+ elif ents=='Condition':
113
+ dictionary = topConditionEntities
114
+ bars = hv.Bars(dictionary, hv.Dimension('Condition Entities'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600)
115
+ layout = pn.Row(bars, condition_button_column)
116
+ return layout
117
+
118
 
119
  def create_ontology_bar_charts(ents, **kwargs):
120
  if ents=='Drug':
 
275
  """, width=800), align="center")
276
 
277
  def CreatePage2():
278
+ return pn.Column(
279
+ pn.pane.Markdown("## Top 30 Entities "),
280
+ entTypeButton,
281
+ pn.bind(create_ent_bar_charts, entTypeButton),
282
+ align="center", )
283
+
284
+
285
+ def CreatePage3():
286
  return pn.Column(
287
  pn.pane.Markdown("## Entity/Relation Types "),
288
+ entRelsButton,
289
  pn.bind(create_type_bar_charts, entRelsButton),
290
  align="center",
291
  )
292
 
 
 
 
 
 
 
293
  def CreatePage4():
294
  return pn.Column(
295
  pn.pane.Markdown("## Bio Ontology Coverage "),
 
341
  "Page2": CreatePage2(),
342
  "Page3": CreatePage3(),
343
  "Page4": CreatePage4(),
344
+ #"Page5": CreatePage5(),
345
  "Page5a": CreatePage5a(),
346
  "Page5b": CreatePage5b(),
347
  "Page5c": CreatePage5c(),