Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1524,52 +1524,49 @@ def insert_line_break(text, max_length=30):
|
|
1524 |
|
1525 |
########################################################### #######################################################################
|
1526 |
|
1527 |
-
|
1528 |
-
|
1529 |
-
def plot_nct2org_icicle (df):
|
1530 |
icicle_df = pd.DataFrame(columns=['ids', 'labels', 'parents', 'hovertext'])
|
1531 |
|
1532 |
# Add the "Trials" root node
|
1533 |
-
icicle_df =
|
1534 |
'ids': ["Trials"],
|
1535 |
'labels': ["Trials"],
|
1536 |
'parents': [""],
|
1537 |
'hovertext': [""]
|
1538 |
-
}), ignore_index=True)
|
1539 |
|
1540 |
# Create a dictionary of NCTId-BriefTitle pairs
|
1541 |
nctid_brieftitle = df[['NCTId', 'BriefTitle']].drop_duplicates().set_index('NCTId').to_dict()['BriefTitle']
|
1542 |
|
1543 |
# Add the NCTId level with BriefTitle as hover text
|
1544 |
-
icicle_df =
|
1545 |
'ids': df['NCTId'].unique(),
|
1546 |
'labels': df['NCTId'].unique(),
|
1547 |
'parents': ["Trials"] * len(df['NCTId'].unique()),
|
1548 |
'hovertext': [nctid_brieftitle[nctid] for nctid in df['NCTId'].unique()]
|
1549 |
-
}), ignore_index=True)
|
1550 |
|
1551 |
# Add the OrgStudyId level
|
1552 |
for nctid in df['NCTId'].unique():
|
1553 |
temp_df = df[df['NCTId'] == nctid]
|
1554 |
orgstudyids = temp_df['OrgStudyId'].unique()
|
1555 |
for orgstudyid in orgstudyids:
|
1556 |
-
icicle_df =
|
1557 |
'ids': [f"{nctid}-{orgstudyid}"],
|
1558 |
'labels': [orgstudyid],
|
1559 |
'parents': [nctid],
|
1560 |
-
|
1561 |
-
|
1562 |
-
}), ignore_index=True)
|
1563 |
|
1564 |
# Add the Condition level
|
1565 |
for index, row in df.iterrows():
|
1566 |
-
icicle_df =
|
1567 |
'ids': [f"{row['NCTId']}-{row['OrgStudyId']}-{row['Condition']}-{index}"],
|
1568 |
'labels': [row['Condition']],
|
1569 |
'parents': [f"{row['NCTId']}-{row['OrgStudyId']}"],
|
1570 |
-
#'hovertext': [row['Condition']] # Set hovertext at the row level for Condition
|
1571 |
'hovertext': [""]
|
1572 |
-
}), ignore_index=True)
|
1573 |
|
1574 |
fig = go.Figure(go.Icicle(
|
1575 |
ids=icicle_df.ids,
|
@@ -1584,6 +1581,8 @@ def plot_nct2org_icicle (df):
|
|
1584 |
|
1585 |
return fig
|
1586 |
|
|
|
|
|
1587 |
######################################################################################################################################
|
1588 |
|
1589 |
|
|
|
1524 |
|
1525 |
########################################################### #######################################################################
|
1526 |
|
1527 |
+
########################################################### #######################################################################
|
1528 |
+
def plot_nct2org_icicle(df):
|
|
|
1529 |
icicle_df = pd.DataFrame(columns=['ids', 'labels', 'parents', 'hovertext'])
|
1530 |
|
1531 |
# Add the "Trials" root node
|
1532 |
+
icicle_df = pd.concat([icicle_df, pd.DataFrame({
|
1533 |
'ids': ["Trials"],
|
1534 |
'labels': ["Trials"],
|
1535 |
'parents': [""],
|
1536 |
'hovertext': [""]
|
1537 |
+
})], ignore_index=True)
|
1538 |
|
1539 |
# Create a dictionary of NCTId-BriefTitle pairs
|
1540 |
nctid_brieftitle = df[['NCTId', 'BriefTitle']].drop_duplicates().set_index('NCTId').to_dict()['BriefTitle']
|
1541 |
|
1542 |
# Add the NCTId level with BriefTitle as hover text
|
1543 |
+
icicle_df = pd.concat([icicle_df, pd.DataFrame({
|
1544 |
'ids': df['NCTId'].unique(),
|
1545 |
'labels': df['NCTId'].unique(),
|
1546 |
'parents': ["Trials"] * len(df['NCTId'].unique()),
|
1547 |
'hovertext': [nctid_brieftitle[nctid] for nctid in df['NCTId'].unique()]
|
1548 |
+
})], ignore_index=True)
|
1549 |
|
1550 |
# Add the OrgStudyId level
|
1551 |
for nctid in df['NCTId'].unique():
|
1552 |
temp_df = df[df['NCTId'] == nctid]
|
1553 |
orgstudyids = temp_df['OrgStudyId'].unique()
|
1554 |
for orgstudyid in orgstudyids:
|
1555 |
+
icicle_df = pd.concat([icicle_df, pd.DataFrame({
|
1556 |
'ids': [f"{nctid}-{orgstudyid}"],
|
1557 |
'labels': [orgstudyid],
|
1558 |
'parents': [nctid],
|
1559 |
+
'hovertext': [""]
|
1560 |
+
})], ignore_index=True)
|
|
|
1561 |
|
1562 |
# Add the Condition level
|
1563 |
for index, row in df.iterrows():
|
1564 |
+
icicle_df = pd.concat([icicle_df, pd.DataFrame({
|
1565 |
'ids': [f"{row['NCTId']}-{row['OrgStudyId']}-{row['Condition']}-{index}"],
|
1566 |
'labels': [row['Condition']],
|
1567 |
'parents': [f"{row['NCTId']}-{row['OrgStudyId']}"],
|
|
|
1568 |
'hovertext': [""]
|
1569 |
+
})], ignore_index=True)
|
1570 |
|
1571 |
fig = go.Figure(go.Icicle(
|
1572 |
ids=icicle_df.ids,
|
|
|
1581 |
|
1582 |
return fig
|
1583 |
|
1584 |
+
|
1585 |
+
|
1586 |
######################################################################################################################################
|
1587 |
|
1588 |
|