-
Notifications
You must be signed in to change notification settings - Fork 0
/
alpha_diversity.Rmd
184 lines (119 loc) · 3.88 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
---
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())
#pal = "Set1"
# scale_colour_discrete <- function(palname=pal, ...){
# scale_colour_brewer(palette=palname, ...)
# }
# scale_fill_discrete <- function(palname=pal, ...){
# scale_fill_brewer(palette=palname, ...)
# }
knitr::opts_chunk$set(out.width = "225%")
```
# Alpha diversity
## By unique participants
```{r}
plot_data <- microbiome_data$meta.dat
ggplot(plot_data, aes(x=SubjectID3, y=Observed, colour=SubjectID3))+
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(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(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(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(aes(group=Intervention, color=Intervention))+
geom_point(position="jitter",aes(color=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(aes(group=Intervention, color=Intervention))+
geom_point(position="jitter",aes(color=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(aes(group=Intervention, color=Intervention))+
geom_point(position="jitter",aes(color=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))+
geom_boxplot(aes(group=Intervention, color=Intervention))+
geom_point(position="jitter",aes(color=Intervention))+
facet_grid(.~Week)+
labs(x="Intervention Group by Week")+
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=Intervention, y=Shannon))+
geom_boxplot(aes(group=Intervention, color=Intervention))+
geom_point(position="jitter",aes(color=Intervention))+
facet_grid(.~Week)+
labs(x="Intervention Group by Week")+
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=Intervention, y=Simpson))+
geom_boxplot(aes(group=Intervention, color=Intervention))+
geom_point(position="jitter",aes(color=Intervention))+
facet_grid(.~Week)+
labs(x="Intervention Group by Week")+
theme(axis.text.x = element_text(angle = 0, hjust=0.33))
```