Multivariate Data For sPCA and sPLS-DA
database <- textshape::column_to_rownames(database, loc = 1)
spinach <- as.data.frame(database)
spinach <- subset(spinach, select= -c(Class))
X <- spinach
Y <- database$Class
dim(X)
## [1] 30 26
“Sparse Principal Component Analysis” sPCA
explainedVariance <- tune.pca(X, ncomp = 10, center = TRUE, scale = TRUE)
plot(explainedVariance)

test.keepX <- c(seq(26))
tune.spca.res <- tune.spca(X, ncomp = 3,
nrepeat = 5,
folds = 10,
test.keepX = test.keepX)
plot(tune.spca.res)

spca <- spca(X, ncomp = 3,
scale = TRUE,
center = TRUE)
plotIndiv(spca, comp = c(1, 2), ind.names = TRUE,
group = database$Class,
ellipse = TRUE,
cutoff = 0.5,
size.title = 15,
size.legend = 15,
size.xlabel = 15,
size.ylabel = 15,
col = c("red", "green", "blue"),
legend = TRUE, title = 'Magnesium stress in Spinach')

plotVar(spca, comp = c(1, 2), var.names = TRUE,
cutoff = 0,
rad.in = 1,
title = 'Magnesium stress in spinach')

biplot(spca, cex = 1,
group = database$Class,
pch.size = 5,
cutoff = 0.5,
size.legend = 20,
size.xlabel = 20,
size.ylabel = 20,
col = c("red", "green", "blue"),
title = 'Magnesium stress Spinach')

plotLoadings(spca, comp = 1,
size.title = 1,
size.name = 1,
size.axis = 1,
ncomp = 26)

plotLoadings(spca, comp = 2,
size.title = 1,
size.name = 1,
size.axis = 1,
ncomp = 26)

“Sparse Partial Least Squares-Discriminant Analysis” sPLS-DA
splsda <- splsda(X, Y, ncomp = 10, scale = TRUE)
set.seed(30)
plotIndiv(splsda, comp = c(1, 2), ind.names = TRUE,
group = database$Class,
ellipse = TRUE,
cutoff = 0.5,
size.title = 15,
size.legend = 15,
size.xlabel = 15,
size.ylabel = 15,
col = c("red", "green", "blue"),
legend = TRUE, title = 'Magnesium stress in Spinach')

perf.splsda <- perf(splsda, validation = "Mfold",
folds = 5, nrepeat = 50,
progressBar = FALSE, auc = TRUE)
plot(perf.splsda, sd = TRUE, legend.position = "vertical")

perf.splsda$choice.ncomp
## max.dist centroids.dist mahalanobis.dist
## overall 6 3 6
## BER 6 3 6
tune.splsda <- tune.splsda(X, Y, ncomp = 4,
validation = 'Mfold',
folds = 5, nrepeat = 50,
dist = 'max.dist',
test.keepX = c (5, 10, 15, 20, 26),
measure = "BER")
plot(tune.splsda)

final.splsda <- splsda(X, Y, ncomp = 3, keepX = c(5, 5) , scale = TRUE)
plotIndiv(final.splsda, comp = c(1, 2), ind.names = TRUE,
group = database$Class,
ellipse = TRUE,
cutoff = 0.5,
size.title = 15,
size.legend = 15,
size.xlabel = 15,
size.ylabel = 15,
col = c("red", "green", "blue"),
legend = TRUE, title = 'Magnesium stress in Spinach')

plotVar(final.splsda, comp = c(1, 2), var.names = TRUE,
cutoff = 0,
rad.in = 1,
title = 'Magnesium stress in spinach')

biplot(final.splsda, cex = 1,
group = database$Class,
pch.size = 5,
cutoff = 0,
size.legend = 20,
size.xlabel = 20,
size.ylabel = 20,
col = c("red", "green", "blue"),
title = 'Magnesium stress in Spinach')

plotLoadings(final.splsda, comp = 1,
size.title = 1,
size.name = 1)

plotLoadings(final.splsda, comp = 2,
size.title = 1,
size.name = 1)

