-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03 Absolute Organ Weights.R
168 lines (140 loc) · 8.23 KB
/
03 Absolute Organ Weights.R
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
#data <- read_excel("C:/Users/edmondsonef/Desktop/MHL 19-331-121 Efficacy.xlsx", sheet = "19-331-121 Chem")
library(ggplot2)
library(gridExtra)
library(readxl)
library(patchwork)
setwd("C:/Users/edmondsonef/Desktop/R-plots/")
### Body Weight
my_mean = aggregate(data$Weight, by=list(data$Group), mean, na.rm = T) ; colnames(my_mean)=c("Group" , "mean")
my_CI = aggregate(data$Weight , by=list(data$Group) , FUN = function(x) t.test(x)$conf.int) ; colnames(my_CI)=c("Group" , "CI")
my_info = merge(my_mean , my_CI , by.x=1 , by.y=1)
my_info$CIdiff = ((my_CI$CI[,2] - my_CI$CI[,1])/2)
### BW Plot
BW <- ggplot(data) +
geom_point(data = my_info, aes(x = Group , y = mean), color = "grey", size = 2) +
scale_y_continuous(name = "Body Weight (95% CI)") +#, limits=c(18, 28.5)) +
geom_errorbar(data = my_info, aes(x = Group, y = CIdiff, ymin = mean - CIdiff, ymax = mean + CIdiff), color = "grey", width = 0.1 , size=0.5) +
geom_jitter(aes(x = Group, y = Weight, color = `Sex`), width = 0.1)+
theme_bw() +
theme(axis.text.x=element_text(angle=25,hjust=1)) +
theme(axis.title.x=element_blank(), text = element_text(size = 10))
### Brain Weight
my_mean = aggregate(data$'Brain Weight', by=list(data$Group), mean, na.rm = T) ; colnames(my_mean)=c("Group" , "mean")
my_CI = aggregate(data$'Brain Weight' , by=list(data$Group) , FUN = function(x) t.test(x)$conf.int) ; colnames(my_CI)=c("Group" , "CI")
my_info = merge(my_mean , my_CI , by.x=1 , by.y=1)
my_info$CIdiff = ((my_CI$CI[,2] - my_CI$CI[,1])/2)
### Brain plot
Brain <- ggplot(data) +
geom_point(data = my_info, aes(x = Group , y = mean), color = "grey", size = 2) +
scale_y_continuous(name = "Brain (grams)", limits=c(0.3, 0.55)) +
geom_errorbar(data = my_info, aes(x = Group, y = CIdiff, ymin = mean - CIdiff, ymax = mean + CIdiff), color = "grey", width = 0.2 , size=0.5) +
geom_jitter(aes(x = Group, y = data$"Brain Weight", color = `Sex`), width = 0.1)+
theme_bw() +
theme(axis.text.x=element_text(angle=25,hjust=1)) +
theme(axis.title.x=element_blank(), text = element_text(size = 10))
### Heart Weight
my_mean = aggregate(data$'Heart Weight', by=list(data$Group), mean, na.rm = T) ; colnames(my_mean)=c("Group" , "mean")
my_CI = aggregate(data$'Heart Weight' , by=list(data$Group) , FUN = function(x) t.test(x)$conf.int) ; colnames(my_CI)=c("Group" , "CI")
my_info = merge(my_mean , my_CI , by.x=1 , by.y=1)
my_info$CIdiff = ((my_CI$CI[,2] - my_CI$CI[,1])/2)
### Heart plot
Heart <- ggplot(data) +
geom_point(data = my_info, aes(x = Group , y = mean), color = "grey", size = 2) +
scale_y_continuous(name = "Heart (grams)")+#, limits=c(0.06, 0.15)) +
geom_errorbar(data = my_info, aes(x = Group, y = CIdiff, ymin = mean - CIdiff, ymax = mean + CIdiff), color = "grey", width = 0.2 , size=0.5) +
geom_jitter(aes(x = Group, y = data$'Heart Weight', color = `Sex`), width = 0.1)+
theme_bw() +
theme(axis.text.x=element_text(angle=25,hjust=1)) +
theme(axis.title.x=element_blank(), text = element_text(size = 10))
### Liver Weight
my_mean = aggregate(data$'Liver Weight', by=list(data$Group), mean, na.rm = T) ; colnames(my_mean)=c("Group" , "mean")
my_CI = aggregate(data$'Liver Weight' , by=list(data$Group) , FUN = function(x) t.test(x)$conf.int) ; colnames(my_CI)=c("Group" , "CI")
my_info = merge(my_mean , my_CI , by.x=1 , by.y=1)
my_info$CIdiff = ((my_CI$CI[,2] - my_CI$CI[,1])/2)
### Liver plot
Liver <- ggplot(data) +
geom_point(data = my_info, aes(x = Group , y = mean), color = "grey", size = 2) +
scale_y_continuous(name = "Liver (grams)")+#, limits=c(0.9, 1.3)) +
geom_errorbar(data = my_info, aes(x = Group, y = CIdiff, ymin = mean - CIdiff, ymax = mean + CIdiff), color = "grey", width = 0.2 , size=0.5) +
geom_jitter(aes(x = Group, y = data$'Liver Weight', color = `Sex`), width = 0.1)+
theme_bw() +
theme(axis.text.x=element_text(angle=25,hjust=1)) +
theme(axis.title.x=element_blank(), text = element_text(size = 10))
### Lung Weight
my_mean = aggregate(data$'Lung Weight', by=list(data$Group), mean, na.rm = T) ; colnames(my_mean)=c("Group" , "mean")
my_CI = aggregate(data$'Lung Weight' , by=list(data$Group) , FUN = function(x) t.test(x)$conf.int) ; colnames(my_CI)=c("Group" , "CI")
my_info = merge(my_mean , my_CI , by.x=1 , by.y=1)
my_info$CIdiff = ((my_CI$CI[,2] - my_CI$CI[,1])/2)
### Lung plot
Lung <- ggplot(data) +
geom_point(data = my_info, aes(x = Group , y = mean), color = "grey", size = 2) +
scale_y_continuous(name = "Lung (grams)")+#, limits=c(0.1, 0.36)) +
geom_errorbar(data = my_info, aes(x = Group, y = CIdiff, ymin = mean - CIdiff, ymax = mean + CIdiff), color = "grey", width = 0.2 , size=0.5) +
geom_jitter(aes(x = Group, y = data$'Lung Weight', color = `Sex`), width = 0.1)+
theme_bw() +
theme(axis.text.x=element_text(angle=25,hjust=1)) +
theme(axis.title.x=element_blank(), text = element_text(size = 10))
### Spleen Weight
my_mean = aggregate(data$'Spleen Weight', by=list(data$Group), mean, na.rm = T) ; colnames(my_mean)=c("Group" , "mean")
my_CI = aggregate(data$'Spleen Weight' , by=list(data$Group) , FUN = function(x) t.test(x)$conf.int) ; colnames(my_CI)=c("Group" , "CI")
my_info = merge(my_mean , my_CI , by.x=1 , by.y=1)
my_info$CIdiff = ((my_CI$CI[,2] - my_CI$CI[,1])/2)
### Spleen plot
Spleen <- ggplot(data) +
geom_point(data = my_info, aes(x = Group , y = mean), color = "grey", size = 2) +
scale_y_continuous(name = "Spleen (grams)")+#, limits=c(0.009, 0.1)) +
geom_errorbar(data = my_info, aes(x = Group, y = CIdiff, ymin = mean - CIdiff, ymax = mean + CIdiff), color = "grey", width = 0.2 , size=0.5) +
geom_jitter(aes(x = Group, y = data$'Spleen Weight', color = `Sex`), width = 0.1) +
theme_bw() +
theme(axis.text.x=element_text(angle=25,hjust=1)) +
theme(axis.title.x=element_blank(), text = element_text(size = 10))
### Kidney Weight
my_mean = aggregate(data$'Kidney Weight', by=list(data$Group), mean, na.rm = T) ; colnames(my_mean)=c("Group" , "mean")
my_CI = aggregate(data$'Kidney Weight' , by=list(data$Group) , FUN = function(x) t.test(x)$conf.int) ; colnames(my_CI)=c("Group" , "CI")
my_info = merge(my_mean , my_CI , by.x=1 , by.y=1)
my_info$CIdiff = ((my_CI$CI[,2] - my_CI$CI[,1])/2)
### Kidney plot
Kidney <- ggplot(data) +
geom_point(data = my_info, aes(x = Group , y = mean), color = "grey", size = 2) +
scale_y_continuous(name = "Kidney (grams)")+#, limits=c(0.18, 0.33)) +
geom_errorbar(data = my_info, aes(x = Group, y = CIdiff, ymin = mean - CIdiff, ymax = mean + CIdiff), color = "grey", width = 0.2 , size=0.5) +
geom_jitter(aes(x = Group, y = data$'Kidney Weight', color = `Sex`), width = 0.1) +
theme_bw() +
theme(axis.text.x=element_text(angle=25,hjust=1)) +
theme(axis.title.x=element_blank(), text = element_text(size = 10))
### Graft Weight
my_mean = aggregate(data$'Graft Weight', by=list(data$Group), mean, na.rm = T) ; colnames(my_mean)=c("Group" , "mean")
my_CI = aggregate(data$'Graft Weight' , by=list(data$Group) , FUN = function(x) t.test(x)$conf.int) ; colnames(my_CI)=c("Group" , "CI")
my_info = merge(my_mean , my_CI , by.x=1 , by.y=1)
my_info$CIdiff = ((my_CI$CI[,2] - my_CI$CI[,1])/2)
### Graft plot
Graft <- ggplot(data) +
geom_point(data = my_info, aes(x = Group , y = mean), color = "grey", size = 2) +
scale_y_continuous(name = "Graft")+#, limits=c(0, 10)) +
geom_errorbar(data = my_info, aes(x = Group, y = CIdiff, ymin = mean - CIdiff, ymax = mean + CIdiff), color = "grey", width = 0.2 , size=0.5) +
geom_jitter(aes(x = Group, y = data$'Graft Weight', color = `Sex`), width = 0.1) +
theme_bw() +
theme(axis.text.x=element_text(angle=25,hjust=1)) +
theme(axis.title.x=element_blank(), text = element_text(size = 10))
### Make multiple plots
### Make multiple plots
### Make multiple plots
#tiff("BW.tiff", units="in", width=6, height=2.5, res=600)
#grid.arrange(BW, ncol = 1, nrow = 1)
#dev.off()
tiff("04. Absolute Organ Weights.tiff", units="in", width=9, height=10, res=300)
(BW) /
(Brain | Heart) /
(Lung | Kidney) /
(Spleen | Liver) /
plot_layout(guides = "collect") +
plot_annotation(title = "Absolute Organ Weights (grams)")
dev.off()
#tiff("04. Absolute Organ Weights.tiff", units="in", width=8, height=10, res=300)
#(BW) /
# (Graft | Heart) /
# (Lung | Kidney) /
# (Spleen | Liver) /
# plot_layout(guides = "collect") +
# plot_annotation(title = "Absolute Organ Weights (grams)")
#dev.off()