-
Notifications
You must be signed in to change notification settings - Fork 0
/
alpha_diversity.Rmd
239 lines (161 loc) · 5.47 KB
/
alpha_diversity.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
---
title: "Alpha Diversity"
output:
workflowr::wflow_html:
toc: true
editor_options:
chunk_output_type: console
---
This page contains the investigation of alpha diversity investigations.
```{r data, include=FALSE, echo=FALSE}
##Chunk iptions
# load packages
source("code/load_packages.R")
# get data
source("code/get_cleaned_data.R")
theme_set(theme_bw())
knitr::opts_chunk$set(out.width = "225%")
# recode
plot_data <- microbiome_data$meta.dat
plot_data$Week <- factor(plot_data$Week,
levels=c("1", "4", "8", "12"),
labels=c("Week 1", "Week 4",
"Week 8", "Week 12"))
```
# Alpha diversity
## Boxplots by unique participants
### Observed OTUs
```{r}
ggplot(plot_data, aes(x=SubjectID3, y=Observed,
colour=SubjectID3, shape=Week))+
geom_point(size=2) +
labs(x="Subject ID")+
guides(colour= guide_legend(title = "Subject ID"))+
theme(axis.text.x = element_text(angle=90, vjust=0.5))
```
### Shannon Index
```{r}
ggplot(plot_data, aes(x=SubjectID3, y=Shannon,
colour=SubjectID3, shape=Week))+
geom_point(size=2) +
labs(x="Subject ID")+
guides(colour= guide_legend(title = "Subject ID"))+
theme(axis.text.x = element_text(angle=90, vjust=0.5))
```
### Simpson
```{r}
ggplot(plot_data, aes(x=SubjectID3, y=Simpson,
colour=SubjectID3, shape=Week))+
geom_point(size=2) +
labs(x="Subject ID")+
guides(colour= guide_legend(title = "Subject ID"))+
theme(axis.text.x = element_text(angle=90, vjust=0.5))
```
## Boxplots by week of study
### Observed OTUs
```{r}
ggplot(plot_data, aes(x=Week, y=Observed,
colour=SubjectID3))+
geom_boxplot(outlier.alpha = 0,aes(group=Week))+
geom_point(size=2, position="jitter")+
labs(x="Week of Study")+
guides(colour= guide_legend(title = "Subject ID"))+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```
### Shannon Index
```{r}
ggplot(plot_data, aes(x=Week, y=Shannon, colour=SubjectID3))+
geom_boxplot(outlier.alpha = 0,aes(group=Week))+
geom_point(size=2, position="jitter")+
labs(x="Week of Study", y="Shannon Index")+
guides(colour= guide_legend(title = "Subject ID"))+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```
### Simpson
```{r}
ggplot(plot_data, aes(x=Week, y=Simpson, colour=SubjectID3))+
geom_boxplot(outlier.alpha = 0,
aes(group=Week))+
geom_point(size=2, position="jitter")+
labs(x="Week of Study", y="Simpson")+
guides(colour= guide_legend(title = "Subject ID"))+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```
# Intervention Effect
## Overall Effect
### Observed OTUs
```{r}
ggplot(plot_data, aes(x=Intervention, y=Observed))+
geom_boxplot(outlier.alpha = 0,
aes(group=Intervention, color=Intervention))+
geom_point(position="jitter",aes(color=Intervention))+
guides(colour= guide_legend(title = "Intervention"))+
labs(x="Intervention Group")+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```
### Shannon Index
```{r}
ggplot(plot_data, aes(x=Intervention, y=Shannon))+
geom_boxplot(outlier.alpha = 0,
aes(group=Intervention, color=Intervention))+
geom_point(position="jitter",aes(color=Intervention))+
guides(colour= guide_legend(title = "Intervention"))+
labs(x="Intervention Group")+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```
### Simpson
```{r}
ggplot(plot_data, aes(x=Intervention, y=Simpson))+
geom_boxplot(outlier.alpha = 0,aes(group=Intervention, color=Intervention))+
geom_point(position="jitter",aes(color=Intervention))+
guides(colour= guide_legend(title = "Intervention"))+
labs(x="Intervention Group")+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```
## Changes Over Time
### Observed OTUs
```{r}
ggplot(plot_data, aes(x=Intervention, y=Observed,
group=Intervention,
color=Intervention, shape=Intervention))+
geom_boxplot(outlier.alpha = 0)+
geom_point(position="jitter")+
facet_grid(.~Week)+
labs(x="Intervention Group by Week")+
guides(colour= guide_legend(title = "Intervention"))+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
ggplot(plot_data, aes(x=Week, y=Observed,
group=interaction(Intervention, SubjectID3),
color=SubjectID3, shape=Intervention))+
#geom_boxplot(outlier.alpha = 0)+
geom_point()+
geom_line()+
#facet_grid(.~Week)+
labs(x="Intervention Group by Week")+
guides(colour= guide_legend(title = "Intervention"))+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```
### Shannon Index
```{r}
ggplot(plot_data, aes(x=Intervention, y=Shannon,
group=Intervention,
color=Intervention, shape=Intervention))+
geom_boxplot(outlier.alpha = 0)+
geom_point(position="jitter")+
facet_grid(.~Week)+
labs(x="Intervention Group by Week")+
guides(colour= guide_legend(title = "Intervention"))+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```
### Simpson
```{r}
ggplot(plot_data, aes(x=Intervention, y=Simpson,
group=Intervention,
color=Intervention, shape=Intervention))+
geom_boxplot(outlier.alpha = 0)+
geom_point(position="jitter")+
facet_grid(.~Week)+
labs(x="Intervention Group by Week")+
guides(colour= guide_legend(title = "Intervention"))+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```