Code
# Load the libraries
library(tidyverse)statOmics, Ghent University (https://statomics.github.io)
Lieven Clement, Jeroen Gilis and Milan Malfait
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:
Experiment:
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 data
Rows: 20 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): trt
dbl (1): rel
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
A crucial first step in a data analysis is to visualize and to explore the raw data.

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.
The observations are independent. This has to be guaranteed by the design.
The data (rel) are normally distributed in each of the groups
The variability within both groups is similar.
To check the normality assumption, we will use QQ plots.
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:

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.
Two Sample t-test
data: rel by trt
t = -5.0334, df = 18, p-value = 8.638e-05
alternative hypothesis: true difference in means between group placebo and group transplant is not equal to 0
95 percent confidence interval:
-31.53191 -12.96072
sample estimates:
mean in group placebo mean in group transplant
44.15496 66.40127
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 22.2% larger in the transplant group than in the placebo group (95% CI [13.0,31.5]%).
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.
How do your results compare to the analysis with the t-test.
Formulate your conclusion based on the output of the linear model.
---
title: "Exercise 6.3: Linear regression vs t-test on the armpit dataset"
author: "Lieven Clement, Jeroen Gilis and Milan Malfait"
subtitle: "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(output$estimate),1)`% larger in the transplant group than in the placebo group (95\% CI [`r paste(format(-output$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, eval=FALSE}
mod <- ...
```
## Inference
1. hypothesis test
```{r eval=FALSE}
...
```
2. confidence interval
```{r eval=FALSE}
...
```
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.