From 91c721e16f247b00d1bcdbceb28caf06e9990598 Mon Sep 17 00:00:00 2001 From: Monique Surles-Zeigler Date: Mon, 3 Feb 2025 13:55:59 -0500 Subject: [PATCH] Update dashboard.py --- dashboard.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dashboard.py b/dashboard.py index fbcdb79..450a510 100644 --- a/dashboard.py +++ b/dashboard.py @@ -24,7 +24,9 @@ # Count values for key categorical columns df = new_df.replace(('No weight reported', 'No age reported', 'No sex reported', 'No strain reported', 'No species reported'), value=None) -categorical_columns = ["metadata:sex", "metadata:species", "metadata:tbi_model", "metadata:tbi_device:type", "metadata:age:category", "min_weight", "max_weight", "units_weight", "min_weeks", "max_weeks", "PMID", "metadata:strain", "metadata:tbi_device", "metadata:tbi_model_class", "metadata:tbi_device:angle (degrees from vertical)", "metadata:tbi_device:craniectomy_size", "metadata:tbi_device:dural_tears", "metadata:tbi_device:impact_area", "metadata:tbi_device:impact_depth (mm)", "metadata:tbi_device:impact_duration (ms)", "metadata:tbi_device:impact_velocity (m/s)", "metadata:tbi_device:shape" ] +new_columns = ["metadata:sex", "metadata:species", "metadata:tbi_model", "metadata:tbi_device:type", "metadata:age:category", "min_weight", "max_weight", "units_weight", "min_weeks", "max_weeks", "PMID", "metadata:strain", "metadata:tbi_device", "metadata:tbi_model_class", "metadata:tbi_device:angle (degrees from vertical)", "metadata:tbi_device:craniectomy_size", "metadata:tbi_device:dural_tears", "metadata:tbi_device:impact_area", "metadata:tbi_device:impact_depth (mm)", "metadata:tbi_device:impact_duration (ms)", "metadata:tbi_device:impact_velocity (m/s)", "metadata:tbi_device:shape"] +categorical_columns = ["metadata:sex", "metadata:species", "metadata:tbi_model", "metadata:tbi_device:type","metadata:strain", "metadata:tbi_device"] + #need to add more columns for col in categorical_columns: if col in df.columns: @@ -47,8 +49,14 @@ #Missing data analysis -msno.matrix(df.replace(r'^\s*$', np.nan, regex=True), figsize=(10,5), fontsize=12, color= (0.93, 0.00, 0.37), sparkline=False) + +df.replace(r'^\s*$', np.nan, regex=True) +fig,ax = plt.subplots(figsize=(10,5)) +msno.matrix(df, ax=ax, fontsize=12, color= (0.93, 0.00, 0.37), sparkline=False) + red_patch = mpatches.Patch(color= (0.93, 0.00, 0.37), label='Data present') white_patch = mpatches.Patch(color='white', label='Data absent') -plt.legend(handles=[red_patch, white_patch],loc='center left', bbox_to_anchor=(1.2, 0.7)) -plt.show() + +st.legend(handles=[red_patch, white_patch],loc='center left', bbox_to_anchor=(1.2, 0.7)) + +st.pyplot(fig)