-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.py
More file actions
56 lines (46 loc) · 1.76 KB
/
dashboard.py
File metadata and controls
56 lines (46 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import streamlit as st
from config import NEO4J_URI, NEO4J_USER, NEO4J_PASSWORD
from neo4j import GraphDatabase
st.title("Clinical Trials Knowledge Graph Dashboard")
driver = GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USER, NEO4J_PASSWORD))
def get_trial_count():
with driver.session() as session:
result = session.run("MATCH (t:Trial) RETURN count(t) AS count")
return result.single()["count"]
def get_conditions():
with driver.session() as session:
result = session.run("""
MATCH (c:Condition)<-[:HAS_CONDITION]-(t:Trial)
RETURN c.name AS name, count(t) AS count
ORDER BY count DESC LIMIT 10
""")
return result.data()
def get_sponsors():
with driver.session() as session:
result = session.run("""
MATCH (s:Sponsor)<-[:SPONSORED_BY]-(t:Trial)
RETURN s.name AS name, count(t) AS count
ORDER BY count DESC LIMIT 10
""")
return result.data()
st.subheader("📊 Estatísticas Gerais")
col1, col2 = st.columns(2)
with col1:
st.metric(label="Total de Trials", value=get_trial_count())
with col2:
with driver.session() as session:
result = session.run("MATCH (c:Condition) RETURN count(c) AS count")
condition_count = result.single()["count"]
st.metric(label="Total de Condições", value=condition_count)
st.subheader("🔝 Top 10 Condições")
conditions = get_conditions()
if conditions:
import pandas as pd
df_conditions = pd.DataFrame(conditions)
st.bar_chart(df_conditions.set_index('name')['count'])
st.subheader("🏢 Top 10 Sponsors")
sponsors = get_sponsors()
if sponsors:
import pandas as pd
df_sponsors = pd.DataFrame(sponsors)
st.bar_chart(df_sponsors.set_index('name')['count'])