-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoperamideFishMeasurents.Rmd
120 lines (87 loc) · 4.13 KB
/
LoperamideFishMeasurents.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
---
title: "Loperamide growth measurements"
author: "Rebecca Stevick"
output:
html_document:
toc: true
keep_md: TRUE
theme: "cerulean"
toc_float:
collapsed: false
smooth_scroll: false
---
# About the data
10 fish per condition
Conventional fish treated with loperamide at 5 dpf for 24 hours.
- Sample timepoint 1 at 6 dpf (24 hour treatment)
- Sample timepoint 2 at 7 dpf (24 hour treatment + 24 hour water)
- Sample timepoint 3 at 11 dpf (24 hour treatment + 5 days water)
# Setup
## Load libraries and settings
```{r setup, warning=FALSE, message=FALSE, echo=FALSE}
library(tidyverse)
library(scales)
library(ggpubr)
# set global theme
theme_set(theme_minimal()+
theme(panel.grid.major.y = element_line(color="grey80"),
strip.text=element_text(size=16),
plot.title = element_text(size=20, hjust=0),
strip.background = element_rect(color="transparent"),
plot.caption = element_text(size=10),
panel.grid.major.x = element_blank(),legend.position="top",
plot.background = element_rect(fill="transparent", color="transparent"),
axis.ticks = element_line(inherit.blank = FALSE),
panel.background = element_rect(color="grey50", size=2),
legend.title = element_text(size=18),
axis.text = element_text(size=15), axis.title = element_text(size=18),
legend.text = element_text(size=16)))
# set global options for code output
knitr::opts_chunk$set(echo=TRUE, warning=FALSE,message=FALSE)
```
## Import data
```{r import}
data <- readxl::read_xlsx("Data ZH1902.xlsx")
```
# Stats of all conditions
```{r stats}
data %>% pivot_longer(Length_mm:EyeDiameter_mm) %>%
mutate(Parameter=factor(name, levels=c("Length_mm", "RumpAnusLength_mm", "TailWidth_mm", "EyeDiameter_mm"),
labels=c("A. Fish Length", "B. Rump-Anus Length", "C. Tail Width", "D. Eye Diameter")),
Timepoint_Day=factor(Timepoint_Day, levels=c("24h","48h","6d"),
labels=c("T0","T1","T5"))) %>%
compare_means(data=., value~Treatment,
group.by = c("Parameter","Timepoint_Day")) -> statsbydayGrowth
sigstatsbydayGrowth <- statsbydayGrowth %>% filter(p.format<0.05 & group1=="DMSO")
```
# All together
```{r together, fig.width=9, fig.height=7}
data %>% pivot_longer(Length_mm:EyeDiameter_mm) %>%
mutate(Parameter=factor(name, levels=c("Length_mm", "RumpAnusLength_mm", "TailWidth_mm", "EyeDiameter_mm"),
labels=c("A. Fish Length", "B. Rump-Anus Length", "C. Tail Width", "D. Eye Diameter")),
Timepoint_Day=factor(Timepoint_Day, levels=c("24h","48h","6d"),
labels=c("T0","T1","T5"))) %>%
ggplot(aes(x=Timepoint_Day, y=value, fill=Treatment,color=Treatment, shape=Treatment))+
geom_point(position=position_jitterdodge(jitter.width = 0.1,jitter.height = 0))+
geom_boxplot(alpha=0.8, color="black", show.legend = FALSE)+
geom_text(data=sigstatsbydayGrowth, aes(label="*", y=0.36, color=NA, shape=NA, x=Timepoint_Day),
size=10, color="black", nudge_x = 0.3, show.legend=FALSE, inherit.aes = FALSE)+
facet_wrap(.~Parameter, scales="free")+
scale_fill_manual(values=c('#000000', '#1c5580', '#0fc08e'))+
scale_color_manual(values=c('#000000', '#1c5580', '#0fc08e'))+
labs(y="Measurement (mm)", x="Timepoint")+
theme(legend.position = "bottom", title = element_text(size=18, face="bold"),
strip.text = element_text(size=18, face="bold", hjust=0),
legend.background = element_blank(),
plot.background = element_blank(),
strip.background = element_blank(),
panel.background = element_rect(size=1, fill="white", color="grey50"))+
guides(fill=guide_legend(override.aes = list(size=8)))
ggsave("FigureS6_fishgrowth_loperamide.png", bg="transparent", width=10)
ggsave("FigureS6_fishgrowth_loperamide.tiff", bg="transparent", width=10)
ggsave("FigureS6_fishgrowth_loperamide.pdf", bg="transparent", width=10)
```
# Session info
```{r}
sessionInfo()
```