library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0 ✔ purrr 0.3.4
✔ tibble 3.1.8 ✔ dplyr 1.0.10
✔ tidyr 1.2.1 ✔ stringr 1.4.1
✔ readr 2.1.2 ✔ forcats 0.5.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
library(ggpubr)
library(rstatix)
Attaching package: 'rstatix'
The following object is masked from 'package:stats':
filter
library(readxl)
PLANT_EXTRACT1 <- read_excel("D:/MARV BS MATH/4th year, 2nd sem/JOLINA/PLANT-EXTRACT1.xlsx",
sheet = "SAureus")
PLANT_EXTRACT1
# A tibble: 56 × 5
Hour Concentration SAureusPositiveControl SAureus SAureusGrowt…¹
<chr> <dbl> <dbl> <dbl> <dbl>
1 Pre-incubation 128 0.0383 0.0770 0.039
2 3-hrs Incubation 64 0.0423 0.065 0.107
3 6-hrs Incubation 32 0.043 0.154 0.174
4 9-hrs Incubation 16 0.041 0.0747 0.198
5 12-hrs Incubation 8 0.042 0.0963 0.223
6 15-hrs Incubation 4 0.0407 0.0827 0.244
7 18-hrs Incubation 2 0.0413 -0.260 0.267
8 Pre-incubation 128 0.0383 0.373 0.039
9 3-hrs Incubation 64 0.0423 0.308 0.107
10 6-hrs Incubation 32 0.043 0.429 0.174
# … with 46 more rows, and abbreviated variable name ¹​SAureusGrowthControl
head(PLANT_EXTRACT1,7)
# A tibble: 7 × 5
Hour Concentration SAureusPositiveControl SAureus SAureusGrowth…¹
<chr> <dbl> <dbl> <dbl> <dbl>
1 Pre-incubation 128 0.0383 0.0770 0.039
2 3-hrs Incubation 64 0.0423 0.065 0.107
3 6-hrs Incubation 32 0.043 0.154 0.174
4 9-hrs Incubation 16 0.041 0.0747 0.198
5 12-hrs Incubation 8 0.042 0.0963 0.223
6 15-hrs Incubation 4 0.0407 0.0827 0.244
7 18-hrs Incubation 2 0.0413 -0.260 0.267
# … with abbreviated variable name ¹​SAureusGrowthControl
summary(PLANT_EXTRACT1)
Hour Concentration SAureusPositiveControl SAureus
Length:56 Min. : 2.00 Min. :0.03833 Min. :-0.56600
Class :character 1st Qu.: 4.00 1st Qu.:0.04067 1st Qu.:-0.10817
Mode :character Median : 16.00 Median :0.04133 Median :-0.02633
Mean : 36.29 Mean :0.04124 Mean :-0.00806
3rd Qu.: 64.00 3rd Qu.:0.04233 3rd Qu.: 0.03225
Max. :128.00 Max. :0.04300 Max. : 0.54900
SAureusGrowthControl
Min. :0.0390
1st Qu.:0.1073
Median :0.1977
Mean :0.1789
3rd Qu.:0.2437
Max. :0.2670
TT<-PLANT_EXTRACT1%>%
gather(key = "Control", value = SAureus, 'SAureusGrowthControl', 'SAureusGrowthControl') %>%
convert_as_factor(Hour, Concentration)
TT
# A tibble: 56 × 5
Hour Concentration SAureusPositiveControl Control SAureus
<fct> <fct> <dbl> <chr> <dbl>
1 Pre-incubation 128 0.0383 SAureusGrowth… 0.039
2 3-hrs Incubation 64 0.0423 SAureusGrowth… 0.107
3 6-hrs Incubation 32 0.043 SAureusGrowth… 0.174
4 9-hrs Incubation 16 0.041 SAureusGrowth… 0.198
5 12-hrs Incubation 8 0.042 SAureusGrowth… 0.223
6 15-hrs Incubation 4 0.0407 SAureusGrowth… 0.244
7 18-hrs Incubation 2 0.0413 SAureusGrowth… 0.267
8 Pre-incubation 128 0.0383 SAureusGrowth… 0.039
9 3-hrs Incubation 64 0.0423 SAureusGrowth… 0.107
10 6-hrs Incubation 32 0.043 SAureusGrowth… 0.174
# … with 46 more rows
plot.design(SAureus ~ ., data = TT)
SAureus by Concentration
TT %>%
group_by(Hour) %>%
get_summary_stats(SAureus, type = "mean_sd")
# A tibble: 7 × 5
Hour variable n mean sd
<fct> <fct> <dbl> <dbl> <dbl>
1 12-hrs Incubation SAureus 8 0.223 0
2 15-hrs Incubation SAureus 8 0.244 0
3 18-hrs Incubation SAureus 8 0.267 0
4 3-hrs Incubation SAureus 8 0.107 0
5 6-hrs Incubation SAureus 8 0.174 0
6 9-hrs Incubation SAureus 8 0.198 0
7 Pre-incubation SAureus 8 0.039 0
SAureus by SAureusGrowthControl
TT %>%
group_by(PLANT_EXTRACT1$SAureusGrowthControl) %>%
get_summary_stats(SAureus, type = "mean_sd")
# A tibble: 7 × 5
`PLANT_EXTRACT1$SAureusGrowthControl` variable n mean sd
<dbl> <fct> <dbl> <dbl> <dbl>
1 0.039 SAureus 8 0.039 0
2 0.107 SAureus 8 0.107 0
3 0.174 SAureus 8 0.174 0
4 0.198 SAureus 8 0.198 0
5 0.223 SAureus 8 0.223 0
6 0.244 SAureus 8 0.244 0
7 0.267 SAureus 8 0.267 0
SAureus by SAureusPositiveControl
TT %>%
group_by(PLANT_EXTRACT1$SAureusPositiveControl) %>%
get_summary_stats(SAureus, type = "mean_sd")
# A tibble: 7 × 5
`PLANT_EXTRACT1$SAureusPositiveControl` variable n mean sd
<dbl> <fct> <dbl> <dbl> <dbl>
1 0.0383 SAureus 8 0.039 0
2 0.0407 SAureus 8 0.244 0
3 0.041 SAureus 8 0.198 0
4 0.0413 SAureus 8 0.267 0
5 0.042 SAureus 8 0.223 0
6 0.0423 SAureus 8 0.107 0
7 0.043 SAureus 8 0.174 0
SAureus by Control
TT %>%
group_by(PLANT_EXTRACT1$Control) %>%
get_summary_stats(SAureus, type = "mean_sd")
Warning: Unknown or uninitialised column: `Control`.
# A tibble: 1 × 4
variable n mean sd
<fct> <dbl> <dbl> <dbl>
1 SAureus 56 0.179 0.075
SAureus by Concentration and Hour
TT %>%
group_by(PLANT_EXTRACT1$Concentration, PLANT_EXTRACT1$Hour) %>%
get_summary_stats(SAureus, type = "mean_sd")
# A tibble: 7 × 6
`PLANT_EXTRACT1$Concentration` `PLANT_EXTRACT1$Hour` varia…¹ n mean sd
<dbl> <chr> <fct> <dbl> <dbl> <dbl>
1 2 18-hrs Incubation SAureus 8 0.267 0
2 4 15-hrs Incubation SAureus 8 0.244 0
3 8 12-hrs Incubation SAureus 8 0.223 0
4 16 9-hrs Incubation SAureus 8 0.198 0
5 32 6-hrs Incubation SAureus 8 0.174 0
6 64 3-hrs Incubation SAureus 8 0.107 0
7 128 Pre-incubation SAureus 8 0.039 0
# … with abbreviated variable name ¹​variable
Saureus by Concentration and Control
TT %>%
group_by(PLANT_EXTRACT1$Concentration, Control) %>%
get_summary_stats(SAureus, type = "mean_sd")
# A tibble: 7 × 6
Control `PLANT_EXTRACT1$Concentration` variable n mean sd
<chr> <dbl> <fct> <dbl> <dbl> <dbl>
1 SAureusGrowthControl 2 SAureus 8 0.267 0
2 SAureusGrowthControl 4 SAureus 8 0.244 0
3 SAureusGrowthControl 8 SAureus 8 0.223 0
4 SAureusGrowthControl 16 SAureus 8 0.198 0
5 SAureusGrowthControl 32 SAureus 8 0.174 0
6 SAureusGrowthControl 64 SAureus 8 0.107 0
7 SAureusGrowthControl 128 SAureus 8 0.039 0
Saureus by Hour and Control
TT %>%
group_by(PLANT_EXTRACT1$Hour, Control) %>%
get_summary_stats(SAureus, type = "mean_sd")
# A tibble: 7 × 6
Control `PLANT_EXTRACT1$Hour` variable n mean sd
<chr> <chr> <fct> <dbl> <dbl> <dbl>
1 SAureusGrowthControl 12-hrs Incubation SAureus 8 0.223 0
2 SAureusGrowthControl 15-hrs Incubation SAureus 8 0.244 0
3 SAureusGrowthControl 18-hrs Incubation SAureus 8 0.267 0
4 SAureusGrowthControl 3-hrs Incubation SAureus 8 0.107 0
5 SAureusGrowthControl 6-hrs Incubation SAureus 8 0.174 0
6 SAureusGrowthControl 9-hrs Incubation SAureus 8 0.198 0
7 SAureusGrowthControl Pre-incubation SAureus 8 0.039 0
Saureus by Concentration. Hour and Control
TT %>%
group_by(Concentration, Hour, Control) %>%
get_summary_stats(SAureus, type = "mean_sd")
# A tibble: 7 × 7
Hour Concentration Control varia…¹ n mean sd
<fct> <fct> <chr> <fct> <dbl> <dbl> <dbl>
1 18-hrs Incubation 2 SAureusGrowthControl SAureus 8 0.267 0
2 15-hrs Incubation 4 SAureusGrowthControl SAureus 8 0.244 0
3 12-hrs Incubation 8 SAureusGrowthControl SAureus 8 0.223 0
4 9-hrs Incubation 16 SAureusGrowthControl SAureus 8 0.198 0
5 6-hrs Incubation 32 SAureusGrowthControl SAureus 8 0.174 0
6 3-hrs Incubation 64 SAureusGrowthControl SAureus 8 0.107 0
7 Pre-incubation 128 SAureusGrowthControl SAureus 8 0.039 0
# … with abbreviated variable name ¹​variable
op <- par(mfrow = c(3, 1))
with(TT, {
interaction.plot(Hour, Concentration, SAureus)
interaction.plot(Hour, Control, SAureus)
interaction.plot(Concentration, Control, SAureus)
}
)
library(ggplot2)
ggplot(TT) +
aes(x = Hour, y = "SAurues", color=Hour) +
geom_jitter() +
theme(legend.position = "none")
library(ggplot2)
ggplot(TT) +
aes(x = Concentration, y = "SAureus", color=Concentration) +
geom_jitter() +
theme(legend.position = "none")
library(ggplot2)
ggplot(TT) +
aes(x = Control, y = "SAureus", color=Control) +
geom_jitter() +
theme(legend.position = "none")
boxplot <- ggboxplot(TT,x ="Hour", y = "SAureus", color = "Hour",palette = "jco")
boxplot
boxplot <- ggboxplot(TT,x ="Concentration", y = "SAureus", color = "Concentration",palette = "jco")
boxplot
model <- aov(SAureus ~ Concentration + Hour, data=PLANT_EXTRACT1)
summary(model)
Df Sum Sq Mean Sq F value Pr(>F)
Concentration 1 0.0011 0.00106 0.027 0.869
Hour 5 0.0529 0.01058 0.272 0.926
Residuals 49 1.9033 0.03884
Since the p values are 0.869 and 0.926 for Concentration and Hour respectively, which are both greater than the significance level 0.05, both are not statistically significant.
tukey.two.way<-TukeyHSD(model)
Warning in replications(paste("~", xx), data = mf): non-factors ignored:
Concentration
Warning in TukeyHSD.aov(model): 'which' specified some non-factors which will be
dropped
tukey.two.way
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = SAureus ~ Concentration + Hour, data = PLANT_EXTRACT1)
$Hour
diff lwr upr p adj
15-hrs Incubation-12-hrs Incubation -0.007131358 -0.3100578 0.2957951 1.0000000
18-hrs Incubation-12-hrs Incubation -0.044426204 -0.3473527 0.2585003 0.9993024
3-hrs Incubation-12-hrs Incubation -0.066452654 -0.3693791 0.2364738 0.9934436
6-hrs Incubation-12-hrs Incubation 0.017913148 -0.2850133 0.3208396 0.9999966
9-hrs Incubation-12-hrs Incubation 0.022679383 -0.2802471 0.3256059 0.9999863
Pre-incubation-12-hrs Incubation 0.006815741 -0.2961107 0.3097422 1.0000000
18-hrs Incubation-15-hrs Incubation -0.037294846 -0.3402213 0.2656316 0.9997452
3-hrs Incubation-15-hrs Incubation -0.059321296 -0.3622478 0.2436052 0.9964633
6-hrs Incubation-15-hrs Incubation 0.025044506 -0.2778820 0.3279710 0.9999753
9-hrs Incubation-15-hrs Incubation 0.029810741 -0.2731157 0.3327372 0.9999311
Pre-incubation-15-hrs Incubation 0.013947099 -0.2889794 0.3168736 0.9999992
3-hrs Incubation-18-hrs Incubation -0.022026450 -0.3249529 0.2809000 0.9999884
6-hrs Incubation-18-hrs Incubation 0.062339352 -0.2405871 0.3652658 0.9953600
9-hrs Incubation-18-hrs Incubation 0.067105586 -0.2358209 0.3700321 0.9930903
Pre-incubation-18-hrs Incubation 0.051241945 -0.2516845 0.3541684 0.9984333
6-hrs Incubation-3-hrs Incubation 0.084365802 -0.2185607 0.3872923 0.9772703
9-hrs Incubation-3-hrs Incubation 0.089132037 -0.2137944 0.3920585 0.9701349
Pre-incubation-3-hrs Incubation 0.073268395 -0.2296581 0.3761949 0.9889866
9-hrs Incubation-6-hrs Incubation 0.004766235 -0.2981602 0.3076927 1.0000000
Pre-incubation-6-hrs Incubation -0.011097407 -0.3140239 0.2918291 0.9999998
Pre-incubation-9-hrs Incubation -0.015863642 -0.3187901 0.2870628 0.9999984