zavavan commited on
Commit
29cb0aa
·
verified ·
1 Parent(s): 0e6c4c9

Update dashboard.py

Browse files
Files changed (1) hide show
  1. dashboard.py +72 -52
dashboard.py CHANGED
@@ -117,59 +117,71 @@ def create_ent_bar_charts(ents, **kwargs):
117
 
118
 
119
  def create_ontology_bar_charts(ents, **kwargs):
120
- if ents=='Drug':
121
- df = pd.DataFrame({
122
- 'Drug_Ontologies': [ont.split('/')[-1] for ont in topDrugOnts_df['ontology']],
123
- 'Frequency': list(topDrugOnts_df['count']),
124
- 'url': list(topDrugOnts_df['ontology_url']) # using full keys as hyperlinks
125
- })
126
- # Create bar chart with label as x-axis
127
- bars = hv.Bars(df, kdims=['Drug_Ontologies'], vdims=['Frequency'])
128
- bars.opts(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  framewise=True,
130
  tools=['hover'],
131
  width=1200,
132
  height=600,
133
  show_legend=True,
134
  xrotation=45,
135
- xlabel='Drug_Ontologies',
136
  ylabel='Frequency',
137
  hover_tooltips=[
138
- ("Drug_Ontologies", "@Drug_Ontologies"),
139
- ("Frequency", "@Frequency")
140
- ]
141
- )
142
- links_panel = pn.Column(
143
- *[pn.pane.Markdown(f"[{row.Drug_Ontologies}]({row.url})", width=400) for _, row in df.iterrows()],
144
- name='Links'
145
- )
146
- layout = pn.Row(bars, links_panel)
147
- return layout
148
- elif ents=='Condition':
149
- df = pd.DataFrame({
150
- 'Condition_Ontologies': [ont.split('/')[-1] for ont in topConditionOnts_df['ontology']],
151
- 'Frequency': list(topConditionOnts_df['count']),
152
- 'url': list(topConditionOnts_df['ontology_url']) # using full keys as hyperlinks
153
- })
154
- # Create bar chart with label as x-axis
155
- bars = hv.Bars(df, kdims=['Condition_Ontologies'], vdims=['Frequency'])
156
- bars.opts(
157
- framewise=True,
158
- tools=['hover'],
159
- width=1200,
160
- height=600,
161
- show_legend=True,
162
- xrotation=45,
163
- xlabel='Condition_Ontologies',
164
- ylabel='Frequency',
165
- hover_tooltips=[
166
- ("Condition Ontologies", "@Condition Ontologies"),
167
- ("Frequency", "@Frequency") ])
168
- links_panel = pn.Column(
169
- *[pn.pane.Markdown(f"[{row.Condition_Ontologies}]({row.url})", width=400) for _, row in df.iterrows()],
170
- name='Links')
171
- layout = pn.Row(bars, links_panel)
172
- return layout
173
 
174
  ############################# WIDGETS & CALLBACK ###########################################
175
 
