diff --git a/server/effect_update_server.py b/server/effect_update_server.py index 7a1ac9e..89d761d 100644 --- a/server/effect_update_server.py +++ b/server/effect_update_server.py @@ -28,6 +28,7 @@ def update_select_input_anno(): new_choices = choices + ["No Annotation"] ui.update_select("bp_anno", choices=new_choices) ui.update_select("h2_anno", choices=choices) + ui.update_select("h1_anno", choices=choices) ui.update_select("hm1_anno", choices=choices) if choices is not None and len(choices) > 1: @@ -322,4 +323,3 @@ def restore_to_master(): # Clear the subset history since the data is restored subset_history.set("") - diff --git a/server/features_server.py b/server/features_server.py index e12e501..76673de 100644 --- a/server/features_server.py +++ b/server/features_server.py @@ -123,9 +123,6 @@ def spac_Histogram_1(): "alt": "Feature histogram", } - histogram_ui_initialized = reactive.Value(False) - - @render.download(filename="features_histogram_data.csv") def download_histogram1_df(): df = shared['df_histogram1'].get() @@ -135,7 +132,6 @@ def download_histogram1_df(): return csv_bytes, "text/csv" return None - @render.ui @reactive.event(input.go_h1, ignore_none=True) def download_histogram1_button_ui(): @@ -146,61 +142,3 @@ def download_histogram1_button_ui(): class_="btn-warning" ) return None - - - @reactive.effect - def histogram_reactivity(): - btn = input.h1_group_by_check() - ui_initialized = histogram_ui_initialized.get() - - if btn and not ui_initialized: - dropdown = ui.input_select( - "h1_anno", - "Select an Annotation", - choices=shared['obs_names'].get() - ) - ui.insert_ui( - ui.div({"id": "inserted-dropdown"}, dropdown), - selector="#main-h1_dropdown", - where="beforeEnd", - ) - - together_check = ui.input_checkbox( - "h1_together_check", - "Plot Together", - value=True - ) - ui.insert_ui( - ui.div({"id": "inserted-check"}, together_check), - selector="#main-h1_check", - where="beforeEnd", - ) - - histogram_ui_initialized.set(True) - - elif not btn and ui_initialized: - ui.remove_ui("#inserted-dropdown") - ui.remove_ui("#inserted-check") - ui.remove_ui("#inserted-dropdown_together") - histogram_ui_initialized.set(False) - - - @reactive.effect - @reactive.event(input.h1_together_check) - def update_stack_type_dropdown(): - if input.h1_together_check(): - dropdown_together = ui.input_select( - "h1_together_drop", - "Select Stack Type", - choices=['stack', 'layer', 'dodge', 'fill'], - selected='stack' - ) - ui.insert_ui( - ui.div( - {"id": "inserted-dropdown_together"}, - dropdown_together - ), - selector="#main-h1_together_drop", - where="beforeEnd",) - else: - ui.remove_ui("#inserted-dropdown_together") diff --git a/ui/features_ui.py b/ui/features_ui.py index 0a70558..ca1e276 100644 --- a/ui/features_ui.py +++ b/ui/features_ui.py @@ -8,70 +8,129 @@ def features_ui(): "Features", ui.card( {"style": "width:100%;"}, - ui.column( - 12, - ui.row( - ui.column( - 2, - ui.input_select( - "h1_feat", - "Select a Feature", - choices=[] - ), - ui.input_select( - "h1_layer", - "Select a Table", - choices=[], - selected=["Original"] - ), - ui.input_checkbox( - "h1_group_by_check", - "Group By", - value=False - ), - ui.input_checkbox( - "h1_log_x", - "Log X-axis", - value=False - ), - ui.input_checkbox( - "h1_log_y", - "Log Y-axis", - value=False - ), - ui.div(id="main-h1_dropdown"), - ui.div(id="main-h1_check"), - ui.div(id="main-h1_together_drop"), - accessible_slider( - "feat_slider", - "Rotate X-axis Labels (degrees)", - min_val=0, - max_val=90, - value=0, - step=1 - ), - ui.input_action_button( - "go_h1", - "Render Plot", - class_="btn-success" - ), - ui.div( - {"style": "padding-top: 20px;"}, - ui.output_ui("download_histogram1_button_ui") - ), + ui.row( + ui.column(3, _controls_panel()), + ui.column(9, _plot_panel()) + ) + ) + ) + + +def _controls_panel(): + return ui.div( + {"class": "controls-panel"}, + + # === SECTION 1: Core Parameters (always visible) === + ui.h4("Core Parameters"), + ui.input_select( + "h1_feat", + "Select a Feature", + choices=[] + ), + ui.input_select( + "h1_layer", + "Select a Table", + choices=[], + selected=["Original"] + ), + + ui.hr(), + + # === SECTION 2: Plot Configuration (collapsible) === + _collapsible_section( + checkbox_id="h1_show_plot_config", + label="Show Plot Configuration", + content=[ + ui.input_checkbox( + "h1_group_by_check", + "Group By", + value=False + ), + ui.panel_conditional( + "input.h1_group_by_check", + ui.input_select( + "h1_anno", + "Select an Annotation", + choices=[] ), - ui.column( - 10, - ui.div( - {"style": "padding-bottom: 100px;"}, - ui.output_image( - "spac_Histogram_1", - width="100%", - height="60vh" - ) + ui.input_checkbox( + "h1_together_check", + "Plot Together", + value=True + ), + ui.panel_conditional( + "input.h1_together_check", + ui.input_select( + "h1_together_drop", + "Select Stack Type", + choices=["stack", "layer", "dodge", "fill"], + selected="stack" ) ) + ), + ui.input_checkbox( + "h1_log_x", + "Log X-axis", + value=False + ), + ui.input_checkbox( + "h1_log_y", + "Log Y-axis", + value=False ) - ) + ] + ), + + ui.hr(), + + # === SECTION 3: Figure Configuration (collapsible) === + _collapsible_section( + checkbox_id="h1_show_figure_config", + label="Show Figure Configuration", + content=[ + accessible_slider( + "feat_slider", + "Rotate X-axis Labels (degrees)", + min_val=0, + max_val=90, + value=0, + step=1 + ) + ] + ), + + ui.br(), + + # === Generate Button === + ui.input_action_button( + "go_h1", + "Render Plot", + class_="btn-success w-100" + ), + ui.div( + {"style": "padding-top: 20px;"}, + ui.output_ui("download_histogram1_button_ui") + ) + ) + + +def _collapsible_section(checkbox_id, label, content): + """Create a collapsible section with checkbox toggle.""" + return ui.div( + ui.input_checkbox(checkbox_id, label, value=False), + ui.panel_conditional( + f"input.{checkbox_id}", + *content + ) + ) + + +def _plot_panel(): + return ui.div( + {"style": "padding-bottom: 100px;"}, + ui.output_image( + "spac_Histogram_1", + width="100%", + height="60vh" ) )