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
fa18b2c5
Commit
fa18b2c5
authored
Nov 30, 2024
by
Jose Luis Gordillo Ruiz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adicion de microbiota
parent
335d3cdb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
+31
-12
dinamyc.py
+31
-12
No files found.
dinamyc.py
View file @
fa18b2c5
...
...
@@ -5,17 +5,8 @@ import plotly.express as px
import
requests
import
numpy
as
np
#
fuentes de dato
s
#
algunos parámetros globale
s
url
=
'https://nutricion.c3.unam.mx/nd/'
data_o
=
(
pd
.
read_csv
(
"inventario.csv"
)
)
data_o
[
"paciente"
]
=
data_o
[
"paciente"
]
.
astype
(
"str"
)
+
"_p"
data_o
[
"Secuenciaciones"
]
=
0
# datos globales
Visitas_e
=
4
Etapas_e
=
3
Comidas_E1_e
=
42
...
...
@@ -33,6 +24,34 @@ esperados = {
"tolerancia"
:
3
}
def
get_visit_data
(
visitnumber
):
url_visitas
=
url
+
"/visits/"
+
str
(
visitnumber
)
+
"/patients-data/"
yaisons
=
requests
.
get
(
url_visitas
)
.
json
()[
"patient_data"
]
df
=
pd
.
json_normalize
(
yaisons
)
df
.
drop
([
"tolerance_curve_measure"
,
"id"
,
"name"
,
"patient_visit_id"
,
"visit_date"
],
inplace
=
True
,
axis
=
1
)
lista
=
[
{
cf
[
"controlled_food"
]:
cf
[
"increment_auc"
]
for
cf
in
yaison
[
"tolerance_curve_measure"
]
}
for
yaison
in
yaisons
]
df
.
rename
(
columns
=
lambda
x
:
x
.
split
(
"."
)[
1
]
if
"."
in
x
else
x
,
inplace
=
True
)
#df.drop(["patient_visit_id"], inplace=True, axis=0) #esta etiqueta aparece dos veces: dentro del primer nivel de json y dentro del json de sample
return
pd
.
concat
([
df
,
pd
.
DataFrame
(
lista
)],
axis
=
1
)
# fuentes de datos
# consulta online a la API para las visitas, que proporcionan la info de
# visitas y microbiota
visitas_datos
=
[
get_visit_data
(
visita
)
for
visita
in
range
(
1
,
Visitas_e
+
1
)]
print
(
visitas_data
[
0
]
.
columns
# la info de glucómetro y comidas es más compleja. por el momento, se estab armando
# la info offline.
data_o
=
(
pd
.
read_csv
(
"inventario.csv"
)
)
data_o
[
"paciente"
]
=
data_o
[
"paciente"
]
.
astype
(
"str"
)
+
"_p"
data_o
[
"Secuenciaciones"
]
=
0
Total_pacientes
=
len
(
data_o
.
index
)
data
=
data_o
.
loc
[
data_o
[
"incluido"
]]
Total_incluidos
=
len
(
data
)
...
...
@@ -372,7 +391,7 @@ def update_charts(etapaSel,min_comidas, min_glucosa, medidaDet, etapaDet, visita
# microbiota_data = data.query("MT >= @min_microbiota")
visitas_data
=
data
.
query
(
"Nvisitas >= 4"
)
microbiota_data
=
visitas_datos
[
etapaSel
-
1
][
"patient_visit_id"
]
.
count
()
multi
=
go
.
Figure
()
...
...
@@ -400,7 +419,7 @@ def update_charts(etapaSel,min_comidas, min_glucosa, medidaDet, etapaDet, visita
multi
.
add_trace
(
go
.
Indicator
(
value
=
100
*
len
(
microbiota_data
.
index
)
/
Total_incluidos
,
value
=
100
*
microbiota_data
/
Total_incluidos
,
# value = min_microbiota,
domain
=
{
'x'
:
[
0.25
,
1
],
'y'
:
[
0.6
,
0.7
]},
title
=
{
'text'
:
"Microbiota"
},
...
...
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