@@ -205,13 +217,21 @@ button1 = pn.widgets.Button(name="Introduction", button_type="warning", icon="fi
205
  button2 = pn.widgets.Button(name="Top Key Entities", button_type="warning", icon="chart-bar", styles={"width": "100%"})
206
  button3 = pn.widgets.Button(name="Entity/Relation Types:", button_type="warning", icon="chart-histogram", styles={"width": "100%"})
207
  button4 = pn.widgets.Button(name="Ontology Coverage", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
208
- button5 = pn.widgets.Button(name="Causal Relation Chord Diagrams", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
 
 
 
 
 
 
 
 
209
  # Define child buttons
210
- child_button_1 = pn.widgets.Button(name="Cause", button_type="warning")
211
- child_button_2 = pn.widgets.Button(name="Enable", button_type="warning")
212
- child_button_3 = pn.widgets.Button(name="Prevent", button_type="warning")
213
- child_button_4 = pn.widgets.Button(name="Hinder", button_type="warning")
214
- child_button_5 = pn.widgets.Button(name="Other", button_type="warning")
215
  # Layout: dendrogram-style using vertical + indent
216
  tree_layout = pn.Column(
217
  button5,
@@ -303,7 +323,7 @@ def CreatePage3():
303
 
304
  def CreatePage4():
305
  return pn.Column(
306
- pn.pane.Markdown("## Bio Ontology Coverage "),
307
  entTypeButton,
308
  pn.bind(create_ontology_bar_charts, entTypeButton),
309
  align="center", )
 
117
 
118
 
119
  def create_ontology_bar_charts(ents, **kwargs):
120
+ if ents=='Drug':
121
+ df = pd.DataFrame({
122
+ 'Drug_Ontologies': [ont.split('/')[-1] for ont in topDrugOnts_df['ontology']],
123
+ 'Frequency': list(topDrugOnts_df['count']),
124
+ 'url': list(topDrugOnts_df['ontology_url']) # using full keys as hyperlinks
125
+ })
126
+ drug_ontolgy_buttons = []
127
+ for i,row in df.iterrows():
128
+ button = pn.widgets.Button(name=row['Drug_Ontologies'], width=150)
129
+ ## Open the associated URL in a new tab when button is clicked
130
+ button.js_on_click(
131
+ code=f'{row["url"]}", "_blank");')
132
+ drug_ontolgy_buttons.append(button)
133
+ drug_ontology_column = pn.Column(*drug_ontolgy_buttons, sizing_mode='stretch_width')
134
+
135
+ # Create bar chart with label as x-axis
136
+ bars = hv.Bars(df, kdims=['Drug_Ontologies'], vdims=['Frequency'])
137
+ bars.opts(
138
+ framewise=True,
139
+ tools=['hover'],
140
+ width=1200,
141
+ height=600,
142
+ show_legend=True,
143
+ xrotation=45,
144
+ xlabel='Drug_Ontologies',
145
+ ylabel='Frequency',
146
+ hover_tooltips=[
147
+ ("Drug_Ontologies", "@Drug_Ontologies"),
148
+ ("Frequency", "@Frequency")
149
+ ]
150
+ )
151
+ #links_panel = pn.Column(*[pn.pane.Markdown(f"[{row.Drug_Ontologies}]({row.url})", width=400) for _, row in df.iterrows()],name='Links')
152
+ layout = pn.Row(bars, drug_ontology_column)
153
+ return layout
154
+ elif ents=='Condition':
155
+ df = pd.DataFrame({
156
+ 'Condition_Ontologies': [ont.split('/')[-1] for ont in topConditionOnts_df['ontology']],
157
+ 'Frequency': list(topConditionOnts_df['count']),
158
+ 'url': list(topConditionOnts_df['ontology_url']) # using full keys as hyperlinks
159
+ })
160
+ condition_ontolgy_buttons = []
161
+ for i, row in df.iterrows():
162
+ button = pn.widgets.Button(name=row['Condition_Ontologies'], width=150)
163
+ ## Open the associated URL in a new tab when button is clicked
164
+ button.js_on_click(
165
+ code=f'{row["url"]}", "_blank");')
166
+ condition_ontolgy_buttons.append(button)
167
+ condition_ontology_column = pn.Column(*condition_ontolgy_buttons, sizing_mode='stretch_width')
168
+ # Create bar chart with label as x-axis
169
+ bars = hv.Bars(df, kdims=['Condition_Ontologies'], vdims=['Frequency'])
170
+ bars.opts(
171
  framewise=True,
172
  tools=['hover'],
173
  width=1200,
174
  height=600,
175
  show_legend=True,
176
  xrotation=45,
177
+ xlabel='Condition_Ontologies',
178
  ylabel='Frequency',
179
  hover_tooltips=[
180
+ ("Condition Ontologies", "@Condition Ontologies"),
181
+ ("Frequency", "@Frequency") ])
182
+ #links_panel = pn.Column(*[pn.pane.Markdown(f"[{row.Condition_Ontologies}]({row.url})", width=400) for _, row in df.iterrows()],name='Links')
183
+ layout = pn.Row(bars, condition_ontology_column)
184
+ return layout
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
  ############################# WIDGETS & CALLBACK ###########################################
187
 
 
217
  button2 = pn.widgets.Button(name="Top Key Entities", button_type="warning", icon="chart-bar", styles={"width": "100%"})
218
  button3 = pn.widgets.Button(name="Entity/Relation Types:", button_type="warning", icon="chart-histogram", styles={"width": "100%"})
219
  button4 = pn.widgets.Button(name="Ontology Coverage", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
220
+ #button5 = pn.widgets.Button(name="Causal Relation Chord Diagrams", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
221
+
222
+ button5 = pn.pane.Markdown(
223
+ "<div style='background-color:#f0f0f0; padding:8px 16px; border:1px solid #ccc; "
224
+ "border-radius:6px; text-align:center; width:100px;'>Causal Relation Chord Diagrams</div>",
225
+ width=120,
226
+ height=40,
227
+ margin=(5, 5)
228
+ )
229
  # Define child buttons
230
+ child_button_1 = pn.widgets.Button(name="Cause", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
231
+ child_button_2 = pn.widgets.Button(name="Enable", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
232
+ child_button_3 = pn.widgets.Button(name="Prevent", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
233
+ child_button_4 = pn.widgets.Button(name="Hinder", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
234
+ child_button_5 = pn.widgets.Button(name="Other", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
235
  # Layout: dendrogram-style using vertical + indent
236
  tree_layout = pn.Column(
237
  button5,
 
323
 
324
  def CreatePage4():
325
  return pn.Column(
326
+ pn.pane.Markdown("## Bio-Medical Ontology Coverage "),
327
  entTypeButton,
328
  pn.bind(create_ontology_bar_charts, entTypeButton),
329
  align="center", )