diff --git a/src/pages/1-samples_selection.py b/src/pages/1-samples_selection.py index cfefd420c65a33def7fd327ff3878eec22368411..b38cec1e3698bc705c76cd4ec84e7e51edea9dd2 100644 --- a/src/pages/1-samples_selection.py +++ b/src/pages/1-samples_selection.py @@ -562,17 +562,36 @@ if not spectra.empty: st.subheader('III - Selected Samples for Reference Analysis', divider='blue') if selected: c16, c17 = st.columns([3, 1]) - c16.write("Tabular identifiers of selected samples for reference analysis:") + with c16: + st.write("Tabular identifiers of selected samples for reference analysis:") - if 'labels' in globals(): - labels['cluster'] = labels.index - labels.index = labels['names'] - result = DataFrame({'names': selected, - 'cluster': np.array(labels)[selected]}, index=selected) + if 'labels' in globals(): + labels['cluster'] = labels.index + labels.index = labels['names'] + result = DataFrame({'names': selected, + 'cluster': np.array(labels)[selected]}, index=selected) - else: - - st.write(meta_data) + else: + if 'name' in meta_data.columns: + subset = meta_data.drop('name', axis = 1).loc[selected] + else: + subset = meta_data.loc[selected] + st.write(subset) + + with c17: + st.info(f'Information !\n - The total number of samples: {n_specs}.\n- The number of samples selected for reference analysis: {len(selected)}.\n - The proportion of samples selected for reference analysis: {round(len(selected)/n_specs*100)}%.') + + selected_col = st.selectbox('Color by: ', options=filter, format_func=lambda x: x if x else "<Select>", + disabled=True if len(filter) == 1 else False) + if selected_col: + cmap2 = dict( + zip(set(md_df_st_.loc[selected][selected_col]), colorslist[:len(set(md_df_st_.loc[selected][selected_col]))])) + st.write('The distribution of selected samples across categories') + + barhsel = barhplot(md_df_st_.loc[selected][[specs_col]], cmap=cmap2) + st.pyplot(barhsel) + + # if meta_data.empty: @@ -587,8 +606,6 @@ if selected: # sam1.insert(loc=0, column='index', value=selected_samples_idx) # sam1.insert(loc=1, column='cluster', value=np.array(labels)[selected_samples_idx]) # sam1.index = np.arange(len(selected_samples_idx))+1 -# with c17: -# st.info(f'Information !\n - The total number of samples: {n_specs}.\n- The number of samples selected for reference analysis: {sam1.shape[0]}.\n - The proportion of samples selected for reference analysis: {round(sam1.shape[0]/n_specs*100)}%.') # sam = sam1 # if clus_method =='HDBSCAN':