diff --git a/pages/1-samples_selection.py b/pages/1-samples_selection.py index 121d4679f88a24fd9c7e26cebe906bc685bfae6d..314bf962c276bdee638f7b3eaf2a6baae3b33ab6 100644 --- a/pages/1-samples_selection.py +++ b/pages/1-samples_selection.py @@ -121,26 +121,41 @@ if not t.empty: with scores: st.write('Scores plot') # scores plot with clustering - if list(labels): + if list(labels) and meta_data.empty: fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3, color = labels) - else: + # scores plot with metadata - if not meta_data.empty: - filter = meta_data.columns[1:] - col = st.selectbox('filter', options= filter) - if col == 0: - fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3) - else: - fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3, color = list(map(str.lower,meta_data[col])) ) + elif len(list(labels)) == 0 and not meta_data.empty: + filter = meta_data.columns[1:] + col = st.selectbox('Group by:', options= filter) + if col == 0: + fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3) + else: + fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3, color = list(map(str.lower,meta_data[col])) ) + + # color with scores and metadata + elif len(list(labels)) > 0 and not meta_data.empty: + if clus_method in cluster_methods[1:]: + filter = ['None', clus_method] + filter.extend(meta_data.columns[1:]) + else: + filter = meta_data.columns[1:].insert(0,'None') + + col = st.selectbox('Group by:', options= filter) + if col == "None": + fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3) + elif col == clus_method: + fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3, color = labels) else: - # scores plot with neither metadata nor clustering - fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3) + fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3, color = list(map(str.lower,meta_data[col]))) + + else: + fig = px.scatter_3d(t, x=axis1, y=axis2, z = axis3) fig.update_traces(marker=dict(size=4)) st.plotly_chart(fig) - if not spectra.empty: if dim_red_method == dim_red_methods[1]: with loadings: