-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHypothesis testing of α diversity under different treatments.Rmd
161 lines (144 loc) · 6.36 KB
/
Hypothesis testing of α diversity under different treatments.Rmd
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
---
title: "Hypothesis testing of α diversity under different treatments"
author: "xyz"
date: "2020/4/29"
output: html_document
---
### sort by RNF
```{r}
df<-read.table("X101SC19050239-Z01-F001-B1-41_result/03.AlphaDiversity/alpha_diversity_index.txt",sep = "\t",header = T)
metaData<-readxl::read_xlsx("metaData.xlsx")
drawDf<-data.frame(Shannon=df$shannon,
Treatments=factor(paste0(metaData$Fertilizer,metaData$Position),
levels = c("CKR","UR","CKN","UN","CKF","UF")),
Fertilizer=metaData$Fertilizer,Positions=metaData$Position)
library(extrafont)
library(ggplot2)
ggplot(drawDf, aes(x = Treatments, y = Shannon, fill = Fertilizer)) +
geom_boxplot(alpha = 0.80) +
# geom_point(aes(fill = position), size = 2, shape = 21 ,position = position_jitterdodge(dodge.width = 1)) +
theme(text = element_text(size = 30,family="Times New Roman"))+
ggsave("Shannon.png",width = 10.24, height = 7.68,dpi=100)
# ACE, Shannon, Observed species, Simpson, Chao1, Goods coverage, PD whole tree
```
### ACE sort by U CK
```{r}
drawDf <-
data.frame(
stringsAsFactors = F,
ACE = df$ACE,
Treatments = metaData$Fertilizer
)
drawDf$Treatments<-factor(drawDf$Treatments,levels = c("U","CK"))
# W = 38, p-value = 1.499e-10
wilcox.test(ACE~Treatments,data = drawDf)
ggplot(drawDf, aes(x = Treatments, y = ACE
# , fill = Treatments
)) +
geom_boxplot(alpha = 0.80) +
# geom_point(aes(fill = position), size = 2, shape = 21 ,position = position_jitterdodge(dodge.width = 1)) +
theme(text = element_text(size = 30, family = "Times New Roman"),
axis.text=element_text(colour="black"),legend.position="none") +
ggsave("ACE sort by N0 N150.png",
width = 10.24,
height = 7.68,
dpi = 100)
```
### ACE sort by "UR","UN","UF","CKR","CKN","CKF"
```{r}
library(ggpubr)
drawDf <- data.frame(
ACE = df$ACE,
Treatments = factor(
paste0(metaData$Fertilizer, metaData$Position),
levels = c("UR", "UN", "UF", "CKR", "CKN", "CKF")
),
Positions = factor(metaData$Position, levels = c("R", "N", "F")),
Fertilizer = metaData$Fertilizer
)
# Kruskal-Wallis chi-squared = 34.206, df = 5, p-value = 2.167e-06
kruskal.test(ACE~Treatments,drawDf)
ggplot(drawDf, aes(x = Treatments, y = ACE, fill = Positions)) +
geom_boxplot(alpha = 0.80) +
# only UN UR was significantly different
# stat_compare_means(
# label = "p.signif",
# method = "wilcox.test",
# comparisons = list(
# c("CKR", "CKN"),
# c("CKR", "CKF"),
# c("CKN", "CKF"),
# c("UR", "UN"),
# c("UR", "UF"),
# c("UN", "UF")
# )
# ) +
theme(
text = element_text(size = 30, family = "Times New Roman"),
axis.text = element_text(colour = "black")
) +
ggsave(
"ACE sort by UR,UN,UF,CKR,CKN,CKF.png",
width = 10.24,
height = 7.68,
dpi = 100
)
```
### Shannon sort by "UR","UN","UF","CKR","CKN","CKF"
```{r}
drawDf<-data.frame(Shannon=df$shannon,
Treatments=factor(paste0(metaData$Fertilizer,metaData$Position),
levels = c("UR","UN","UF","CKR","CKN","CKF")),
Positions=factor(metaData$Position,levels = c("R","N","F")),
Fertilizer=metaData$Fertilizer)
ggplot(drawDf, aes(x = Treatments, y = Shannon, fill = Positions)) +
geom_boxplot(alpha = 0.80) +
theme(text = element_text(size = 30,family="Times New Roman"),
axis.text=element_text(colour="black"))+
ggsave("Shannon sort by UR,UN,UF,CKR,CKN,CKF.png",width = 10.24, height = 7.68,dpi=100)
```
### sort by CK N
```{r}
drawDf<-data.frame(Shannon=df$shannon,
Treatments=factor(paste0(metaData$Fertilizer,metaData$Position),
levels = c("CKR","CKN","CKF","UR","UN","UF")),
Positions=factor(metaData$Position,levels = c("R","N","F")),
Fertilizer=metaData$Fertilizer)
library(extrafont)
library(ggplot2)
library(ggpubr)
ggplot(drawDf, aes(x = Treatments, y = Shannon, fill = Fertilizer)) +
geom_boxplot(alpha = 0.80) +
# geom_point(aes(fill = position), size = 2, shape = 21 ,position = position_jitterdodge(dodge.width = 1)) +
stat_compare_means(method = "kruskal.test", label.y = 10)+
stat_compare_means(label = "p.signif", method = "wilcox.test",
# only UN UR was significantly different
comparisons =list( c("CKR", "CKN"), c("CKR", "CKF"), c("CKN", "CKF"),
c("UR", "UN"), c("UR", "UF"), c("UN", "UF")))+
theme(text = element_text(size = 30,family="Times New Roman"))+
ggsave("Shannon sort by CK N.png",width = 10.24, height = 7.68,dpi=100)
# pairwise comparison test after kruskal-wallis in r https://rcompanion.org/handbook/F_08.html
# There was little difference between rhizosphere and non-rhizosphere
# library(FSA)
# dunnTest(Shannon~Treatments,drawDf,method="bh")
# p-value = 0.01781
kruskal.test(Shannon~Treatments,drawDf)
ggplot(drawDf, aes(x = Treatments, y = Shannon, fill = Fertilizer)) +
geom_boxplot(alpha = 0.80) +
# geom_point(aes(fill = position), size = 2, shape = 21 ,position = position_jitterdodge(dodge.width = 1)) +
stat_compare_means(method = "kruskal.test",size = 8, label.y = 10,family="Times New Roman")+
stat_compare_means(label = "p.signif", method = "wilcox.test",
# only UN UR was significantly different
comparisons =list(c("UR", "UN")),size = 5,family="Times New Roman")+
theme(text = element_text(size = 30,family="Times New Roman"))+
ggsave("Shannon CK N, UN vs UR.png",width = 10.24, height = 7.68,dpi=100)
ggplot(drawDf, aes(x = Treatments, y = Shannon, fill = Positions)) +
geom_boxplot(alpha = 0.80) +
# geom_point(aes(fill = position), size = 2, shape = 21 ,position = position_jitterdodge(dodge.width = 1)) +
# stat_compare_means(method = "kruskal.test",size = 5, label.y = 10)+
# stat_compare_means(label = "p.signif", method = "wilcox.test",
# # In fact, only UN UR was different
# comparisons =list(c("UR", "UN")),size = 5,family="Times New Roman")+
theme(text = element_text(size = 30,family="Times New Roman"))+
ggsave("Shannon without significance.png",width = 10.24, height = 7.68,dpi=100)
```