sPLS-DA model evaluation
perf.res <- perf.assess(final.splsda, dist = "max.dist",
validation = "Mfold",
folds = 5,
nrepeat = 50)
perf.res$error.rate$overall[,'max.dist']
## [1] 0.2153333
perf.res$error.rate.class$max.dist
## Deficiency Excess Standard
## 0.340 0.278 0.028
summary(Y)
## Length N.unique N.blank Min.nchar Max.nchar
## 30 3 0 6 10
perf.res$error.rate$BER[,'max.dist']
## [1] 0.2153333
auc.plsda <- auroc(final.splsda, roc.comp = 4, print = FALSE)
Analysis of Variance ANOVA for 10 most important variables
ANOVATest.data <- read.csv("C:/Users/cesar/Desktop/ESPINACA MAESTRÍA/TRATAMIENTOS/Magnesio/Magnesio Espinaca Anovas.csv")
attach(ANOVATest.data)
str(ANOVATest.data)
## 'data.frame': 30 obs. of 28 variables:
## $ Sample : int 1 2 3 4 5 6 7 8 9 10 ...
## $ Condition : chr "Standard" "Standard" "Standard" "Standard" ...
## $ Valine : num 252.2 48.9 58.7 93.5 84.8 ...
## $ Alanine : num 408.3 88.1 87.8 158.8 146.3 ...
## $ GABA : num 1507 146 237 371 272 ...
## $ Glutamate : num 1330 401 590 532 492 ...
## $ Malate : num 88.8 36 143.9 106 42.9 ...
## $ Succinate : num 61.4 8.1 28.6 17.2 14.5 ...
## $ Citrate : num 157.1 47.1 211.7 171.2 57.6 ...
## $ Aspartate : num 898 192 143 322 342 ...
## $ Betaine : num 1846 374 687 762 557 ...
## $ Glucose : num 250.7 89.8 161.1 167.5 150.7 ...
## $ Fructose : num 275.7 67.6 162.6 145.2 106.2 ...
## $ Sucrose : num 45.2 40.7 42.8 29 21.6 ...
## $ Ascorbate : num 876.7 76.5 123.9 45.2 113.7 ...
## $ Uridine : num 330.7 58.4 95.1 132.9 114.4 ...
## $ Adenosine : num 385 52.7 85.2 96.1 99.9 ...
## $ Fumarate : num 37.3 18.6 35.3 35.5 21.6 58.3 17.4 16.2 30 29.2 ...
## $ Tyrosine : num 101 31.9 32.7 59 49.1 65.9 37.1 32.2 60.9 60 ...
## $ Phenylalanine: num 104.3 37 37.1 71.7 51.9 ...
## $ Guanosine : num 361.7 58.4 97.8 139.4 111 ...
## $ Formate : num 137.7 35.9 53.6 50.6 70.1 ...
## $ Choline : num 569.8 91.5 107.6 207 178.4 ...
## $ Ferulate : num 75.4 14.9 26.8 30.1 27.9 25.9 36.1 31.2 60.5 58.6 ...
## $ Glycerol : num 429.8 97.6 138.4 170.8 158.7 ...
## $ Isoleucine : num 154.5 31.1 43.4 55.8 49.5 ...
## $ Leucine : num 279.5 74.8 89.1 134.7 103 ...
## $ p.Cumarate : num 64 5.5 9.2 12 19.5 20.2 19 15.7 37.8 31 ...
GABA
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(GABA[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: GABA[Condition == "Standard"]
## W = 0.74473, p-value = 0.003078
with(ANOVATest.data, shapiro.test(GABA[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: GABA[Condition == "Deficiency"]
## W = 0.87848, p-value = 0.1253
with(ANOVATest.data, shapiro.test(GABA[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: GABA[Condition == "Excess"]
## W = 0.82517, p-value = 0.02926
Hm_var <- bartlett.test(GABA ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: GABA by Condition
## Bartlett's K-squared = 3.2936, df = 2, p-value = 0.1927
#### ONE WAY - ANOVA
OneWay_test <- aov(GABA ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 2303668 1151834 4.552 0.0198 *
## Residuals 27 6831841 253031
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = GABA ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 458.45 -99.31556 1016.2156 0.1224463
## Standard-Deficiency -204.27 -762.03556 353.4956 0.6399837
## Standard-Excess -662.72 -1220.48556 -104.9544 0.0174425
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = GABA , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

Alanine
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Alanine[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Alanine[Condition == "Standard"]
## W = 0.84195, p-value = 0.04656
with(ANOVATest.data, shapiro.test(Alanine[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Alanine[Condition == "Deficiency"]
## W = 0.8615, p-value = 0.07947
with(ANOVATest.data, shapiro.test(Alanine[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Alanine[Condition == "Excess"]
## W = 0.81621, p-value = 0.0228
Hm_var <- bartlett.test(Alanine ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Alanine by Condition
## Bartlett's K-squared = 8.3228, df = 2, p-value = 0.01559
#### ONE WAY - ANOVA
OneWay_test <- aov(Alanine ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 277799 138899 5.026 0.0139 *
## Residuals 27 746116 27634
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Alanine ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 165.25 -19.07575 349.57575 0.0853098
## Standard-Deficiency -62.94 -247.26575 121.38575 0.6778003
## Standard-Excess -228.19 -412.51575 -43.86425 0.0130078
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Alanine , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

Valine
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Valine[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Valine[Condition == "Standard"]
## W = 0.81302, p-value = 0.02086
with(ANOVATest.data, shapiro.test(Valine[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Valine[Condition == "Deficiency"]
## W = 0.91423, p-value = 0.3114
with(ANOVATest.data, shapiro.test(Valine[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Valine[Condition == "Excess"]
## W = 0.748, p-value = 0.003374
Hm_var <- bartlett.test(Valine ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Valine by Condition
## Bartlett's K-squared = 13.183, df = 2, p-value = 0.001372
#### ONE WAY - ANOVA
OneWay_test <- aov(Valine ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 348389 174194 8.231 0.00162 **
## Residuals 27 571433 21164
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Valine ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 164.93 3.618443 326.24156 0.0443298
## Standard-Deficiency -96.02 -257.331557 65.29156 0.3180392
## Standard-Excess -260.95 -422.261557 -99.63844 0.0012124
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Valine , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

Phenylalanine
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Phenylalanine[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Phenylalanine[Condition == "Standard"]
## W = 0.87191, p-value = 0.1052
with(ANOVATest.data, shapiro.test(Phenylalanine[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Phenylalanine[Condition == "Deficiency"]
## W = 0.87001, p-value = 0.1
with(ANOVATest.data, shapiro.test(Phenylalanine[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Phenylalanine[Condition == "Excess"]
## W = 0.77531, p-value = 0.007259
Hm_var <- bartlett.test(Phenylalanine ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Phenylalanine by Condition
## Bartlett's K-squared = 15.518, df = 2, p-value = 0.0004269
#### ONE WAY - ANOVA
OneWay_test <- aov(Phenylalanine ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 66063 33032 6.716 0.00429 **
## Residuals 27 132801 4919
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Phenylalanine ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 60.82 -16.94494 138.58494 0.1472060
## Standard-Deficiency -54.06 -131.82494 23.70494 0.2149225
## Standard-Excess -114.88 -192.64494 -37.11506 0.0029817
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Phenylalanine , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

Glycerol
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Glycerol[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Glycerol[Condition == "Standard"]
## W = 0.87963, p-value = 0.1292
with(ANOVATest.data, shapiro.test(Glycerol[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Glycerol[Condition == "Deficiency"]
## W = 0.87424, p-value = 0.112
with(ANOVATest.data, shapiro.test(Glycerol[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Glycerol[Condition == "Excess"]
## W = 0.87163, p-value = 0.1044
Hm_var <- bartlett.test(Glycerol ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Glycerol by Condition
## Bartlett's K-squared = 7.8601, df = 2, p-value = 0.01964
#### ONE WAY - ANOVA
OneWay_test <- aov(Glycerol ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 408102 204051 5.381 0.0108 *
## Residuals 27 1023887 37922
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Glycerol ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 149.74 -66.18795 365.66795 0.2164462
## Standard-Deficiency -135.84 -351.76795 80.08795 0.2800185
## Standard-Excess -285.58 -501.50795 -69.65205 0.0078123
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Glycerol , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

Formate
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Formate[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Formate[Condition == "Standard"]
## W = 0.72287, p-value = 0.001669
with(ANOVATest.data, shapiro.test(Formate[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Formate[Condition == "Deficiency"]
## W = 0.8994, p-value = 0.2158
with(ANOVATest.data, shapiro.test(Formate[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Formate[Condition == "Excess"]
## W = 0.79429, p-value = 0.01236
Hm_var <- bartlett.test(Formate ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Formate by Condition
## Bartlett's K-squared = 3.384, df = 2, p-value = 0.1841
#### ONE WAY - ANOVA
OneWay_test <- aov(Formate ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 299 149.5 0.202 0.819
## Residuals 27 20031 741.9
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Formate ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency -1.44 -31.64162 28.76162 0.9923270
## Standard-Deficiency 5.86 -24.34162 36.06162 0.8807923
## Standard-Excess 7.30 -22.90162 37.50162 0.8216674
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Formate , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

Sucrose
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Sucrose[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Sucrose[Condition == "Standard"]
## W = 0.70463, p-value = 0.001002
with(ANOVATest.data, shapiro.test(Sucrose[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Sucrose[Condition == "Deficiency"]
## W = 0.91812, p-value = 0.3416
with(ANOVATest.data, shapiro.test(Sucrose[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Sucrose[Condition == "Excess"]
## W = 0.88536, p-value = 0.1502
Hm_var <- bartlett.test(Sucrose ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Sucrose by Condition
## Bartlett's K-squared = 63.292, df = 2, p-value = 1.804e-14
#### ONE WAY - ANOVA
OneWay_test <- aov(Sucrose ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 46329841 23164921 11.31 0.000271 ***
## Residuals 27 55307184 2048414
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Sucrose ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 1918.27 331.2822 3505.2578 0.0154613
## Standard-Deficiency -1087.73 -2674.7178 499.2578 0.2237847
## Standard-Excess -3006.00 -4592.9878 -1419.0122 0.0001978
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Sucrose , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

Malate
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Malate[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Malate[Condition == "Standard"]
## W = 0.86604, p-value = 0.08986
with(ANOVATest.data, shapiro.test(Malate[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Malate[Condition == "Deficiency"]
## W = 0.91902, p-value = 0.3489
with(ANOVATest.data, shapiro.test(Malate[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Malate[Condition == "Excess"]
## W = 0.88978, p-value = 0.1686
Hm_var <- bartlett.test(Malate ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Malate by Condition
## Bartlett's K-squared = 37.472, df = 2, p-value = 7.297e-09
#### ONE WAY - ANOVA
OneWay_test <- aov(Malate ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 3447188 1723594 11.01 0.000319 ***
## Residuals 27 4226439 156535
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Malate ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 545.13 106.4275 983.8325 0.0126548
## Standard-Deficiency -269.84 -708.5425 168.8625 0.2953762
## Standard-Excess -814.97 -1253.6725 -376.2675 0.0002517
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Malate , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

Glucose
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Glucose[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Glucose[Condition == "Standard"]
## W = 0.92417, p-value = 0.3931
with(ANOVATest.data, shapiro.test(Glucose[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Glucose[Condition == "Deficiency"]
## W = 0.93083, p-value = 0.4561
with(ANOVATest.data, shapiro.test(Glucose[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Glucose[Condition == "Excess"]
## W = 0.87094, p-value = 0.1025
Hm_var <- bartlett.test(Glucose ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Glucose by Condition
## Bartlett's K-squared = 60.722, df = 2, p-value = 6.521e-14
#### ONE WAY - ANOVA
OneWay_test <- aov(Glucose ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 212186595 106093297 18.56 8.5e-06 ***
## Residuals 27 154348876 5716625
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Glucose ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 4027.13 1375.978 6678.2815 0.0022867
## Standard-Deficiency -2420.92 -5072.072 230.2315 0.0784773
## Standard-Excess -6448.05 -9099.202 -3796.8985 0.0000057
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Glucose , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

p-Cumarate
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(p.Cumarate[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: p.Cumarate[Condition == "Standard"]
## W = 0.8493, p-value = 0.05699
with(ANOVATest.data, shapiro.test(p.Cumarate[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: p.Cumarate[Condition == "Deficiency"]
## W = 0.72097, p-value = 0.001583
with(ANOVATest.data, shapiro.test(p.Cumarate[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: p.Cumarate[Condition == "Excess"]
## W = 0.82944, p-value = 0.03294
Hm_var <- bartlett.test(p.Cumarate ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: p.Cumarate by Condition
## Bartlett's K-squared = 1.74, df = 2, p-value = 0.4189
#### ONE WAY - ANOVA
OneWay_test <- aov(p.Cumarate ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 566 283.1 1.237 0.306
## Residuals 27 6180 228.9
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = p.Cumarate ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 10.59 -6.185797 27.3658 0.2776908
## Standard-Deficiency 6.20 -10.575797 22.9758 0.6348499
## Standard-Excess -4.39 -21.165797 12.3858 0.7946027
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = p.Cumarate , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()
