---
title: "Cholesterol levels of TALLYHO and C57BL/6 mice fed three different diets"
output:
  html_document:
    df_print: paged
  word_document: default
  pdf_document: default
---

In this experiment, TALLYHO and C57BL/6 mice were fed either a Chow diet,
a Low-fat, high-calorie ("LF") diet, or a High-Fat ("HF") diet from weaning
until 16 weeks of age. At that time, mice were sacrificed and a number of 
metabolic measures were recorded.

```{r message=FALSE, echo=FALSE}
library(tidyverse)
library(knitr)
met <- read_csv("https://denvirlab.marshall.edu/BMR617-2022/data/TH-B6-metabolic.csv") %>%
  separate(MouseID, into=c("Strain", "Diet", "ID"), sep='-') %>%
  mutate(Strain = factor(Strain), Diet=factor(Diet)) %>%
  select(Strain, Diet, Cholesterol)
```


Statistical Methods
---

A two-way ANOVA with interaction was performed on the data, using R version 4.2.1. 
Graphs were generated using the `ggplot2` package, version 3.3.6.

Results
---

The data are shown in the following table and graph:

```{r echo=FALSE}
kable(met, digits=2)
ggplot(met, aes(x=Strain, y=Cholesterol, fill=Diet)) +
  geom_boxplot(outlier.shape = NA) + 
  geom_point(position=position_jitterdodge(jitter.width = 0.1, dodge.width = 0.75)) +
  ylab("Cholesterol Level (mg/dl)") +
  ggtitle("Cholesterol Level by Mouse Strain and Diet")
```


```{r echo=FALSE}
aov.full <- aov(Cholesterol ~ Strain * Diet, data = met)
summ.aov.full <- summary(aov.full)
pvals <- summ.aov.full[[1]][,"Pr(>F)"]
```

Both Strain (p=`r signif(pvals[1], 3)`) and Diet (p=`r signif(pvals[2], 3)`) 
showed an effect on Cholesterol Levels of the mice. There
was no evidence of any interaction between Strain and Diet (p=`r signif(pvals[3], 3)`), indicating that
the effects of Diet on Cholesterol levels was broadly the same in both strains.

```{r echo=FALSE}
kable(summ.aov.full[[1]])
resultsTable <- as_tibble(confint(aov.full), rownames="Parameter")
resultsTable <- cbind(resultsTable, tibble(Estimate = aov.full$coefficients))
resultsTable <- resultsTable %>%
  mutate(`2.5 %` = round(`2.5 %`, digits = 2),
         `97.5 %` = round(`97.5 %`, digits = 2),
         Estimate = round(Estimate, digits = 2)) %>%
  mutate(`95% Confidence Interval`=paste0("[", `2.5 %`, ", ", `97.5 %`, "]"))

resultsTable <- resultsTable %>%
  select(Parameter, Estimate, `95% Confidence Interval`)
kable(resultsTable, digits=3)
```

