Skip to content
Snippets Groups Projects
Commit 41ebda6c authored by Mouhcine's avatar Mouhcine
Browse files

Test

parent 2660dec4
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ from scipy.sparse.csgraph import minimum_spanning_tree ...@@ -26,7 +26,7 @@ from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csgraph from scipy.sparse import csgraph
# Modelling # Modelling
from juliacall import Main as jl #from juliacall import Main as jl
from pinard import utils from pinard import utils
from pinard import preprocessing as pp from pinard import preprocessing as pp
......
...@@ -181,14 +181,18 @@ if labels: ...@@ -181,14 +181,18 @@ if labels:
meta['index'] = spectra.index[selected_samples_idx] meta['index'] = spectra.index[selected_samples_idx]
selected_samples_metd.write(meta) selected_samples_metd.write(meta)
############################################################################
## Scores ## Scores
if not t.empty: if not t.empty:
with scores: with scores:
fig1, ((ax1, ax2),(ax3,ax4)) = plt.subplots(2,2)
st.write('Scores plot') st.write('Scores plot')
# scores plot with clustering # scores plot with clustering
if list(labels) and meta_data.empty: if list(labels) and meta_data.empty:
fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3, color = labels) fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3, color = labels)
sns.scatterplot(data = tcr, x = axis1, y =axis2 , hue = labels, ax = ax1)
# scores plot with metadata # scores plot with metadata
elif len(list(labels)) == 0 and not meta_data.empty: elif len(list(labels)) == 0 and not meta_data.empty:
...@@ -196,9 +200,12 @@ if not t.empty: ...@@ -196,9 +200,12 @@ if not t.empty:
col = st.selectbox('Color by:', options= filter) col = st.selectbox('Color by:', options= filter)
if col == 0: if col == 0:
fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3) fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3)
sns.scatterplot(data = tcr, x = axis1, y =axis2 , ax = ax1)
else: else:
fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3, color = list(map(str.lower,meta_data[col])) ) fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3, color = list(map(str.lower,meta_data[col])) )
sns.scatterplot(data = tcr, x = axis1, y =axis2 , hue = list(map(str.lower,meta_data[col])), ax = ax1)
# color with scores and metadata # color with scores and metadata
elif len(list(labels)) > 0 and not meta_data.empty: elif len(list(labels)) > 0 and not meta_data.empty:
if clus_method in cluster_methods[1:]: if clus_method in cluster_methods[1:]:
...@@ -210,13 +217,19 @@ if not t.empty: ...@@ -210,13 +217,19 @@ if not t.empty:
col = st.selectbox('Color by:', options= filter) col = st.selectbox('Color by:', options= filter)
if col == "None": if col == "None":
fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3) fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3)
sns.scatterplot(data = tcr, x = axis1, y =axis2 , ax = ax1)
elif col == clus_method: elif col == clus_method:
fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3, color = labels) fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3, color = labels)
sns.scatterplot(data = tcr, x = axis1, y =axis2 , ax = ax1)
else: else:
fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3, color = list(map(str.lower,meta_data[col]))) fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3, color = list(map(str.lower,meta_data[col])))
sns.scatterplot(data = tcr, x = axis1, y =axis2 , hue = list(map(str.lower,meta_data[col])), ax = ax1)
sns.scatterplot(data = tcr, x = axis1, y =axis2 , hue = list(map(str.lower,meta_data[col])), ax = ax2)
sns.scatterplot(data = tcr, x = axis1, y =axis2 , hue = list(map(str.lower,meta_data[col])), ax = ax3)
else: else:
fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3) fig = px.scatter_3d(tcr, x=axis1, y=axis2, z = axis3)
sns.scatterplot(data = tcr, x = axis1, y =axis2 , ax = ax1)
fig.update_traces(marker=dict(size=4)) fig.update_traces(marker=dict(size=4))
if selected_samples_idx: if selected_samples_idx:
...@@ -224,8 +237,10 @@ if not t.empty: ...@@ -224,8 +237,10 @@ if not t.empty:
fig.add_scatter3d(x = tt.loc[:,axis1], y = tt.loc[:,axis2], fig.add_scatter3d(x = tt.loc[:,axis1], y = tt.loc[:,axis2],
z = tt.loc[:,axis3], mode ='markers', marker = dict(size = 7, color = 'black'), z = tt.loc[:,axis3], mode ='markers', marker = dict(size = 7, color = 'black'),
name = 'selected samples') name = 'selected samples')
plt.savefig("./Report/Figures/test.png")
st.plotly_chart(fig, use_container_width=True) st.plotly_chart(fig, use_container_width=True)
import plotly.express as px import plotly.express as px
if labels: if labels:
...@@ -254,7 +269,29 @@ if not t.empty: ...@@ -254,7 +269,29 @@ if not t.empty:
fig_axe2_axe3.update_traces(marker=dict(size=4)) fig_axe2_axe3.update_traces(marker=dict(size=4))
fig_axe2_axe3.write_image("./Report/Figures/plot_axe2_axe3.png") fig_axe2_axe3.write_image("./Report/Figures/plot_axe2_axe3.png")
else :
fig_axe1_axe2 = px.scatter(tcr, x=axis1, y=axis2, color=labels if list(labels) else None)
fig_axe1_axe2.update_layout(title='Axe1-Axe2')
fig_axe1_axe2.update_traces(marker=dict(size=4))
fig_axe1_axe2.write_image("./Report/Figures/plot_axe1_axe2.png")
# Créer et exporter le graphique Axe1-Axe3 en PNG
fig_axe1_axe3 = px.scatter(tcr, x=axis1, y=axis3, color=labels if list(labels) else None)
fig_axe1_axe3.update_layout(title='Axe1-Axe3')
fig_axe1_axe3.update_traces(marker=dict(size=4))
fig_axe1_axe3.write_image("./Report/Figures/plot_axe1_axe3.png")
# Créer et exporter le graphique Axe2-Axe3 en PNG
fig_axe2_axe3 = px.scatter(tcr, x=axis2, y=axis3, color=labels if list(labels) else None)
fig_axe2_axe3.update_layout(title='Axe2-Axe3')
fig_axe2_axe3.update_traces(marker=dict(size=4))
fig_axe2_axe3.write_image("./Report/Figures/plot_axe2_axe3.png")
#################################################################
if not spectra.empty: if not spectra.empty:
if dim_red_method == dim_red_methods[1]: if dim_red_method == dim_red_methods[1]:
......
import streamlit as st import streamlit as st
from Packages import *
st.set_page_config(page_title="NIRS Utils", page_icon=":goat:", layout="wide",)
if 'interface' not in st.session_state:
st.session_state['interface'] = 'simple'
from Modules import *
from Class_Mod.DATA_HANDLING import *
# HTML for the banner "CEFE - CNRS" # HTML for the banner "CEFE - CNRS"
# bandeau_html = """ # bandeau_html = """
# <div style="width: 100%; background-color: #4682B4; padding: 10px; margin-bottom: 10px;"> # <div style="width: 100%; background-color: #4682B4; padding: 10px; margin-bottom: 10px;">
...@@ -28,7 +33,7 @@ with st.container(): ...@@ -28,7 +33,7 @@ with st.container():
.stButton>button { .stButton>button {
display: block; display: block;
margin: 0 auto; margin: 0 auto;
width: 200px; width: 200px;
height: 50px; height: 50px;
font-size: 16px; font-size: 16px;
} }
......
src/plot_axe1_axe2.png

15.6 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment