Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
inventario
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jose Luis Gordillo Ruiz
inventario
Commits
36cbcb1b
Commit
36cbcb1b
authored
Feb 05, 2025
by
Jose Luis Gordillo Ruiz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajustes en las gráficas de iaucs y distr. de comidas reportadas
parent
8e2c3fc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
37 deletions
+85
-37
estadisticas.py
+85
-37
No files found.
estadisticas.py
View file @
36cbcb1b
...
...
@@ -220,49 +220,91 @@ def triareas(pacientes):
)
return
figura
def
comidas_
dato
s
(
datos
):
columnas
=
[
"
hc_total"
,
"kcal_total"
,
"fiber_total"
,
"protein_total"
,
"pre-AUC"
,
"post-AUC"
,
"iAUC"
,
"N-alimentos
"
]
def
comidas_
iauc
s
(
datos
):
columnas
=
[
"
pre-AUC"
,
"post-AUC"
,
"iAUC
"
]
datos
[
"N-alimentos"
]
=
datos
[
"foods"
]
.
apply
(
lambda
x
:
len
(
x
))
figura
=
make_subplots
(
cols
=
4
,
rows
=
2
,
shared_xaxes
=
True
,
vertical_spacing
=
0.1
,
subplot_titles
=
columnas
)
lrow
=
1
fig
=
make_subplots
(
cols
=
3
,
rows
=
1
,
vertical_spacing
=
0.25
)
lcol
=
1
seq
=
1
for
columna
in
columnas
:
datosfil
=
datos
[
np
.
abs
(
stats
.
zscore
(
datos
[
columna
],
nan_policy
=
'omit'
))
<
3
]
fig
.
add_trace
(
go
.
Scatter
(
y
=
datosfil
[
columna
],
name
=
columna
,
mode
=
"markers"
),
row
=
1
,
col
=
lcol
)
fig
[
'layout'
][
'yaxis'
+
str
(
seq
)][
'title'
]
=
columna
fig
[
'layout'
][
'xaxis'
+
str
(
seq
)][
'title'
]
=
"Comida ID"
seq
=
seq
+
1
lcol
=
lcol
+
1
fig
.
update_layout
(
showlegend
=
False
)
return
fig
def
comidas_iauc_describe
(
datos
):
columnas
=
[
"pre-AUC"
,
"post-AUC"
,
"iAUC"
]
fig
=
make_subplots
(
cols
=
3
,
rows
=
1
,
vertical_spacing
=
0.25
)
seq
=
1
lcol
=
1
for
columna
in
columnas
:
datosfil
=
datos
[
np
.
abs
(
stats
.
zscore
(
datos
[
columna
],
nan_policy
=
'omit'
))
<
3
]
fig
.
add_trace
(
go
.
Histogram
(
x
=
datosfil
[
columna
],
name
=
columna
),
row
=
1
,
col
=
lcol
)
fig
[
'layout'
][
'yaxis'
+
str
(
seq
)][
'title'
]
=
columna
seq
=
seq
+
1
lcol
=
lcol
+
1
fig
.
update_layout
(
showlegend
=
False
,
bargap
=
0.05
,
# gap between bars of adjacent location coordinates
bargroupgap
=
0.05
# gap between bars of the same location coordinates
)
return
fig
def
comidas_macro_contenido
(
datos
):
columnas
=
[
"hc_total"
,
"lipids_total"
,
"fiber_total"
,
"protein_total"
]
datos
[
"N-alimentos"
]
=
datos
[
"foods"
]
.
apply
(
lambda
x
:
len
(
x
))
figura
=
make_subplots
(
cols
=
4
,
rows
=
1
,
vertical_spacing
=
0.24
)
lcol
=
1
seq
=
1
for
columna
in
columnas
:
datosfil
=
datos
[
np
.
abs
(
stats
.
zscore
(
datos
[
columna
],
nan_policy
=
'omit'
))
<
3
]
figura
.
add_trace
(
go
.
Scatter
(
y
=
datosfil
[
columna
],
name
=
columna
,
mode
=
"markers"
),
row
=
lrow
,
col
=
lcol
row
=
1
,
col
=
lcol
)
lrow
=
lrow
+
(
lcol
//
4
)
figura
[
'layout'
][
'yaxis'
+
str
(
seq
)][
'title'
]
=
columna
figura
[
'layout'
][
'xaxis'
+
str
(
seq
)][
'title'
]
=
"Comida ID"
seq
=
seq
+
1
lcol
=
lcol
+
1
if
lcol
<
4
else
1
figura
.
update_layout
(
showlegend
=
False
)
return
figura
def
comidas_describe
(
datos
):
columnas
=
[
"hc_total"
,
"kcal_total"
,
"fiber_total"
,
"protein_total"
,
"pre-AUC"
,
"post-AUC"
,
"iAUC"
,
"N-alimentos"
]
datos
[
"N-alimentos"
]
=
datos
[
"foods"
]
.
apply
(
lambda
x
:
len
(
x
))
print
(
datos
.
columns
)
figura
=
make_subplots
(
cols
=
4
,
rows
=
2
,
shared_yaxes
=
True
,
subplot_titles
=
columnas
)
lrow
=
1
def
comidas_macro_describe
(
datos
):
columnas
=
[
"hc_total"
,
"lipids_total"
,
"fiber_total"
,
"protein_total"
]
fig
=
make_subplots
(
cols
=
4
,
rows
=
1
,
vertical_spacing
=
0.25
)
seq
=
1
lcol
=
1
for
columna
in
columnas
:
datosfil
=
datos
[
np
.
abs
(
stats
.
zscore
(
datos
[
columna
],
nan_policy
=
'omit'
))
<
3
]
fig
ura
.
add_trace
(
fig
.
add_trace
(
go
.
Histogram
(
x
=
datosfil
[
columna
],
name
=
columna
),
row
=
lrow
,
col
=
lcol
row
=
1
,
col
=
lcol
)
lrow
=
lrow
+
(
lcol
//
4
)
fig
[
'layout'
][
'yaxis'
+
str
(
seq
)][
'title'
]
=
columna
seq
=
seq
+
1
lcol
=
lcol
+
1
if
lcol
<
4
else
1
fig
ura
.
update_layout
(
fig
.
update_layout
(
showlegend
=
False
,
bargap
=
0.05
,
# gap between bars of adjacent location coordinates
bargroupgap
=
0.05
# gap between bars of the same location coordinates
)
return
fig
ura
return
fig
def
comidas_porcentajes
(
datos
):
columnas
=
[
"hc_total"
,
"fiber_total"
,
"protein_total"
,
"lipids_total"
]
...
...
@@ -551,30 +593,37 @@ app.layout = html.Div(children=[
dcc
.
Graph
(
id
=
"figCorrelaciones"
)
]),
# correlaciones transpuesta
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"Relación de iAUC/Controlados con diversos índices (traspuesta)"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
correlaciones_v2
(
visitas_incluidos
,
"Glucosa"
))
]),
#
html.Div(children= [
#
html.Div(children= [html.H1("Relación de iAUC/Controlados con diversos índices (traspuesta)", className = "header-title2")]),
#
dcc.Graph(figure=correlaciones_v2(visitas_incluidos, "Glucosa"))
#
]),
# areas de tres pacientes
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"Ejemplos de iAUC de Glucosa"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
triareas
([
85
,
148
,
177
]))
]),
# heatmap
# # heatmap
# html.Div(children= [
# html.Div(children= [html.H1("Mapa de calor de iAUC/alimentos controlados", className = "header-title2")]),
# dcc.Graph(figure=heatmap(visitas_incluidos))
# ,]),
# datos de comidas
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"Mapa de calor de iAUC/alimentos controlados"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
heatmap
(
visitas_incluidos
))
html
.
Div
(
children
=
[
html
.
H1
(
"iAUCs de las comidas reportadas"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
comidas_iaucs
(
comidas
)),
dcc
.
Graph
(
figure
=
comidas_iauc_describe
(
comidas
))
,]),
# datos de comidas
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"
Macronutrientes / AUCs de
comidas"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
comidas_
datos
(
comidas
))
html
.
Div
(
children
=
[
html
.
H1
(
"
Contenido de macronutrientes de las
comidas"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
comidas_
macro_contenido
(
comidas
))
,]),
# descripcion de comidas
html
.
Div
(
children
=
[
html
.
Div
(
children
=
[
html
.
H1
(
"Distribución de Macronutrientes de comidas"
,
className
=
"header-title2"
)]),
dcc
.
Graph
(
figure
=
comidas_describe
(
comidas
))
dcc
.
Graph
(
figure
=
comidas_
macro_
describe
(
comidas
))
,]),
# descripcion de componentes de macronutrientes de comidas
html
.
Div
(
children
=
[
...
...
@@ -626,7 +675,7 @@ def update_correlacion(controlado):
datos_sorted
=
datos_fil
.
sort_values
(
by
=
controlado
,
ascending
=
True
)
datos_sorted
.
reset_index
(
inplace
=
True
)
metricas
=
[
"imc"
,
"age"
,
"glucose"
,
"hba1c"
]
figura
=
make_subplots
(
rows
=
2
,
cols
=
2
,
vertical_spacing
=
0.25
)
figura
=
make_subplots
(
rows
=
1
,
cols
=
4
,
vertical_spacing
=
0.25
)
lrow
=
1
lcol
=
1
seq
=
1
...
...
@@ -635,18 +684,17 @@ def update_correlacion(controlado):
figura
.
add_trace
(
go
.
Scatter
(
x
=
datos_sorted
.
index
,
y
=
datos_sorted
[
metrica
],
name
=
metrica
,
mode
=
'markers'
),
row
=
lrow
,
col
=
lcol
row
=
1
,
col
=
lcol
)
figura
.
add_trace
(
go
.
Scatter
(
x
=
datos_sorted
.
index
,
y
=
datos_sorted
[
metrica
]
.
rolling
(
5
)
.
mean
(),
name
=
"PM(5)"
),
row
=
lrow
,
col
=
lcol
row
=
1
,
col
=
lcol
)
corr
=
datos_sorted
[[
metrica
]]
.
corrwith
(
datos_sorted
[
controlado
])
.
values
[
0
]
figura
.
add_annotation
(
row
=
lrow
,
col
=
lcol
,
text
=
"R = "
+
"{:.2f}"
.
format
(
corr
))
figura
[
"layout"
][
'xaxis'
+
str
(
seq
)][
'title'
]
=
"Ranqueo de pacientes por
su iAUC de
"
+
controlado
figura
.
add_annotation
(
row
=
1
,
col
=
lcol
,
text
=
"R = "
+
"{:.2f}"
.
format
(
corr
))
figura
[
"layout"
][
'xaxis'
+
str
(
seq
)][
'title'
]
=
"Ranqueo de pacientes por
iAUC:
"
+
controlado
figura
[
"layout"
][
'yaxis'
+
str
(
seq
)][
'title'
]
=
metrica
lcol
=
lcol
+
1
if
lcol
<
2
else
1
lrow
=
lrow
+
(
lcol
%
2
)
lcol
=
lcol
+
1
seq
=
seq
+
1
figura
[
"layout"
][
"yaxis1"
][
"range"
]
=
[
15
,
45
]
figura
[
"layout"
][
"yaxis2"
][
"range"
]
=
[
17
,
80
]
...
...
@@ -654,7 +702,7 @@ def update_correlacion(controlado):
figura
[
"layout"
][
"yaxis4"
][
"range"
]
=
[
5
,
7
]
figura
.
update_layout
(
showlegend
=
False
)
figura
.
update_layout
(
height
=
600
,
width
=
800
)
#
figura.update_layout(height=600, width=800)
return
figura
if
__name__
==
"__main__"
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment