@@ -28,7 +28,7 @@ def _render_kv_table(rows: list[tuple[str, str]]) -> str:
2828def _render_df_table (df : Any , max_rows : int = 200 ) -> str :
2929 try :
3030 df2 = df .head (max_rows )
31- return df2 .to_html (index = False , escape = True , classes = "df" )
31+ return df2 .to_html (index = False , escape = False , classes = "df" )
3232 except Exception :
3333 return f"<pre>{ _html .escape (str (df )[:20000 ])} </pre>"
3434
@@ -198,7 +198,7 @@ def generate_tpcav_html_report(
198198 "source" : "motif" ,
199199 }
200200 for nm in motif_insertions :
201- out [f"fscore_{ nm } " ] = row .get (nm )
201+ out [f"fscore_{ nm } _insertions " ] = row .get (nm )
202202 out ["AUC_fscores" ] = row .get ("AUC_fscores" )
203203 out ["Motif_concept_sensitivity_score (AUC_fscores_residual)" ] = row .get ("Motif_concept_sensitivity_score (AUC_fscores_residual)" )
204204 concept_rows .append (out )
@@ -344,15 +344,16 @@ def _new_trainer() -> Any:
344344 # 5) Build JS payload (used by Plotly)
345345 # -----------------------------------------------------------------------------
346346 motif_logo_concepts = selected_motif_concepts [:]
347+ motif_logo_dict = _maybe_build_motif_logo_data_uris (
348+ motif_file if motif_file_fmt == "meme" else None ,
349+ motif_logo_concepts ,
350+ )
347351 js_payload : dict [str , Any ] = {
348352 "motif_file_fmt" : motif_file_fmt ,
349353 "motif_auc_rows" : motif_auc_df .to_dict (orient = "records" ) if motif_auc_df is not None else None ,
350354 "motif_insertions" : motif_insertions ,
351355 "concept_rows" : concept_rows ,
352- "motif_logos" : _maybe_build_motif_logo_data_uris (
353- motif_file if motif_file_fmt == "meme" else None ,
354- motif_logo_concepts ,
355- ),
356+ "motif_logos" : motif_logo_dict ,
356357 "heatmaps" : {
357358 "motif" : {"heatmap" : None , "heatmap_div_id" : "heatmap__motif" , "hover_div_id" : "hover__motif" },
358359 "non-motif" : {"heatmap" : None , "heatmap_div_id" : "heatmap__non_motif" , "hover_div_id" : "hover__non_motif" },
@@ -432,6 +433,9 @@ def _to_list(x: Any) -> Any:
432433
433434 motif_auc_table_html = ""
434435 if motif_auc_df is not None :
436+ # append motif logo column if exists
437+ if motif_logo_dict is not None :
438+ motif_auc_df ['motif_logo' ] = motif_auc_df .apply (lambda x : "<img src=\" " + motif_logo_dict [x ['concept' ]] + "\" width=\" 100\" >" , axis = 1 )
435439 motif_auc_table_html = _render_df_table (motif_auc_df , max_rows = 5000 )
436440
437441 if embed_images :
@@ -480,14 +484,17 @@ def _to_list(x: Any) -> Any:
480484
481485 motif_cols = (
482486 ["rank" , "concept" ]
483- + [f"fscore_{ nm } " for nm in motif_insertions ]
487+ + [f"fscore_{ nm } _insertions " for nm in motif_insertions ]
484488 + ["AUC_fscores" , "Motif_concept_sensitivity_score (AUC_fscores_residual)" , "source" ]
485489 )
486490 extra_cols = ["concept" , "source" , "fscore" ]
487491
488492 if motif_concept_rows :
489493 motif_df = pd .DataFrame (motif_concept_rows )
490494 motif_df = motif_df [[c for c in motif_cols if c in motif_df .columns ]]
495+ # append motif logo column if exists
496+ if motif_logo_dict is not None :
497+ motif_df ['motif_logo' ] = motif_df .apply (lambda x : "<img src=\" " + motif_logo_dict [x ['concept' ]] + "\" width=\" 100\" >" , axis = 1 )
491498 motif_table_html = _render_df_table (motif_df , max_rows = 5000 )
492499 if non_motif_concept_rows :
493500 extra_df = pd .DataFrame (non_motif_concept_rows )
0 commit comments