forked from statOmics/PSLS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
06_3_armpit_sol.Rmd
186 lines (139 loc) · 5.37 KB
/
06_3_armpit_sol.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
---
title: "Exercise 6.3: Linear regression vs t-test on the armpit dataset"
author: "Lieven Clement, Jeroen Gilis and Milan Malfait"
date: "statOmics, Ghent University (https://statomics.github.io)"
---
# Smelly armpit dataset
Smelly armpits are not caused by sweat, itself. The smell is caused
by specific micro-organisms belonging to the group of
*Corynebacterium spp.* that metabolise sweat. Another group of abundant bacteria
are the *Staphylococcus spp.*, these bacteria do not metabolise sweat in smelly
compounds.
The CMET-group at Ghent University does research to on transplanting the armpit
microbiome to save people with smelly armpits.
- Proposed Therapy:
1. Remove armpit-microbiome with antibiotics
2. Influence armpit microbiome with microbial transplant, see this 2 minute
talk on [youtube](https://youtu.be/9RIFyqLXdVw)
- Experiment:
- 20 students with smelly armpits are attributed to one of
two treatment groups
- placebo (only antibiotics)
- transplant (antibiotica followed by microbial transplant).
- The microbiome is sampled 6 weeks upon the treatment
- The relative abundance of *Staphylococcus spp.* on
*Corynebacterium spp.* + *Staphylococcus spp.* in the
microbiome is measured via DGGE (*Denaturing Gradient Gel
Electrophoresis*).
# Goal
The overarching goal of this research was to assess if the relative abundance
*Staphylococcus spp.*
in the microbiome of the armpit is affected by transplanting the microbiome.
To this end the researchers randomized patients to two treatment:
A treatment with antibiotics only and a treatment with
antibiotics and a microbial transplant.
In the tutorial on hypotheses testing we will use a formal statistical test to
generalize the results from the sample to that of the population.
# Import the dataset
```{r, message=FALSE}
# Load the libraries
library(tidyverse)
```
Import the data
```{r}
ap <- read_csv("https://raw.githubusercontent.com/statOmics/PSLSData/main/armpit.csv")
```
```{r}
glimpse(ap)
```
# Data Exploration
A crucial first step in a data analysis is to visualize and to explore the raw
data.
```{r}
ap %>%
ggplot(aes(x = trt, y = rel, fill = trt)) +
geom_boxplot(outlier.shape = NA) +
geom_point(position = "jitter") +
ylab("relative abundance (%)") +
xlab("treatment group") +
stat_summary(
fun = mean, geom = "point",
shape = 5, size = 3, color = "black",
)
```
We clearly see that, on average, the subjects who had a
microbial transplant have a higher relative abundance of
Staphylococcus spp. But is this difference statistically
*significant* so that we can generalized what we observe
in the sample to the population?
We can test this with an unpaired, two-sample t-test, which falsifies the null
hypothesis that there is on average no difference in relative abundance of
*Staphylococcus* in the armpit microbiome between the transplant and the
placebo group against the alternative hypothesis that there is a difference
in average abundance of *Staphyloccocus* in the armpit microbiome between
the transplant and placebo treatment.
But, before we can start the analysis, we must check if all assumptions to
perform a t-test are met.
# Analysis
## Check the assumptions
1. The observations are independent. This has to be
guaranteed by the design.
2. The data (rel) are normally distributed in each of the groups
3. The variability within both groups is similar.
To check the normality assumption, we will use QQ plots.
```{r}
ap %>%
ggplot(aes(sample = rel)) +
geom_qq() +
geom_qq_line() +
facet_grid(cols = vars(trt))
```
We can see that all of the data lies nicely around the quantile-quantile
line (black line). As such, we may assume that our data are normally distributed.
For the third assumption, we must compare the within-group
variability of both groups. We can do this visually:
```{r}
ap %>%
ggplot(aes(x = trt, y = rel)) +
geom_boxplot(outlier.shape = NA) +
geom_point(position = "jitter") +
ylab("relative abundance (%)") +
xlab("treatment group") +
stat_summary(
fun = mean, geom = "point",
shape = 5, size = 3, color = "black",
)
```
Here we can see that the interquartile range is approximately equal for groups.
As all three assumptions are met we may continue with
performing the unpaired two-sample t-test.
## Hypothesis test
```{r}
output <- t.test(
rel ~ trt,
data = ap,
conf.level = 0.95,
var.equal = TRUE
)
output
```
## Conclusion
On average the relative abundance of *Staphylococcus spp.* in the microbiome of the armpit in the transplant group is extremely significantly different from that in the placebo group ($p<<0.001$). The relative abundance of *Staphylococcus spp.* is on average `r round(diff(t.test(rel~trt,data=ap,var.equal=TRUE)$estimate),1)`% larger in the transplant group than in the placebo group (95\% CI [`r paste(format(-t.test(rel~trt,data=ap,var.equal=TRUE)$conf.int[2:1],digits=2,nsmall=1),collapse=",")`]%).
# Data Analysis with a linear model
## Fit the model
We do not need to check the assumptions again because we have done this already in the data exploration when analysing the data using the t-test.
```{r}
mod <- lm(rel ~ trt, data = ap)
mod
```
## Inference
1. hypothesis test
```{r}
summary(mod)
```
2. confidence interval
```{r}
confint(mod)
```
3. How do your results compare to the analysis with the t-test.
4. Formulate your conclusion based on the output of the linear model.