From 07905ffe1ec4af3daa56bb221a92b4a983f1c365 Mon Sep 17 00:00:00 2001 From: DIANE Abderrahim <abderrahim.diane@cefe.cnrs.fr> Date: Tue, 8 Oct 2024 13:22:27 +0300 Subject: [PATCH] correcting for interface switching error --- src/pages/1-samples_selection.py | 71 ++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/src/pages/1-samples_selection.py b/src/pages/1-samples_selection.py index 60799ef..185b912 100644 --- a/src/pages/1-samples_selection.py +++ b/src/pages/1-samples_selection.py @@ -32,31 +32,46 @@ if Path('report/out/model').exists() and Path('report/out/model').is_dir(): rmtree(Path('report/out/model')) # algorithms available on our app -dim_red_methods=['PCA','UMAP', 'NMF'] # List of dimensionality reduction algos -cluster_methods = ['Kmeans','HDBSCAN', 'AP'] # List of clustering algos -selec_strategy = ['center','random'] - match st.session_state["interface"]: case 'simple': - st.write(':red[Automated Simple Interface]') - # hide_pages("Predictions") - if 37 not in st.session_state: - default_reduction_option = 1 - else: - default_reduction_option = dim_red_methods.index(st.session_state.get(37)) - if 38 not in st.session_state: - default_clustering_option = 1 - else: - default_clustering_option = cluster_methods.index(st.session_state.get(38)) - if 102 not in st.session_state: - default_sample_selection_option = 1 - else: - default_sample_selection_option = selec_strategy.index(st.session_state.get(102)) + dim_red_methods = ['PCA'] + cluster_methods = ['Kmeans'] # List of clustering algos + selec_strategy = ['center'] + + case 'advanced': + dim_red_methods=['PCA','UMAP', 'NMF'] # List of dimensionality reduction algos + cluster_methods = ['Kmeans','HDBSCAN', 'AP'] # List of clustering algos + selec_strategy = ['center','random'] + + +#match st.session_state["interface"]: +# case 'simple': +# st.write(':red[Automated Simple Interface]') +# # hide_pages("Predictions") +# if 37 not in st.session_state: +# default_reduction_option = 1 +# else: +# default_reduction_option = dim_red_methods.index(st.session_state.get(37)) + +# if 38 not in st.session_state: + #st.session_state["38"] = "Kmeans" +# st.write(st.session_state) +# default_clustering_option = 1 + #st.write(st.session_state.get(x)) + +# else: + +# default_clustering_option = cluster_methods.index(st.session_state.get(38)) +# if 102 not in st.session_state: +# default_sample_selection_option = 1 +# else: +# default_sample_selection_option = selec_strategy.index(st.session_state.get(102)) - case'advanced': - default_reduction_option = 0 - default_clustering_option = 0 - default_sample_selection_option = 0 +# case'advanced': +# default_reduction_option = 0 +# default_clustering_option = 0 +# default_sample_selection_option = 0 +#st.write(st.session_state) @@ -243,7 +258,9 @@ if not spectra.empty: c5, c6, c7, c8, c9, c10, c11 = st.columns([1, 1, 0.6, 0.6, 0.6, 1.5, 1.5]) with c5: - dim_red_method = st.selectbox("Dimensionality reduction techniques: ", options = ['']+dim_red_methods, index = default_reduction_option, key = 37, format_func = lambda x: x if x else "<Select>") + dim_red_method = st.selectbox("Dimensionality reduction techniques: ", + options = ['']+dim_red_methods if len(dim_red_methods)>2 else dim_red_methods, + key = 37, format_func = lambda x: x if x else "<Select>", disabled = False if len(dim_red_methods)>2 else True) if dim_red_method == '': st.info('Info: Select a dimensionality reduction technique!') p_hash(dim_red_method) @@ -260,8 +277,10 @@ if not spectra.empty: umapsupervisor = None p_hash(supervised) - disablewidgets = [False if dim_red_method else True][0] - clus_method = st.selectbox("Clustering techniques(optional): ", options = ['']+cluster_methods, index = default_clustering_option, key = 38, format_func = lambda x: x if x else "<Select>", disabled= disablewidgets) + disablewidgets = [False if (dim_red_method and st.session_state.interface == 'advanced') else True][0] + clus_method = st.selectbox("Clustering techniques(optional): ", + options = ['']+cluster_methods if len(cluster_methods)>2 else cluster_methods, + key = 38, format_func = lambda x: x if x else "<Select>", disabled= disablewidgets) # if disablewidgets == False and dim_red_method in dim_red_methods: @@ -316,7 +335,7 @@ if not spectra.empty: elif dr_model and clus_method: disabled1 = False if clus_method in cluster_methods else True - selection = st.radio('Select samples selection strategy:', options = selec_strategy, index = default_sample_selection_option, key=102, disabled = disabled1) + selection = st.radio('Select samples selection strategy:', options = selec_strategy, disabled = disabled1) -- GitLab