-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bankside_Geochemical_Average.R
248 lines (224 loc) · 10.7 KB
/
Bankside_Geochemical_Average.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#This script plots the average values for each constituent group by which
#Bank of the stream the wells where located
library(ggplot2)
library(ggpubr)
library(cowplot)
setwd("~/R_Scripts/Data")
master <- read.csv("MasterData.csv")
master$Month = factor(master$Month, levels=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"))
#This custom function is used to calculate the mean & se log values for pH
f1 <- function(x){
log10(mean(10^x))
}
f2 <- function(x){
log10(mean_se(10^x))
}
#Plots the mean monthly dissolved oxygen values by bankside
DOAB<-ggplot(master, aes(x=Month, y=DO, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="Dissolved Oxygen (ppm)")+
ggtitle("A")
#Plots the mean monthly specific conductivity values by bankside
SPCAB<-ggplot(master, aes(x=Month, y=Conductivity, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="Specific Conductivity(us/cm)")+
ggtitle("C")
#Plots the mean monthly water temperature values by bankside
TempAB<-ggplot(master, aes(x=Month, y=Temperature, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="Water Temperature (C)")+
ggtitle("D")
#Plots the mean monthly pH values by bankside
pHAB<-ggplot(master, aes(x=Month, y=pH, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = f1, geom="line",size=1)+
stat_summary(fun.data = f2, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="pH Values")+
ggtitle("B")
#Plots the mean monthly alkalinity values by bankside
AlkAB<-ggplot(master, aes(x=Month, y=Alkalinity, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="[CaCO3] (mg/L)")+
ggtitle("D")
#Plots the mean monthly nitrate values by bankside
NO3AB<-ggplot(master, aes(x=Month, y=NO3, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="[NO3-N] (mg/L)")+
annotate("text", x=3, y=0.2, label="Detection= 0.02")+
annotate("segment", x=1, y=0, xend=12, yend=0)+
ggtitle("A")
#Plots the mean monthly sulfate values by bankside
SO4AB<-ggplot(master, aes(x=Month, y=SO4, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="[SO4] (mg/L)")+
ggtitle("B")
#Plots the mean monthly chloride values by bankside
ClAB<-ggplot(master, aes(x=Month, y=Cl, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="[Cl] (mg/L)")+
ggtitle("C")
#Plots the mean monthly calcium values by bankside
CaAB<-ggplot(master, aes(x=Month, y=Ca, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="[Ca] (mg/L)")+
ggtitle("A")
#Plots the mean monthly sodium values by bankside
NaAB<-ggplot(master, aes(x=Month, y=Na, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="[Na] (mg/L)")+
ggtitle("D")
#Plots the mean monthly magnesium values by bankside
MgAB<-ggplot(master, aes(x=Month, y=Mg, color=Bank, group=Bank
))+
theme_bw()+
stat_summary(fun.y = mean, geom="line",size=1, na.rm = FALSE)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))+
theme(legend.position = 'bottom')+
theme(plot.title = element_text(hjust=0.5))+
theme(axis.title.x = element_blank())+
labs(y="[Mg] (mg/L)")+
ggtitle("C")
#Plots the mean monthly potassium values by bankside
KAB<-ggplot(master, aes(x=Month, y=K, color=Bank, group=Bank
))+
theme_bw()+
ggtitle("B")+
theme(plot.title = element_text(hjust=0.5))+
stat_summary(fun.y = mean, geom="line",size=1, na.rm=FALSE)+
stat_summary(fun.data = mean_se, geom="pointrange")+
scale_color_manual(values = c(Ag="black",
Pr="blue"))+
scale_x_discrete(breaks=c("Nov '17","Dec '17","Jan '18","Feb '18","Mar '18", "Apr '18", "May '18", "Jun '18", "Jul '18", "Aug '18", "Sep '18", "Jan '19"),
labels=c("Nov","Dec","Jan","Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Jan"))
theme(legend.position = 'bottom')+
theme(axis.title.x = element_blank())+
labs(y="[K] (mg/L)")
#Creating figure arrays from the above figures
anion_bankside<- ggarrange(NO3AB, SO4AB, ClAB, AlkAB,
common.legend = TRUE, legend="bottom",
ncol=2, nrow=2)
cation_bankside<- ggarrange(CaAB, KAB, MgAB, NaAB,
common.legend = TRUE, legend="bottom",
ncol=2, nrow=2)
fieldpar_bankside<- ggarrange(DOAB, pHAB, SPCAB, TempAB,
common.legend = TRUE, legend="bottom",
ncol=2, nrow=2)
microbe_bankside <- ggarrange(NO3AB, pHAB, DOAB, KAB,
common.legend=TRUE, legend='bottom',
ncol=1, nrow=4)
#These lines will save pdfs of the figure arrays
setwd("~/R_Scripts/Figures")
pdf("Anion_Bankside.pdf")
print(anion_bankside)
dev.off()
pdf("Cation_Bankside.pdf")
print(cation_bankside)
dev.off()
pdf("Parameter_Bankside.pdf")
print(fieldpar_bankside)
dev.off()
pdf("Microbial_Activity.pdf")
print(microbe_bankside)
dev.off()