Repository navigation
Expand file tree
/
Copy pathStatistical_Tests.R
More file actions
72 lines (62 loc) · 3.83 KB
/
Copy pathStatistical_Tests.R
File metadata and controls
72 lines (62 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# statistical_tests.R
# Requires Setup.R to have been run first.
# ── Two-way ANOVA ─────────────────────────────────────────────────────────────
# Tests whether Treatment, Time_Lapse, or their interaction significantly
# explain variation in motility across the full dataset.
# H0: motility is not affected by treatment, time lapse, or their combination.
anova_two_way <- aov(Motility ~ Treatment * Time_Lapse, data = xlr)
print(summary(anova_two_way))
# Interpretation:
# Treatment alone does not produce a significant difference in mean motility
# between CPA1 and CPA2. Time_Lapse is significant, indicating motility
# changes over time regardless of which cryoprotectant is applied.
# The non-significant interaction term suggests both formulations follow a
# similar time-dependent trajectory — neither is uniquely better or worse
# at any specific time point, given the current sample size.
# ── One-way ANOVA per treatment ───────────────────────────────────────────────
# Tests whether time lapse significantly affects motility within each
# treatment independently.
# H0: motility does not differ across time lapses within a given treatment.
anova_cpa1 <- aov(Motility ~ factor(Time_Lapse), data = cpa1r)
anova_cpa2 <- aov(Motility ~ factor(Time_Lapse), data = cpa2r)
print("One-way ANOVA — CPA1:")
print(summary(anova_cpa1))
print("One-way ANOVA — CPA2:")
print(summary(anova_cpa2))
# CPA1: p > 0.05 — fail to reject H0. Time lapse does not significantly
# affect motility under CPA1.
# CPA2: p < 0.05 — reject H0. At least one time lapse differs significantly
# from the others under CPA2. Proceed to post-hoc testing.
# ── Tukey HSD post-hoc test — CPA2 ───────────────────────────────────────────
# Identifies which specific pairs of time lapses drive the significant
# one-way ANOVA result in CPA2. Applied only to CPA2 since CPA1 showed
# no significant time effect.
model_cpa2 <- aov(Motility ~ factor(Time_Lapse), data = cpa2r)
TukeyHSD(model_cpa2)
# Output columns:
# diff — mean motility difference between the two time points
# lwr / upr — 95% confidence interval bounds for the difference
# p adj — family-wise error rate-corrected p-value
#
# Key findings:
# Time 15 vs Time 5 — significant (p adj < 0.05): motility had declined
# substantially by minute 15 relative to minute 5.
# Time 20 vs Time 5 — significant (p adj < 0.05): further decline by
# minute 20, though less pronounced than the 15–5 comparison.
# All other pairs (10–5, 15–10, 20–10, 20–15) — not significant,
# suggesting motility stabilises after the initial drop at minute 15.
# ── Sample size determination ─────────────────────────────────────────────────
# The current dataset is simulated from a small pilot sample. This power
# analysis estimates the minimum n per group needed to detect a medium
# effect with adequate statistical confidence in a future full study.
#
# Parameters:
# k = 4 (number of time-lapse groups)
# f = 0.25 (Cohen's f for a medium effect size)
# sig.level = 0.05 (alpha)
# power = 0.80 (80% probability of detecting a true effect)
pwr.anova.test(k = 4, f = 0.25, sig.level = 0.05, power = 0.80)
# Result: approximately 45 observations per group are required.
# The current pilot sample falls well below this threshold, which is why
# the two-way ANOVA found no significant treatment effect — the study is
# underpowered for detecting between-CPA differences at this sample size.