library(readxl)
library(ggplot2)
library(CGPfunctions)
library(ggplot2)
library(plotly)
library(lmtest)
#Definir directorio
setwd("G:/TRABAJO/CONSULTORIAS/TRABAJOS VARIOS/JORGE CHAVARRIA/analisis2")
data1 = read_excel("Bicuspid.xlsx")
head(data1,5)
ANALISIS RELATIVE STENT EXPANSION
# Función para agregar coeficientes de correlación
panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...) {
usr <- par("usr")
on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
Cor <- abs(cor(x, y)) # Elimina la función abs si lo prefieres
txt <- paste0(prefix, format(c(Cor, 0.123456789), digits = digits)[1])
if(missing(cex.cor)) {
cex.cor <- 0.4 / strwidth(txt)
}
text(0.5, 0.5, txt,
cex = 1 + cex.cor * Cor) # Escala el texto al nivel de correlación
}
#Matriz de Correlación Respecto a Relative Stent Expansion
pairs(~ RelativeStentExpansion + MaxSinAnnDcalc + MinSinusAnnDcalc + CCV,
upper.panel = panel.cor,
lower.panel = panel.smooth,data = data1)
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
#Relacion entre Maximum Sinus Diameter Indexed vs Relative Stent Expansion %
g1=ggplot(data=data1,mapping=
aes(x=MaxSinAnnDcalc,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g1 + labs(title = "Relative Stent Expansion % vs Maximum Sinus Diameter Indexed",
x = "Maximum Sinus Diameter Indexed",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
#Relacion entre Minimun Sinus Diameter Indexed vs Relative Stent Expansion %
g2=ggplot(data=data1,mapping=
aes(x=MinSinusAnnDcalc,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g2 + labs(title = "Relative Stent Expansion % vs Minimun Sinus Diameter Indexed",
x = "Minimun Sinus Diameter Indexed",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
#Relacion entre CONTRAST CALCIUM VOLUME vs Relative Stent Expansion %
g3=ggplot(data=data1,mapping=
aes(x=CCV,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g3 + labs(title = "Relative Stent Expansion % vs Contrast Calcium Volume",
x = "Contrast Calcium Volume",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
#Relacion entre Postdilatation vs Relative Stent Expansion %
boxplot(data1$RelativeStentExpansion~data1$Postdilation,
xlab = 'Postdilation',
ylab = 'Relative Stent Expansion %',
title=('Postdilatation vs Relative Stent Expansion %'),
col= 'bisque')
ggplot(data = data1) + geom_density(aes(x=RelativeStentExpansion,fill=factor(Postdilation)),
bins=10, position = "identity",alpha = 0.5)
Warning: Ignoring unknown parameters: bins
#Relacion entre Raphe Calcification vs Relative Stent Expansion %
boxplot(data1$RelativeStentExpansion~data1$Raphaecalcification,
xlab = 'Raphae Calcification',
ylab = 'Relative Stent Expansion %',
title=('Raphae Calcification vs Relative Stent Expansion %'),
col= 'ivory')
ggplot(data = data1) + geom_density(aes(x=RelativeStentExpansion,fill=factor(Raphaecalcification)),
bins=10, position = "identity",alpha = 0.5)
Warning: Ignoring unknown parameters: bins
#Relacion entre AVAi vs Relative Stent Expansion %
g4=ggplot(data=data1,mapping=
aes(x=AVAi,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g4 + labs(title = "Relative Stent Expansion % vs AVAi",
x = "AVAi",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
Warning: Removed 26 rows containing non-finite values (stat_smooth).
Warning: Removed 26 rows containing missing values (geom_point).
#Relacion entre Mean Gradient (mmHg) vs Relative Stent Expansion %
g5=ggplot(data=data1,mapping=
aes(x=MeanGradientmmHg,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g5 + labs(title = "Relative Stent Expansion % vs Mean Gradient (mmHg)",
x = "Mean Gradient (mmHg)",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
#Regresion inicial
mod1=lm(RelativeStentExpansion ~ MaxSinAnnDcalc + MinSinusAnnDcalc + Postdilation +CCV + Raphaecalcification,
data = data1)
summary(mod1)
Call:
lm(formula = RelativeStentExpansion ~ MaxSinAnnDcalc + MinSinusAnnDcalc +
Postdilation + CCV + Raphaecalcification, data = data1)
Residuals:
Min 1Q Median 3Q Max
-0.096436 -0.011235 0.003484 0.019744 0.066353
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.499e-01 4.013e-02 21.178 < 2e-16 ***
MaxSinAnnDcalc -5.700e-03 3.044e-02 -0.187 0.851864
MinSinusAnnDcalc 4.679e-02 3.740e-02 1.251 0.213979
Postdilation 2.651e-02 7.364e-03 3.600 0.000508 ***
CCV 3.406e-06 5.278e-06 0.645 0.520271
Raphaecalcification -4.582e-03 6.782e-03 -0.676 0.500935
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.03043 on 95 degrees of freedom
Multiple R-squared: 0.1468, Adjusted R-squared: 0.1019
F-statistic: 3.27 on 5 and 95 DF, p-value: 0.009087
#Modelo binario
mod2 <- glm(RSEcalc ~ MaxSinAnnDcalc + MinSinusAnnDcalc +
Postdilation + CCV + Raphaecalcification,
data = data1, family = "binomial")
summary(mod2)
Call:
glm(formula = RSEcalc ~ MaxSinAnnDcalc + MinSinusAnnDcalc + Postdilation +
CCV + Raphaecalcification, family = "binomial", data = data1)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.9256 -1.2399 0.5795 1.0343 1.2307
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.5695037 3.0095653 -0.854 0.393
MaxSinAnnDcalc 0.6706370 2.1665003 0.310 0.757
MinSinusAnnDcalc 1.5877584 2.6703586 0.595 0.552
Postdilation 1.5656236 0.6674808 2.346 0.019 *
CCV -0.0001900 0.0003786 -0.502 0.616
Raphaecalcification 0.2157918 0.4809451 0.449 0.654
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 132.71 on 100 degrees of freedom
Residual deviance: 123.99 on 95 degrees of freedom
AIC: 135.99
Number of Fisher Scoring iterations: 4
ANALISIS Ellipticity
#Matriz de Correlación Respecto a Relative Stent Expansion
pairs(~ Ellipticity + MaxSinAnnDcalc + MinSinusAnnDcalc + CCV,
upper.panel = panel.cor,
lower.panel = panel.smooth,data = data1)
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
Warning in par(usr) : argument 1 does not name a graphical parameter
#Relacion entre Maximum Sinus Diameter Indexed vs Ellipticity
g6=ggplot(data=data1,mapping=
aes(x=MaxSinAnnDcalc,y=Ellipticity,))+geom_point()+theme_bw()+
geom_smooth(method="lm")
g6 + labs(title = "Ellipticity vs Maximum Sinus Diameter Indexed",
x = "Maximum Sinus Diameter Indexed",
y= "Ellipticity")
`geom_smooth()` using formula 'y ~ x'
#Relacion entre Minimun Sinus Diameter Indexed vs Ellipticity
g7=ggplot(data=data1,mapping=
aes(x=MinSinusAnnDcalc,y=Ellipticity,))+geom_point()+theme_bw()+
geom_smooth(method="lm")
g7 + labs(title = "Ellipticity vs Minimun Sinus Diameter Indexed",
x = "Minimun Sinus Diameter Indexed",
y= "Ellipticity")
`geom_smooth()` using formula 'y ~ x'
#Relacion entre CONTRAST CALCIUM VOLUME vs Ellipticity
g8=ggplot(data=data1,mapping=
aes(x=CCV,y=Ellipticity,))+geom_point()+theme_bw()+
geom_smooth(method="lm")
g8 + labs(title = "Ellipticity vs Contrast Calcium Volume",
x = "",
y= "Ellipticity")
`geom_smooth()` using formula 'y ~ x'
#Relacion entre AVAi vs Ellipticity
g9=ggplot(data=data1,mapping=
aes(x=AVAi,y=Ellipticity,))+geom_point()+theme_bw()+
geom_smooth(method="lm")
g9 + labs(title = "Ellipticity vs AVAi",
x = "AVAi",
y= "Ellipticity")
`geom_smooth()` using formula 'y ~ x'
Warning: Removed 26 rows containing non-finite values (stat_smooth).
Warning: Removed 26 rows containing missing values (geom_point).
#Relacion entre Mean Gradient (mmHg) vs Ellipticity
g10=ggplot(data=data1,mapping=
aes(x=MeanGradientmmHg,y=Ellipticity,))+geom_point()+theme_bw()+
geom_smooth(method="lm")
g10 + labs(title = "Ellipticity vs Mean Gradient (mmHg)",
x = "Mean Gradient (mmHg)",
y= "Ellipticity")
`geom_smooth()` using formula 'y ~ x'
#Relacion entre Postdilatation vs Ellipticity
boxplot(data1$Ellipticity~data1$Postdilation,
xlab = 'Postdilation',
ylab = 'Ellipticity',
title=('Postdilatation vs Ellipticity'),
col= 'bisque')
ggplot(data = data1) + geom_density(aes(x=Ellipticity,fill=factor(Postdilation)),
bins=10, position = "identity",alpha = 0.5)
Warning: Ignoring unknown parameters: bins
#Relacion entre Raphe Calcification vs Ellipticity
boxplot(data1$Ellipticity~data1$Raphaecalcification,
xlab = 'Raphae Calcification',
ylab = 'Ellipticity',
title=('Raphae Calcification vs Ellipticity'),
col= 'ivory')
ggplot(data = data1) + geom_density(aes(x=Ellipticity,fill=factor(Raphaecalcification)),
bins=10, position = "identity",alpha = 0.5)
Warning: Ignoring unknown parameters: bins
#Regresion inicial
mod3=lm(Ellipticity ~ MaxSinAnnDcalc + MinSinusAnnDcalc + Postdilation +CCV + Raphaecalcification,
data = data1)
summary(mod3)
Call:
lm(formula = Ellipticity ~ MaxSinAnnDcalc + MinSinusAnnDcalc +
Postdilation + CCV + Raphaecalcification, data = data1)
Residuals:
Min 1Q Median 3Q Max
-0.074869 -0.032489 -0.001692 0.022949 0.107501
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.069e+00 5.200e-02 20.563 <2e-16 ***
MaxSinAnnDcalc -1.618e-02 3.944e-02 -0.410 0.6827
MinSinusAnnDcalc 3.080e-02 4.846e-02 0.636 0.5266
Postdilation -1.026e-02 9.541e-03 -1.075 0.2851
CCV 3.804e-06 6.839e-06 0.556 0.5793
Raphaecalcification 1.522e-02 8.788e-03 1.732 0.0865 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.03943 on 95 degrees of freedom
Multiple R-squared: 0.06378, Adjusted R-squared: 0.01451
F-statistic: 1.294 on 5 and 95 DF, p-value: 0.2729
#Modelo binario
mod4 <- glm(Ellipticitycalc ~ MaxSinAnnDcalc + MinSinusAnnDcalc +
Postdilation + CCV + Raphaecalcification,
data = data1, family = "binomial")
summary(mod4)
Call:
glm(formula = Ellipticitycalc ~ MaxSinAnnDcalc + MinSinusAnnDcalc +
Postdilation + CCV + Raphaecalcification, family = "binomial",
data = data1)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.4406 -1.0762 -0.8559 1.1592 1.5535
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.795e+00 2.739e+00 1.021 0.307
MaxSinAnnDcalc -4.545e-01 2.061e+00 -0.221 0.825
MinSinusAnnDcalc -2.122e+00 2.534e+00 -0.838 0.402
Postdilation -4.690e-01 5.048e-01 -0.929 0.353
CCV 6.213e-05 3.594e-04 0.173 0.863
Raphaecalcification 5.670e-01 4.601e-01 1.232 0.218
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 139.53 on 100 degrees of freedom
Residual deviance: 134.98 on 95 degrees of freedom
AIC: 146.98
Number of Fisher Scoring iterations: 4
Mean gradient analysis
#Relacion entre Mean gradient analysis vs RSE calc
boxplot(data1$MeanGradientmmHg~data1$RSEcalc,
xlab = 'Relative Stent Expansion >90%',
ylab = 'Mean Gradient (mmHg)',
title=('Mean Gradient (mmHg) vs Relative Stent Expansion >90%'),
col= '#87CEFA')
ggplot(data = data1) + geom_density(aes(x=MeanGradientmmHg,fill=factor(RSEcalc)),
bins=10, position = "identity",alpha = 0.5)
Warning: Ignoring unknown parameters: bins
#Relacion entre Mean Gradient (mmHg) vs Relative Stent Expansion %
g11=ggplot(data=data1,mapping=
aes(x=MeanGradientmmHg,y=RelativeStentExpansion,))+
geom_point(aes(colour = factor(Postdilation))) +theme_bw()+
geom_smooth(method = "lm", color="#838B8B", linetype="dashed", fill="#EEEEE0") +
scale_color_manual(values=c('#0000FF','#FF3030'))
g11 + labs(title = "Relative Stent Expansion % vs Mean Gradient (mmHg)",
x = "Mean Gradient (mmHg)",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
#Relacion entre Mean gradient analysis vs Ellipticity calc
boxplot(data1$MeanGradientmmHg~data1$Ellipticitycalc,
xlab = 'Ellipticity >1.1',
ylab = 'Mean Gradient (mmHg)',
title=('Mean Gradient (mmHg) vs Ellipticity >1.1'),
col= '#836FFF')
ggplot(data = data1) + geom_density(aes(x=MeanGradientmmHg,fill=factor(Ellipticitycalc)),
bins=10, position = "identity",alpha = 0.5)
Warning: Ignoring unknown parameters: bins
#Relacion entre Mean Gradient (mmHg) vs Ellipticity
g12=ggplot(data=data1,mapping=
aes(x=MeanGradientmmHg,y=Ellipticity,))+
geom_point(aes(colour = factor(Postdilation))) +theme_bw()+
geom_smooth(method = "lm", color="#838B8B", linetype="dashed", fill="#EEEEE0") +
scale_color_manual(values=c('#0000FF','#FF3030'))
g12 + labs(title = "Ellipticity vs Mean Gradient (mmHg)",
x = "Mean Gradient (mmHg)",
y= "Ellipticity")
`geom_smooth()` using formula 'y ~ x'