grupo o-CIII y bigotes

eliminamos el grupo o-CIII de las gráficas de grupos de IMC
también ajustamos etiquetas de las gráficas y las gráficas de bigote
parent 1f23ea1b
...@@ -115,10 +115,28 @@ def imc_cat(datos): ...@@ -115,10 +115,28 @@ def imc_cat(datos):
def imc_cat_bigote(datos): def imc_cat_bigote(datos):
medidas = [ "glucose", "hba1c", "ct", "hdl", "insuline"] medidas = [ "glucose", "hba1c", "ct", "hdl", "insuline"]
grupos = ["LW","NW","OW","O-CI","O-CII","O-CIII"] grupos = ["LW","NW","OW","O-CI","O-CII"]
datos["imc_cat"] = pd.cut(datos["imc"], bins=[0,18,25,30,35,40,100], labels=grupos) datos["imc_cat"] = pd.cut(datos["imc"], bins=[0,18,25,30,35,40], labels=grupos)
figura = px.box(datos, x="imc_cat", y="glucose") # figura = px.box(datos, x="imc_cat", y="glucose")
return figura fig = make_subplots(rows=2, cols=3, vertical_spacing=0.25)
lcol = 1
lrow = 1
seq = 1
for medida in medidas:
fig.add_trace(
go.Box(x=datos["imc_cat"], y=datos[medida]),
row=lrow, col=lcol
)
fig['layout']['yaxis' + str(seq)]['title']=medida
lrow = lrow + (lcol // 3)
lcol = lcol + 1 if lcol < 3 else 1
seq = seq + 1
fig.update_xaxes(categoryorder='array', categoryarray=grupos)
fig.update_layout(
showlegend = False
)
return fig
...@@ -154,29 +172,37 @@ def correlaciones_v2(datos, controlado): ...@@ -154,29 +172,37 @@ def correlaciones_v2(datos, controlado):
return figura return figura
def controlado_ppgr(datos): def controlado_ppgr(datos):
datos_fil = datos.loc[datos["Glucosa"].notnull()]
controlados = ["Glucosa", "Gelatina", "Pan"] controlados = ["Glucosa", "Gelatina", "Pan"]
figura = make_subplots(rows=1, cols=3, subplot_titles=controlados) datos_fil = datos[controlados]
datos_fil["id"] = datos["id"]
datos_fil = datos_fil[~datos_fil.isnull().any(axis=1)]
fig = make_subplots(rows=1, cols=3)
lcol = 1 lcol = 1
seq = 1
for controlado in controlados: for controlado in controlados:
figura.add_trace( fig.add_trace(
go.Scatter(x=datos["id"],y=datos[controlado], name=controlado, mode="markers"), go.Scatter(x=datos_fil["id"],y=datos_fil[controlado], name=controlado, mode="markers"),
row = 1, col = lcol row = 1, col = lcol
) )
fig['layout']['yaxis' + str(seq)]['title']=controlado
fig['layout']['xaxis' + str(seq)]['title']="Patient ID"
lcol = lcol + 1 lcol = lcol + 1
figura.update_layout( seq = seq + 1
fig.update_layout(
showlegend = False, showlegend = False,
bargap=0.05, # gap between bars of adjacent location coordinates
bargroupgap=0.05 # gap between bars of the same location coordinates
) )
return figura return fig
def controlado_ppgr2(datos): def controlado_ppgr2(datos):
controlados = ["Glucosa", "Gelatina", "Pan"] controlados = ["Glucosa", "Gelatina", "Pan"]
datos_fil = datos[controlados] datos_fil = datos[controlados]
datos_fil = datos_fil[~datos_fil.isnull().any(axis=1)] datos_fil = datos_fil[~datos_fil.isnull().any(axis=1)]
figura = ff.create_distplot([ datos_fil[controlado] for controlado in controlados], controlados, show_hist = False, show_rug=False) figura = ff.create_distplot([ datos_fil.loc[datos_fil[controlado]!=0, controlado] for controlado in controlados], controlados, show_hist=False, show_rug=False)
figura.update(layout_title_text='Kernel Density Estimation')
figura["layout"]["xaxis"]["title"] = "iAUC"
return figura return figura
def triareas(pacientes): def triareas(pacientes):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment