zavavan commited on
Commit
bdae620
·
verified ·
1 Parent(s): 02ec192

Update dashboard.py

Browse files
Files changed (1) hide show
  1. dashboard.py +32 -9
dashboard.py CHANGED
@@ -96,20 +96,43 @@ def create_ontology_bar_charts(ents, **kwargs):
96
  tools=['hover'],
97
  width=1200,
98
  height=600,
99
- show_legend=False,
100
  xrotation=45,
101
  xlabel='Label',
102
  ylabel='Frequency',
103
  hover_tooltips=[
104
- ("Label", "@label"),
105
- ("Frequency", "@frequency"),
106
  ("Link", "@url")
107
  ]
108
  )
109
  return bars
110
  elif ents=='Condition':
111
  dictionary = topConditionOnts
112
- return hv.Bars(dictionary, hv.Dimension('Condition Ontologies'), 'Frequency').opts(framewise=True, xrotation=45,width=1200, height=600)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  ############################# WIDGETS & CALLBACK ###########################################
115
 
@@ -149,11 +172,11 @@ button3 = pn.widgets.Button(name="Top Key Entities", button_type="warning", icon
149
  button4 = pn.widgets.Button(name="Ontology Coverage", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
150
  button5 = pn.widgets.Button(name="Causal Relation Chord Diagrams", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
151
  # Define child buttons
152
- child_button_1 = pn.widgets.Button(name="Child 1", button_type="warning")
153
- child_button_2 = pn.widgets.Button(name="Child 2", button_type="warning")
154
- child_button_3 = pn.widgets.Button(name="Child 2", button_type="warning")
155
- child_button_4 = pn.widgets.Button(name="Child 2", button_type="warning")
156
- child_button_5 = pn.widgets.Button(name="Child 2", button_type="warning")
157
  # Layout: dendrogram-style using vertical + indent
158
  tree_layout = pn.Column(
159
  button5,
 
96
  tools=['hover'],
97
  width=1200,
98
  height=600,
99
+ show_legend=True,
100
  xrotation=45,
101
  xlabel='Label',
102
  ylabel='Frequency',
103
  hover_tooltips=[
104
+ ("Drug Ontologies", "@Drug Ontologies"),
105
+ ("Frequency", "@Frequency"),
106
  ("Link", "@url")
107
  ]
108
  )
109
  return bars
110
  elif ents=='Condition':
111
  dictionary = topConditionOnts
112
+ df = pd.DataFrame({
113
+ 'full_key': list(dictionary.keys()),
114
+ 'Condition Ontologies': [k.split('/')[-1] for k in dictionary.keys()],
115
+ 'Frequency': list(dictionary.values()),
116
+ 'url': list(dictionary.keys()) # using full keys as hyperlinks
117
+ })
118
+ # Create bar chart with label as x-axis
119
+ bars = hv.Bars(df, kdims=['Condition Ontologies'], vdims=['Frequency'])
120
+ bars = bars.opts(
121
+ framewise=True,
122
+ tools=['hover'],
123
+ width=1200,
124
+ height=600,
125
+ show_legend=True,
126
+ xrotation=45,
127
+ xlabel='Label',
128
+ ylabel='Frequency',
129
+ hover_tooltips=[
130
+ ("Condition Ontologies", "@Condition Ontologies"),
131
+ ("Frequency", "@Frequency"),
132
+ ("Link", "@url")
133
+ ]
134
+ )
135
+ return bars
136
 
137
  ############################# WIDGETS & CALLBACK ###########################################
138
 
 
172
  button4 = pn.widgets.Button(name="Ontology Coverage", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
173
  button5 = pn.widgets.Button(name="Causal Relation Chord Diagrams", button_type="warning", icon="chart-dots-filled", styles={"width": "100%"})
174
  # Define child buttons
175
+ child_button_1 = pn.widgets.Button(name="Cause", button_type="warning")
176
+ child_button_2 = pn.widgets.Button(name="Enable", button_type="warning")
177
+ child_button_3 = pn.widgets.Button(name="Prevent", button_type="warning")
178
+ child_button_4 = pn.widgets.Button(name="Hinder", button_type="warning")
179
+ child_button_5 = pn.widgets.Button(name="Other", button_type="warning")
180
  # Layout: dendrogram-style using vertical + indent
181
  tree_layout = pn.Column(
182
  button5,