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 = 'Nitrogen stress in Spinach')

plotVar(spca, comp = c(1, 2), var.names = TRUE,
cutoff = 0,
rad.in = 1,
title = 'Nitrogen 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 = 'Nitrogen stress in 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 = 'Nitrogen 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 2 2 2
## BER 2 2 2
tune.splsda <- tune.splsda(X, Y, ncomp = 3,
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 = 2, keepX = c(16, 26) , 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 = 'Nitrogen stress in Spinach')

plotVar(final.splsda, comp = c(1, 2), var.names = TRUE,
cutoff = 0,
rad.in = 1,
title = 'Nitrogen 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 = 'Nitrogen 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.3346667
perf.res$error.rate.class$max.dist
## Deficiency Excess Standard
## 0.202 0.666 0.136
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.3346667
auc.plsda <- auroc(final.splsda, roc.comp = 2, print = FALSE)

Analysis of Variance ANOVA for 10 most important variables
ANOVATest.data <- read.csv("C:/Users/cesar/Desktop/ESPINACA MAESTRÍA/TRATAMIENTOS/Nitrógeno/Nitrógeno 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 144.7 64.1 104.2 146 72 ...
## $ Alanine : num 285.5 116.1 215.8 244.1 91.9 ...
## $ GABA : num 1041 432 535 1210 558 ...
## $ Glutamate : num 726 365 686 692 565 ...
## $ Malate : num 870 70 312 206 278 ...
## $ Succinate : num 125.4 23.5 56.5 54.4 57.3 ...
## $ Citrate : num 433.5 22.9 243.3 232.9 691.5 ...
## $ Aspartate : num 1037 372 608 552 304 ...
## $ Betaine : num 1853 506 1646 1612 928 ...
## $ Glucose : num 769 301 478 683 376 ...
## $ Fructose : num 767 295 556 630 352 ...
## $ Sucrose : num 902 187 501 800 407 ...
## $ Ascorbate : num 103.5 30.1 71.2 191.4 234.4 ...
## $ Uridine : num 225 120 137 208 106 ...
## $ Adenosine : num 164 108 120 184 108 ...
## $ Fumarate : num 247.3 27.9 81.1 76.1 79.2 ...
## $ Tyrosine : num 79.8 32 70.1 78.9 34.7 40.7 61.1 31.3 42.5 39.7 ...
## $ Phenylalanine: num 82.5 34 67.6 85 37.8 37.2 58 38.3 45.1 44 ...
## $ Guanosine : num 193 117 136 203 109 ...
## $ Formate : num 51.6 33.9 65.1 32.1 24.7 26.2 51 29.1 37.2 24.3 ...
## $ Choline : num 286 183 228 278 181 ...
## $ Ferulate : num 35 29.6 11.7 36.7 23.2 29.2 47.1 12.7 21 23.1 ...
## $ Glycerol : num 494 210 353 386 216 ...
## $ Isoleucine : num 92.3 37.4 70.5 86.5 46.1 48.3 70 44 48.5 48.5 ...
## $ Leucine : num 156.8 72 145.3 163.5 75.6 ...
## $ p.Cumarate : num 17.9 12.3 13.9 24.5 12.2 13 15.7 7.7 12.6 11 ...
Tyrosine
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Tyrosine[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Tyrosine[Condition == "Standard"]
## W = 0.84429, p-value = 0.04966
with(ANOVATest.data, shapiro.test(Tyrosine[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Tyrosine[Condition == "Deficiency"]
## W = 0.91435, p-value = 0.3122
with(ANOVATest.data, shapiro.test(Tyrosine[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Tyrosine[Condition == "Excess"]
## W = 0.93799, p-value = 0.5309
Hm_var <- bartlett.test(Tyrosine ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Tyrosine by Condition
## Bartlett's K-squared = 0.58795, df = 2, p-value = 0.7453
#### ONE WAY - ANOVA
OneWay_test <- aov(Tyrosine ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 1264 632.1 2.2 0.13
## Residuals 27 7756 287.3
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Tyrosine ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 9.02 -9.773589 27.813589 0.4691684
## Standard-Deficiency -6.83 -25.623589 11.963589 0.6442828
## Standard-Excess -15.85 -34.643589 2.943589 0.1106061
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Tyrosine , 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.88112, p-value = 0.1344
with(ANOVATest.data, shapiro.test(Alanine[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Alanine[Condition == "Deficiency"]
## W = 0.85022, p-value = 0.05844
with(ANOVATest.data, shapiro.test(Alanine[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Alanine[Condition == "Excess"]
## W = 0.87997, p-value = 0.1304
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 = 0.97398, df = 2, p-value = 0.6145
#### 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 31560 15780 2.783 0.0796 .
## Residuals 27 153107 5671
## ---
## 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 -14.92 -98.41895 68.578948 0.8978647
## Standard-Deficiency -75.04 -158.53895 8.458948 0.0843857
## Standard-Excess -60.12 -143.61895 23.378948 0.1935532
#### 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.86053, p-value = 0.07741
with(ANOVATest.data, shapiro.test(Valine[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Valine[Condition == "Deficiency"]
## W = 0.94439, p-value = 0.6028
with(ANOVATest.data, shapiro.test(Valine[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Valine[Condition == "Excess"]
## W = 0.88871, p-value = 0.164
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 = 1.4655, df = 2, p-value = 0.4806
#### 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 11186 5593 4.915 0.0151 *
## Residuals 27 30724 1138
## ---
## 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 13.10 -24.30451 50.504507 0.6644547
## Standard-Deficiency -32.81 -70.21451 4.594507 0.0938819
## Standard-Excess -45.91 -83.31451 -8.505493 0.0138504
#### 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.84304, p-value = 0.04798
with(ANOVATest.data, shapiro.test(Phenylalanine[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Phenylalanine[Condition == "Deficiency"]
## W = 0.90457, p-value = 0.2457
with(ANOVATest.data, shapiro.test(Phenylalanine[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Phenylalanine[Condition == "Excess"]
## W = 0.8712, p-value = 0.1032
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 = 0.47373, df = 2, p-value = 0.7891
#### 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 1595 797.7 2.306 0.119
## Residuals 27 9338 345.9
#### 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 11.35 -9.271268 31.971268 0.3730900
## Standard-Deficiency -6.27 -26.891268 14.351268 0.7339056
## Standard-Excess -17.62 -38.241268 3.001268 0.1048655
#### 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.86273, p-value = 0.08218
with(ANOVATest.data, shapiro.test(Glycerol[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Glycerol[Condition == "Deficiency"]
## W = 0.76101, p-value = 0.00486
with(ANOVATest.data, shapiro.test(Glycerol[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Glycerol[Condition == "Excess"]
## W = 0.90413, p-value = 0.2431
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 = 0.18336, df = 2, p-value = 0.9124
#### 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 3820 1910 0.217 0.807
## Residuals 27 238154 8821
#### 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 27.46 -76.67859 131.59859 0.7918302
## Standard-Deficiency 16.47 -87.66859 120.60859 0.9189882
## Standard-Excess -10.99 -115.12859 93.14859 0.9630129
#### 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()

Succinate
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Succinate[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Succinate[Condition == "Standard"]
## W = 0.86011, p-value = 0.07653
with(ANOVATest.data, shapiro.test(Succinate[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Succinate[Condition == "Deficiency"]
## W = 0.95106, p-value = 0.6811
with(ANOVATest.data, shapiro.test(Succinate[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Succinate[Condition == "Excess"]
## W = 0.95623, p-value = 0.7422
Hm_var <- bartlett.test(Succinate ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Succinate by Condition
## Bartlett's K-squared = 17.895, df = 2, p-value = 0.0001301
#### ONE WAY - ANOVA
OneWay_test <- aov(Succinate ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 10801 5401 17.88 1.13e-05 ***
## Residuals 27 8155 302
## ---
## 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 = Succinate ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 16.74 -2.531005 36.011 0.0978756
## Standard-Deficiency 45.92 26.648995 65.191 0.0000079
## Standard-Excess 29.18 9.908995 48.451 0.0023581
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Succinate , 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.88543, p-value = 0.1506
with(ANOVATest.data, shapiro.test(Sucrose[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Sucrose[Condition == "Deficiency"]
## W = 0.73724, p-value = 0.002495
with(ANOVATest.data, shapiro.test(Sucrose[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Sucrose[Condition == "Excess"]
## W = 0.90621, p-value = 0.2559
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 = 3.0967, df = 2, p-value = 0.2126
#### 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 696112 348056 10.86 0.000347 ***
## Residuals 27 865753 32065
## ---
## 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 84.80 -113.75453 283.3545 0.5471324
## Standard-Deficiency 357.08 158.52547 555.6345 0.0003721
## Standard-Excess 272.28 73.72547 470.8345 0.0057900
#### 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.77158, p-value = 0.006538
with(ANOVATest.data, shapiro.test(Malate[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Malate[Condition == "Deficiency"]
## W = 0.68437, p-value = 0.0005698
with(ANOVATest.data, shapiro.test(Malate[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Malate[Condition == "Excess"]
## W = 0.82744, p-value = 0.03117
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 = 22.87, df = 2, p-value = 1.081e-05
#### 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 430784 215392 11.34 0.000266 ***
## Residuals 27 512947 18998
## ---
## 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 118.98 -33.85373 271.8137 0.1496332
## Standard-Deficiency 291.87 139.03627 444.7037 0.0001785
## Standard-Excess 172.89 20.05627 325.7237 0.0242248
#### 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()

Fumarate
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Fumarate[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Fumarate[Condition == "Standard"]
## W = 0.73297, p-value = 0.002214
with(ANOVATest.data, shapiro.test(Fumarate[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Fumarate[Condition == "Deficiency"]
## W = 0.82455, p-value = 0.02876
with(ANOVATest.data, shapiro.test(Fumarate[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Fumarate[Condition == "Excess"]
## W = 0.96426, p-value = 0.8332
Hm_var <- bartlett.test(Fumarate ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Fumarate by Condition
## Bartlett's K-squared = 25.088, df = 2, p-value = 3.567e-06
#### ONE WAY - ANOVA
OneWay_test <- aov(Fumarate ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 23100 11550 8.291 0.00156 **
## Residuals 27 37614 1393
## ---
## 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 = Fumarate ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency 24.89 -16.4966394 66.27664 0.3108934
## Standard-Deficiency 67.22 25.8333606 108.60664 0.0011622
## Standard-Excess 42.33 0.9433606 83.71664 0.0442431
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Fumarate , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()

Glutamate
#### NORMALITY TEST AND HOMOGENEITY OF VARIANCE
with(ANOVATest.data, shapiro.test(Glutamate[Condition == "Standard"]))
##
## Shapiro-Wilk normality test
##
## data: Glutamate[Condition == "Standard"]
## W = 0.91289, p-value = 0.3014
with(ANOVATest.data, shapiro.test(Glutamate[Condition == "Deficiency"]))
##
## Shapiro-Wilk normality test
##
## data: Glutamate[Condition == "Deficiency"]
## W = 0.94504, p-value = 0.6103
with(ANOVATest.data, shapiro.test(Glutamate[Condition == "Excess"]))
##
## Shapiro-Wilk normality test
##
## data: Glutamate[Condition == "Excess"]
## W = 0.95424, p-value = 0.7188
Hm_var <- bartlett.test(Glutamate ~ Condition, data =ANOVATest.data)
Hm_var
##
## Bartlett test of homogeneity of variances
##
## data: Glutamate by Condition
## Bartlett's K-squared = 0.27217, df = 2, p-value = 0.8728
#### ONE WAY - ANOVA
OneWay_test <- aov(Glutamate ~ Condition, data =ANOVATest.data)
summary(OneWay_test)
## Df Sum Sq Mean Sq F value Pr(>F)
## Condition 2 116494 58247 2.502 0.101
## Residuals 27 628475 23277
#### POST-HOC TUKEY's Test
TukeyHSD(OneWay_test)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Glutamate ~ Condition, data = ANOVATest.data)
##
## $Condition
## diff lwr upr p adj
## Excess-Deficiency -14.52 -183.69128 154.6513 0.9753658
## Standard-Deficiency 124.33 -44.84128 293.5013 0.1815047
## Standard-Excess 138.85 -30.32128 308.0213 0.1231242
#### BOXPLOT
ggplot(ANOVATest.data, aes(x = Condition, y = Glutamate , fill = Condition)) +
geom_boxplot() +
geom_jitter (shape = 15,
color = "steelblue",
position = position_jitter(0.21)) +
theme_classic()
