115115 ui .output_image ("image" , inline = True ),
116116 VERSION ,
117117 ui .HTML (f'<a href="{ PAPER_URL } " target="_blank">Please cite our paper.</a>' ),
118- ui .output_text ("current_time" , inline = True ), # for debugging
118+ # ui.output_text("current_time", inline=True), # for debugging
119119 ###############
120120 ## DATA PAGE ##
121121 ###############
304304 ui .navset_tab (
305305 ui .nav_panel (
306306 "Model Diagnostics" ,
307- ui .output_ui ("pred_vs_true_ui " ),
307+ ui .output_ui ("mlde_results_ui " ),
308308 ui .output_data_frame ("mlde_model_table" ),
309309 ),
310310 ui .nav_panel ("Search Results" , ui .output_ui ("mlde_download_ui" )),
@@ -592,7 +592,7 @@ def zero_shot_ui():
592592
593593 else :
594594 return ui .TagList (
595- "Upload a protein sequence or protein structure in the 'Data' tab to proceed with the Zero Shot Module."
595+ tooltips . zs_file_type ,
596596 )
597597
598598 ################
@@ -639,9 +639,8 @@ def mlde_ui():
639639 ui .input_numeric (
640640 "k_folds" ,
641641 "K-Fold cross validation" ,
642- value = 5 ,
642+ value = 1 ,
643643 min = 1 ,
644- max = 10 ,
645644 ),
646645 ),
647646 ),
@@ -677,7 +676,7 @@ def mlde_ui():
677676 )
678677
679678 else :
680- return ui .TagList ("Upload data in the 'Data' tab to proceed." )
679+ return ui .TagList (tooltips . mlde_file_type )
681680
682681 ### MLDE SEARCH UI ###
683682 @output
@@ -719,18 +718,82 @@ def mlde_search_ui(alt=None):
719718 ui .column (6 , ui .input_task_button ("mlde_search_btn" , "Search" )),
720719 )
721720
721+ @output
722+ @render .ui
723+ def mlde_results_ui (alt = None ):
724+ if MODEL () is not None :
725+ return ui .TagList (
726+ ui .h5 ("Predictions vs. True values of the validation data" ),
727+ ui .output_ui ("pred_vs_true_ui" ),
728+ ui .row (
729+ ui .h5 ("Model statistics" ),
730+ ui .column (
731+ 12 ,
732+ ui .output_data_frame ("mlde_statistics" ),
733+ style = "padding:25px;" ,
734+ ),
735+ ),
736+ ui .h5 ("Validation data" ),
737+ )
738+
739+ @render .data_frame
740+ def mlde_statistics (alt = None ):
741+ model = MODEL ()
742+ if model is not None :
743+ calibration = round (model .calibration , 2 )
744+ val_r2 = round (model .val_r2 , 2 )
745+ val_pearson = round (model .val_pearson [0 ], 2 )
746+ # Add significance stars
747+ pearson_p = model .val_pearson [1 ]
748+ pearson_p_str = f"{ pearson_p :.2e} " # Format p-value in scientific notation
749+
750+ val_ken_tau = round (
751+ model .val_ken_tau .statistic ,
752+ 2 ,
753+ )
754+ val_ken_tau_p = model .val_ken_tau .pvalue
755+ kendall_p_str = (
756+ f"{ val_ken_tau_p :.2e} " # Format p-value in scientific notation
757+ )
758+
759+ # Create DataFrame
760+ df = pd .DataFrame (
761+ {
762+ "Metric" : [
763+ "Calibration error (90% confidence)" ,
764+ "Validation R-squared value" ,
765+ "Validation Pearson correlation" ,
766+ "Kendall Tau correlation" ,
767+ ],
768+ "Value" : [
769+ f"+/- { calibration } " ,
770+ val_r2 ,
771+ f"{ val_pearson } (p-value: { pearson_p_str } )" ,
772+ f"{ val_ken_tau } (p-value: { kendall_p_str } )" ,
773+ ],
774+ "Description" : [
775+ "The calibration error is a measure of model and experimental noise. A value of 0 indicates a perfect model and no experimental noise." ,
776+ "The R-squared value is a measure of how well the model fits the data. A value of 1 indicates a perfect fit." ,
777+ "The Pearson correlation measures the strength and direction of the predictions and actual values. A value of 1 indicates a perfect correlation." ,
778+ "The Kendall Tau correlation is a measure of how well the model ranks the data. A value of 1 indicates a perfect ranking." ,
779+ ],
780+ }
781+ )
782+
783+ return df
784+
722785 ###################
723786 ## DISCOVERY TAB ##
724787 ###################
725788 @output
726789 @render .ui
727790 def discovery_ui_clu (alt = None ):
728- if Y_TYPE == "num " :
791+ if Y_TYPE () != "class " :
729792 return ui .TagList (
730793 "The Discovery workflow is only available for categorical Y-Values. Please use the MLDE workflow for numerical Y-values"
731794 )
732795
733- elif MODE () != "start " :
796+ elif MODE () == "dataset " :
734797 return ui .TagList (
735798 ui .row (
736799 ui .h5 ("Protein Discovery and Annotation" ),
@@ -792,19 +855,17 @@ def discovery_ui_clu(alt=None):
792855 )
793856
794857 else :
795- return ui .TagList (
796- "Upload a library in the 'Data' tab to proceed with the Discovery module."
797- )
858+ return ui .TagList (tooltips .discovery_file_type )
798859
799860 @output
800861 @render .ui
801862 def discovery_ui_class (alt = None ):
802- if Y_TYPE == "num " :
863+ if Y_TYPE () != "class " :
803864 return ui .TagList (
804865 "The Discovery workflow is only available for categorical Y-Values. Please use the MLDE workflow for numerical Y-values"
805866 )
806867
807- elif MODE () != "start " :
868+ elif MODE () == "dataset " :
808869 return ui .TagList (
809870 ui .row (
810871 ui .h5 ("Protein Discovery and Annotation" ),
@@ -893,9 +954,7 @@ def discovery_ui_class(alt=None):
893954 )
894955
895956 else :
896- return ui .TagList (
897- "Upload a library in the 'Data' tab to proceed with the Discovery module."
898- )
957+ return ui .TagList (tooltips .discovery_file_type )
899958
900959 ### DISCOVERY SEARCH UI ###
901960 @output
@@ -1251,7 +1310,7 @@ async def _():
12511310 ui .update_select ("discovery_model_type" , choices = _MODEL_TYPES ())
12521311
12531312 ui .update_select ("y_type" , choices = [_y_type ])
1254- print ( "Library loaded successfully" )
1313+
12551314 PROTEIN .set (None )
12561315
12571316 REP_PATH .set (None ) # used in train
@@ -1260,13 +1319,19 @@ async def _():
12601319
12611320 LIBRARY_PLOT .set (None )
12621321
1322+ with ui .Progress (min = 1 , max = 15 ) as p :
1323+ p .set (
1324+ message = "Data loaded" ,
1325+ )
1326+ await asyncio .sleep (0.5 )
1327+
12631328 except Exception :
12641329 with ui .Progress (min = 1 , max = 15 ) as p :
12651330 p .set (
12661331 message = "Problem with input file" ,
12671332 detail = "Please check if there are any problems with the input file." ,
12681333 )
1269- time .sleep (2.5 )
1334+ await asyncio .sleep (2.5 )
12701335
12711336 ### READING PROTEIN FILE ###
12721337 @reactive .Effect
@@ -1443,7 +1508,7 @@ async def _():
14431508 prot = PROTEIN ()
14441509
14451510 if input .demo_structure_check ():
1446- data_path = os .path .join (app_path , "../demo/demo_data/GB1 .pdb" )
1511+ data_path = os .path .join (app_path , "../demo/demo_data/1zb6 .pdb" )
14471512 file_name = data_path .split ("/" )[- 1 ]
14481513 else :
14491514 f : list [FileInfo ] = input .structure_file ()
@@ -2312,6 +2377,8 @@ async def train_mlde_model():
23122377 finally :
23132378 # Reset the task running state in the session
23142379 IS_MLDE_TRAINING_RUNNING .set (False )
2380+ with ui .Progress (min = 1 , max = 15 ) as p :
2381+ p .set (message = "Done..." , detail = "" )
23152382
23162383 @reactive .effect
23172384 @reactive .event (input .mlde_train_button )
@@ -2353,6 +2420,10 @@ def mlde_model_table(alt=None):
23532420 model = MODEL ()
23542421 if model is not None :
23552422 table = VAL_DF ()
2423+ if "y_sigma" in table .columns :
2424+ # if y_sigma column is empty, drop it
2425+ if table ["y_sigma" ].isnull ().all ():
2426+ table = table .drop (["y_sigma" ], axis = 1 )
23562427 return table
23572428
23582429 #################
@@ -2422,6 +2493,10 @@ def mlde_search_table(alt=None):
24222493 table = table .drop (["sequence" ], axis = 1 )
24232494 if "y_true" in table .columns :
24242495 table = table .drop (["y_true" ], axis = 1 )
2496+ if "y_sigma" in table .columns :
2497+ # if y_sigma column is empty, drop it
2498+ if table ["y_sigma" ].isnull ().all ():
2499+ table = table .drop (["y_sigma" ], axis = 1 )
24252500
24262501 return table
24272502
0 commit comments