Spaces:
Sleeping
Sleeping
Update dashboard.py
Browse files- 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=
|
100 |
xrotation=45,
|
101 |
xlabel='Label',
|
102 |
ylabel='Frequency',
|
103 |
hover_tooltips=[
|
104 |
-
("
|
105 |
-
("Frequency", "@
|
106 |
("Link", "@url")
|
107 |
]
|
108 |
)
|
109 |
return bars
|
110 |
elif ents=='Condition':
|
111 |
dictionary = topConditionOnts
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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="
|
153 |
-
child_button_2 = pn.widgets.Button(name="
|
154 |
-
child_button_3 = pn.widgets.Button(name="
|
155 |
-
child_button_4 = pn.widgets.Button(name="
|
156 |
-
child_button_5 = pn.widgets.Button(name="
|
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,
|