-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
512 lines (512 loc) · 28.7 KB
/
.Rhistory
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
Resp.Data$time_Sec <- period_to_seconds(hms(substr((strptime(sub(".*2021/", "", Resp.Data$Date..Time..DD.MM.YYYY.HH.MM.SS.), "%I:%M:%S %p")) , 12,19))) # time - use 'sub' to call target time of the raw date time after 'year/' + strptime' convert to 24 hr clock + 'period_to_seconds' converts the hms to seconds
Resp.Data$seconds <- (Resp.Data$time_Sec - Resp.Data$time_Sec[1]) # secs - calc the sec time series
Resp.Data$minutes <- (Resp.Data$time_Sec - Resp.Data$time_Sec[1])/60 # mins - calc the minute time series
temperature_C <- as.numeric(Resp.Data$CH1.temp...C.[1])
barromP_kPa <- as.numeric(Resp.Data$Barometric.pressure..hPa.[1]) / 10
salinity.pp.thou <- as.numeric(Resp.Data$Salinity....[1])
Resp.Data <- Resp.Data %>% # use 'dplyr'
dplyr::filter(!Phase %in% 'Flush') %>% # remove the initial rows labeled flush
dplyr::select(c(date, seconds, minutes, contains(".O2...air.sat"))) # call unique column names for the 8 Channels
colnames(Resp.Data)[c(4:(ncol(Resp.Data)))] <- substr( ( colnames(Resp.Data)[c(4:(ncol(Resp.Data)))] ), 1,3) # clean these column names to make things easier - first 3 characters
# Truncate!
# the loligo recoreded values every second, this slows the model dramatically with >2000 values for each Channel, call every 30 seconds to speed this up
# discuss with collaborators on this truncated approach
Resp.Data_30sec = Resp.Data[seq(1, nrow(Resp.Data), 30), ]
# II.B Loop #2 - within each filename, call each Channel (% O2 sat.) to measure respiration rates, output plots and cumulative spreadsheet
for(j in 4:(ncol(Resp.Data_30sec))){
Resp_loop <- na.omit(Resp.Data_30sec[,c(3,4)]) # noticed some random rows have 'NaN' - so I will loop the min and Channels to ommit Nas before proceeding
Resp_loop$mgL <- DO.unit.convert(as.numeric(Resp_loop[,2]), # DO in percent air sat to be converted to mgL
DO.units.in = "pct", DO.units.out ="mg/L",
bar.units.in = "kPa", bar.press = barromP_kPa, bar.units.out = "kpa",
temp.C = temperature_C,
salinity.units = "pp.thou", salinity = salinity.pp.thou)
if (nrow(Resp_loop) < 1) {
resp.table$Date <- Resp.Data_30sec[1,1]
resp.table$Channel <- colnames(Resp_loop)[2]
resp.table[3:ncol(resp.table)] <- 'NA'
df <- data.frame(resp.table) # name dataframe for this single row
df_total <- rbind(df_total,df) #bind to a cumulative list dataframe
print(df_total) # print to monitor progress
} else {
model <- rankLocReg(
xall = as.numeric(Resp_loop[, 1]),
yall = as.numeric(Resp_loop[, 3]), # call x as the minute timeseries and y as the % air saturation of the particular Channel
alpha = a, # alpha was assigned earlier as 0.4 by the authors default suggestions - review Olito et al. and their github page for details
method = "pc",
verbose = TRUE)
sum.table <- summary(model)
resp.table$Date <- Resp.Data_30sec[1,1]
resp.table$Channel <- colnames(Resp_loop)[2]
resp.table$Lpc <- sum.table$Lcompare[3,6] # Lpc slope - call the column 'b1'
resp.table$Leq <- sum.table$Lcompare[2,6] # Leq slope - call the column 'b1'
resp.table$Lz <- sum.table$Lcompare[1,6] # Lz slope - call the column 'b1'
resp.table$alpha <- a
resp.table$Notes <- file.names.table[i,2]
resp.table$Filename <- file.names.table[i,1]
df <- data.frame(resp.table) # name dataframe for this single row
df_total <- rbind(df_total,df) #bind to a cumulative list dataframe
print(df_total) # print to monitor progress
# save plots every inside loop and name by date_run_vialposition
pdf(paste0("C:/Users/samjg/Documents/Github_repositories/Cvriginica_multistressor/Output/Respiration/plots_alpha0.4_increm30sec/",file.names.table[i,2],"_",colnames(Resp_loop)[2],"_regression.pdf"))
plot(model)
dev.off()
} # end of if else statement
} # end of inside for loop
} # end of outside for loop
file.names.table[i,1]
Resp.Data_30sec
Resp_loop
# bring in the respiration file names
file.names.full <- basename(list.files(path = path.p, pattern = "txt$", recursive = TRUE)) #list all csv file names in the folder and subfolders
file.names <- file.names.full[c(3:4,6:7,10:11, 13,15, 19:20)] # call all target files (excluding tests and empty files) - open in notepad++ to make sure you have the correct files
file.names # check
file.names.table <- data.frame(file.names)
file.names.table$about <- c('20210319_new_sensor_7', '20210319', '20210430_LOWtemp_HIGHsal',
'20210430_LOWtemp_LOWsal', '20210430_raw', '20210507_HIGHtemp_LOWsal',
'20210507_LOWtemp_LOWsal', '20210507_HIGHtemp_HIGHsal', '20210507_LOWtemp_HIGHsal_b', '20210507_LOWtemp_HIGHsal')
# ANALYSIS :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Objective: use LoLinr to run all respiration rates in a non-bias and autonomous fashion
# Ouputs: there will be two main resources from this script:
# (1) cumulative spreasheet of all respiration rate value for each Channel on each day
# (2) a folder of plots from the LoLinR script to a plots folder - this will allow troubleshooting and sanity checks
# I. Call the cumulative dataframe that we will write to in the for loop below
df_total <- data.frame() # start dataframe
resp.table <- data.frame(matrix(nrow = 1, ncol = 8)) # create dataframe to save cumunalitively during for loop
colnames(resp.table) <- c('Date', 'Channel', 'Lpc', 'Leq' , 'Lz', 'alpha', 'Notes', 'Filename') # names for comuns in the for loop
# II.A Loop #1 - call filenames one at a time for analysis
for(i in 1:nrow(file.names.table)) { # for every file in list start at the first and run this following function
Resp.Data <- read.delim2(file = paste(path.p,'/',file.names.table[i,1], sep=''), header = TRUE,skip = 37) #reads in the data files
Resp.Data$date <- paste((sub("2021.*", "", Resp.Data$Date..Time..DD.MM.YYYY.HH.MM.SS.)), '2021', sep='') # date - use 'sub' to call everything before 2021, add back 2021 using paste
Resp.Data$time_Sec <- period_to_seconds(hms(substr((strptime(sub(".*2021/", "", Resp.Data$Date..Time..DD.MM.YYYY.HH.MM.SS.), "%I:%M:%S %p")) , 12,19))) # time - use 'sub' to call target time of the raw date time after 'year/' + strptime' convert to 24 hr clock + 'period_to_seconds' converts the hms to seconds
Resp.Data$seconds <- (Resp.Data$time_Sec - Resp.Data$time_Sec[1]) # secs - calc the sec time series
Resp.Data$minutes <- (Resp.Data$time_Sec - Resp.Data$time_Sec[1])/60 # mins - calc the minute time series
temperature_C <- as.numeric(Resp.Data$CH1.temp...C.[1])
barromP_kPa <- as.numeric(Resp.Data$Barometric.pressure..hPa.[1]) / 10
salinity.pp.thou <- as.numeric(Resp.Data$Salinity....[1])
Resp.Data <- Resp.Data %>% # use 'dplyr'
dplyr::filter(!Phase %in% 'Flush') %>% # remove the initial rows labeled flush
dplyr::select(c(date, seconds, minutes, contains(".O2...air.sat"))) # call unique column names for the 8 Channels
colnames(Resp.Data)[c(4:(ncol(Resp.Data)))] <- substr( ( colnames(Resp.Data)[c(4:(ncol(Resp.Data)))] ), 1,3) # clean these column names to make things easier - first 3 characters
# Truncate!
# the loligo recoreded values every second, this slows the model dramatically with >2000 values for each Channel, call every 30 seconds to speed this up
# discuss with collaborators on this truncated approach
Resp.Data_30sec = Resp.Data[seq(1, nrow(Resp.Data), 30), ]
# II.B Loop #2 - within each filename, call each Channel (% O2 sat.) to measure respiration rates, output plots and cumulative spreadsheet
for(j in 4:(ncol(Resp.Data_30sec))){
Resp_loop <- na.omit(Resp.Data_30sec[,c(3,j)]) # noticed some random rows have 'NaN' - so I will loop the min and Channels to ommit Nas before proceeding
Resp_loop$mgL <- DO.unit.convert(as.numeric(Resp_loop[,2]), # DO in percent air sat to be converted to mgL
DO.units.in = "pct", DO.units.out ="mg/L",
bar.units.in = "kPa", bar.press = barromP_kPa, bar.units.out = "kpa",
temp.C = temperature_C,
salinity.units = "pp.thou", salinity = salinity.pp.thou)
if (nrow(Resp_loop) < 1) {
resp.table$Date <- Resp.Data_30sec[1,1]
resp.table$Channel <- colnames(Resp_loop)[2]
resp.table[3:ncol(resp.table)] <- 'NA'
df <- data.frame(resp.table) # name dataframe for this single row
df_total <- rbind(df_total,df) #bind to a cumulative list dataframe
print(df_total) # print to monitor progress
} else {
model <- rankLocReg(
xall = as.numeric(Resp_loop[, 1]),
yall = as.numeric(Resp_loop[, 3]), # call x as the minute timeseries and y as the % air saturation of the particular Channel
alpha = a, # alpha was assigned earlier as 0.4 by the authors default suggestions - review Olito et al. and their github page for details
method = "pc",
verbose = TRUE)
sum.table <- summary(model)
resp.table$Date <- Resp.Data_30sec[1,1]
resp.table$Channel <- colnames(Resp_loop)[2]
resp.table$Lpc <- sum.table$Lcompare[3,6] # Lpc slope - call the column 'b1'
resp.table$Leq <- sum.table$Lcompare[2,6] # Leq slope - call the column 'b1'
resp.table$Lz <- sum.table$Lcompare[1,6] # Lz slope - call the column 'b1'
resp.table$alpha <- a
resp.table$Notes <- file.names.table[i,2]
resp.table$Filename <- file.names.table[i,1]
df <- data.frame(resp.table) # name dataframe for this single row
df_total <- rbind(df_total,df) #bind to a cumulative list dataframe
print(df_total) # print to monitor progress
# save plots every inside loop and name by date_run_vialposition
pdf(paste0("C:/Users/samjg/Documents/Github_repositories/Cvriginica_multistressor/Output/Respiration/plots_alpha0.4_increm30sec/",file.names.table[i,2],"_",colnames(Resp_loop)[2],"_regression.pdf"))
plot(model)
dev.off()
} # end of if else statement
} # end of inside for loop
} # end of outside for loop
df_total
df_total
file.names.table
# merge with the preexisiting table?
cumulative_resp_table <- read.csv(file=ouputNAME, header=T) #call the pre existing cumulative table
new_table <- rbind(cumulative_resp_table, df_total) # bind the new table from the for loop to the pre exisiting table
write.table(new_table,ouputNAME,sep=",", row.names=FALSE) # write out to the path names outputNAME
library(dplyr)
library(ggplot2)
# SET WORKING DIRECTORY :::::::::::::::::::::::::::::::::::::::::::::::
setwd("C:/Users/samjg/Documents/Github_repositories/Cvriginica_multistressor")
# LOAD DATA :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
exp_metadata <- read.csv(file="Data/ExperimentMetadata.csv", header=T) # treatment assignments to 'Chamber_Tank'
resp.ref <- read.csv(file="Data/Respiration/Reference_master.csv", header=T) # reference for the respirometry data - contains the 'Chamber_Tank' for each sensor channel (whether an animal or a blank)
resp.data <- read.csv(file="Output/Respiration/Cumulative_resp_alpha0.4.csv", header=T) # read the calculate raw rates from 'resp_LoLin' script - contains the calculated rate (not normalized for blanks) for each sensor-channel
# merge the exp_metadata with the resp.data
resp.ref_merged <- merge(exp_metadata, resp.ref, by = 'Chamber_tank', all=TRUE) # all TRUE allows us to keep the blanks
resp.data_merged <- merge(resp.data, resp.ref_merged, by = c('Date', 'Channel','Notes','Filename')) # out master file moving forward....
resp.data_merged$TempCarbSal <- paste(resp.data_merged$Temp, resp.data_merged$pCO2, resp.data_merged$Salinity, sep ='')
dates.runs <- resp.data_merged %>% # call table
dplyr::distinct(Date, Notes) # call all unique values for date run and sw condition
dates.runs <- na.omit(dates.runs)
# call dataframe and build table to rbind in for loop
blanks_total <- data.frame() # start dataframe
blanks.table <- data.frame(matrix(nrow = 1,ncol = 5)) # make a table template
colnames(blanks.table)<-c('Date', 'Notes', 'BLANK.mean.Lpc', 'BLANK.mean.Leq' , 'BLANK.mean.Lz') # names for comuns in the for loop
# for loop. objective = obtian a mean value for all blanks specific to date, run #, seawater treatment
for(i in 1:nrow(dates.runs)) {
data <- resp.data_merged %>%
dplyr::select(Date, Chamber_tank, Notes, Lpc, Leq, Lz) %>%
dplyr::filter(!is.na(Lpc)) %>% # ommits empty resp channels (if any)
dplyr::filter(Notes == dates.runs[i,2])
blanks <- data %>%
dplyr::filter(Chamber_tank == "blank") %>%
dplyr::summarise(mean_Lpc = mean(abs(Lpc)),
mean_Leq = mean(abs(Leq)),
mean_Lz = mean(abs(Lz)))
blanks.table$Date <- dates.runs[i,1] # all files have date in the form of yyyymmdd at the start of each csv name
#blanks.table$RUN <- dates.runs[i,2] # assign the run to the number in the title for the trials completed that day
blanks.table$Notes <- dates.runs[i,2]
blanks.table$BLANK.mean.Lpc <- blanks[1,1]
blanks.table$BLANK.mean.Leq <- blanks[1,2]
blanks.table$BLANK.mean.Lz <- blanks[1,3]
# blanks.table$alpha <- data[1,9] # set at start of script - reresents the proportion of data for final estimate of slopes (Lpc, Leq, Lz)
df <- data.frame(blanks.table) # name dataframe for this singl e row
blanks_total <- rbind(blanks_total,df) #bind to a cumulative list dataframe
print(blanks_total) # print to monitor progress
}
blanks_total # view blanks table
Resp.Master <- merge(resp.data_merged, blanks_total, by=c("Date", "Notes")) %>% # NOTE: this repeats for every distinct length value
dplyr::filter(!Chamber_tank =='blank') %>%
dplyr::mutate(resp_norm = Lpc - BLANK.mean.Lpc) # ommits respiration rate values showing an increase in O2 over time
# NOTE: look at the following table to troubleshoot if needed
Resp.outliers <- Resp.Master %>% dplyr::filter(resp_norm > 0)
# calculate resp rates
vial.vol <- 2 # milliliters (ml)
Resp.Master$resp_norm
Resp.Master_OM <- Resp.Master %>% dplyr::filter(!resp_norm > 0)
Resp.Master_OM
Resp.Master_OM$resp_percO2sat_L_hr <- (abs(Resp.Master_OM$resp_norm)*(vial.vol/1000)*(60)) # correct for Liters and hours (currently in minutes fro the resp.lolin.R script)
Resp.Master_OM$resp_percO2sat_L_hr
Resp.Master_OM$resp_ug_L_hr <- ( (abs(Resp.Master_OM$resp_norm)/1000)*(vial.vol/1000)*(60)) # correct for Liters and hours (currently in minutes fro the resp.lolin.R script)
Resp.Master_OM$resp_ug_L_hr
Resp.Master_OM$resp_ug_L_hr <- ( (abs(Resp.Master_OM$resp_norm)*1000)*(vial.vol/1000)*(60)) # correct for Liters and hours (currently in minutes fro the resp.lolin.R script)
Resp.Master_OM$resp_ug_L_hr
(abs(Resp.Master_OM$resp_norm)*1000)*(vial.vol/1000)
(vial.vol/1000)
(abs(Resp.Master_OM$resp_norm)*1000)
Resp.Master_OM$resp_norm
(abs(Resp.Master_OM$resp_norm)*1000)*(vial.vol/1000)
Resp.Master_OM$resp_ug_L_hr <- ( (abs(Resp.Master_OM$resp_norm)*1000)*(vial.vol/1000)*(60)) # correct for Liters and hours (currently in minutes fro the resp.lolin.R script)
Resp.Master_OM$resp_ug_L_hr
# mean sd rates
mean(Resp.Master_OM$resp_ug_L_hr)
sd(Resp.Master_OM$resp_ug_L_hr)
Resp.Master_OM
Reap_0507 <- Resp.Master_OM %>% dplyr::filter(Date %in% 5/7/2021)
Reap_0507 <- Resp.Master_OM %>% dplyr::filter(Date %in% 5/07/2021)
Reap_0507 <- Resp.Master_OM %>% dplyr::filter(Date %in% '5/07/2021')
Resp_0507 <- Resp.Master_OM %>% dplyr::filter(Date %in% '5/07/2021')
Resp_0507
Resp.Master_OM
Resp_0507 <- Resp.Master_OM %>% dplyr::filter(Date %in% '5/7/2021')
Resp_0507
# model effect of treatment on resp rate 20210507
aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0507))
# model effect of treatment on resp rate 20210507
mode <- aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0507))
# model effect of treatment on resp rate 20210507
mod <- aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0507))
summary(mod)
ggboxplot(Resp_0507, x = "Salinity", y = "resp_ug_L_hr", ylab = "µg.L.hr.indiv", fill = "Treat",
palette = c("#FC4E07", "#00AFBB"),add = "jitter", title = "Pre-conditioning", xlab = "Initial pCO2 Treatment")
library(ggpubr)
ggboxplot(Resp_0507, x = "Salinity", y = "resp_ug_L_hr", ylab = "µg.L.hr.indiv", fill = "Treat",
palette = c("#FC4E07", "#00AFBB"),add = "jitter", title = "Pre-conditioning", xlab = "Initial pCO2 Treatment")
ggboxplot(Resp_0507, x = "Salinity", y = "resp_ug_L_hr", ylab = "µg.L.hr.indiv", fill = "Salinity",
palette = c("#FC4E07", "#00AFBB"),add = "jitter", title = "Pre-conditioning", xlab = "Initial pCO2 Treatment")
Resp_0507
Resp_0507_FIGS <- Resp_0507 %>% dplyr::select(c('resp_ug_L_hr', 'Temp', 'pCO2', 'Salinity'))
Resp_0507_melt <- melt(Resp_0507_FIGS, id=c("resp_ug_L_hr"))
install.packages('reshape2')
library('reshape2')
Resp_0507_melt <- melt(Resp_0507_FIGS, id=c("resp_ug_L_hr"))
Resp_0507_melt
ggplot(Resp_0507_melt, aes(x=value, y=resp_ug_L_hr, color = value)) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_line(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable)
ggplot(Resp_0507_melt, aes(x=value, y=resp_ug_L_hr, color = value)) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_line(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free")
ggplot(Resp_0507_melt, aes(x=value, y=resp_ug_L_hr, color = value)) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_line(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
ggplot(Resp_0507_melt, aes(x=value, y=resp_ug_L_hr, color = value)) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_line(size=0.2, alpha=0.1) +
theme_bw()
ggplot(Resp_0507_melt, aes(x=value, y=resp_ug_L_hr, color = value)) +
theme(panel.grid=element_blank())
Resp_0507_melt
ggplot(Resp_0507_melt, aes(x=value, y=resp_ug_L_hr, fill = value)) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_line(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
ggplot(Resp_0507_melt, aes(x=value, y=resp_ug_L_hr, group = variable,fill = value)) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_line(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
ggplot(Resp_0507_FIGS, aes(value, resp_ug_L_hr , fill = factor(value))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_line(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
Resp_0507_FIGS
ggplot(Resp_0507_melt, aes(value, resp_ug_L_hr , fill = factor(value))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_line(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
Resp_0507_melt
Resp_0507_FIGS
ggplot(Resp_0507_FIGS, aes(Temp , resp_ug_L_hr , fill = factor(Temp )))
ggplot(Resp_0507_FIGS, aes(Temp , resp_ug_L_hr , fill = factor(Temp ))) +
theme(panel.grid=element_blank())
ggplot(Resp_0507_FIGS, aes(Temp , resp_ug_L_hr , fill = factor(Temp ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_line(size=0.2, alpha=0.1)
ggplot(Resp_0507_FIGS, aes(Temp , resp_ug_L_hr , fill = factor(Temp ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1)
ggplot(Resp_0507_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
# model effect of treatment on resp rate 20210507
mod <- aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0507))
summary(mod)
Resp_0507_FIGS
Resp_0507_FIGS_2 <- Resp_0507_FIGS %>% dplyr::mutate(fll.treatment <- paste(Temp, pCO2, Salinity,sep=''))
Resp_0507_FIGS_2
Resp_0507_FIGS_2 <- Resp_0507_FIGS %>% dplyr::mutate(fll.treatment <- (paste(Temp, pCO2, Salinity,sep='')))
Resp_0507_FIGS_2
Resp_0507_FIGS_2 <- Resp_0507_FIGS %>% dplyr::mutate(fll.treatment = (paste(Temp, pCO2, Salinity,sep='')))
Resp_0507_FIGS_2
Resp_0507_FIGS_2 <- Resp_0507_FIGS %>% dplyr::mutate(full.treatment = (paste(Temp, pCO2, Salinity,sep='')))
ggplot(Resp_0507_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
# scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
ggplot(Resp_0507_FIGS_2, aes(full.treatment, resp_ug_L_hr , fill = factor(full.treatment))) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
Resp_0507
Resp_0507 <- Resp.Master_OM %>% dplyr::filter(Date %in% '5/7/2021') %>% dplyr::filter(!resp_ug_L_hr > 20)
# model effect of treatment on resp rate 20210507
mod <- aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0507))
summary(mod)
Resp_0507_FIGS <- Resp_0507 %>% dplyr::select(c('resp_ug_L_hr', 'Temp', 'pCO2', 'Salinity'))
Resp_0507_melt <- melt(Resp_0507_FIGS, id=c("resp_ug_L_hr"))
ggplot(Resp_0507_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
Resp_0507_FIGS_2 <- Resp_0507_FIGS %>% dplyr::mutate(full.treatment = (paste(Temp, pCO2, Salinity,sep='')))
ggplot(Resp_0507_FIGS_2, aes(full.treatment, resp_ug_L_hr , fill = factor(full.treatment))) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
Plot <- Resp_0507_FIGS %>%
dplyr::mutate(full.treatment = (paste(Temp, pCO2, Salinity,sep=''))) %>%
dplyr::mutate(full.treatment = fct_relevel(full.treatment,
"HHH", "HLH", "LHH",'LLH',
"HHH", "HLH", "LHH",'LLH')) %>%
ggplot(aes(full.treatment, resp_ug_L_hr , fill = factor(full.treatment))) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
library('forcats')
Plot <- Resp_0507_FIGS %>%
dplyr::mutate(full.treatment = (paste(Temp, pCO2, Salinity,sep=''))) %>%
dplyr::mutate(full.treatment = fct_relevel(full.treatment,
"HHH", "HLH", "LHH",'LLH',
"HHH", "HLH", "LHH",'LLH')) %>%
ggplot(aes(full.treatment, resp_ug_L_hr , fill = factor(full.treatment))) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
full.treatment
Plot <- Resp_0507_FIGS %>%
dplyr::mutate(full.treatment = (paste(Temp, pCO2, Salinity,sep=''))) %>%
dplyr::mutate(full.treatment = fct_relevel(full.treatment,
"HHH", "HLH", "LHH",'LLH',
"HHL", "HLL", "LHL",'LLL')) %>%
ggplot(aes(full.treatment, resp_ug_L_hr , fill = factor(full.treatment))) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
Plot <- Resp_0507_FIGS %>%
dplyr::mutate(full.treatment = (paste(Temp, pCO2, Salinity,sep=''))) %>%
dplyr::mutate(full.treatment = fct_relevel(full.treatment,
"HHH", "HLH", "LHH",'LLH',
"HHL", "LHL",'LLL')) %>%
ggplot(aes(full.treatment, resp_ug_L_hr , fill = factor(full.treatment))) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
Plot
Plot <- Resp_0507_FIGS %>%
dplyr::mutate(full.treatment = (paste(Temp, pCO2, Salinity,sep=''))) %>%
dplyr::mutate(full.treatment = fct_relevel(full.treatment,
"HHH", "HLH", "LHH",'LLH',
"HHL", "LHL",'LLL')) %>%
ggplot(aes(full.treatment, resp_ug_L_hr , fill = factor(full.treatment))) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
Plot
ggplot(Resp_0507_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
ggplot(Resp_0507_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
# calculate resp rates
vial.vol <- 0.08 # milliliters (ml)
Resp.Master_OM$resp_ug_L_hr <- ( (abs(Resp.Master_OM$resp_norm)*1000)*(vial.vol/1000)*(60)) # correct for Liters and hours (currently in minutes fro the resp.lolin.R script)
# mean sd rates
mean(Resp.Master_OM$resp_ug_L_hr)
sd(Resp.Master_OM$resp_ug_L_hr)
Resp_0507 <- Resp.Master_OM %>% dplyr::filter(Date %in% '5/7/2021') %>% dplyr::filter(!resp_ug_L_hr > 20)
# model effect of treatment on resp rate 20210507
mod <- aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0507))
summary(mod)
Resp_0507_FIGS <- Resp_0507 %>% dplyr::select(c('resp_ug_L_hr', 'Temp', 'pCO2', 'Salinity'))
Resp_0507_melt <- melt(Resp_0507_FIGS, id=c("resp_ug_L_hr"))
ggplot(Resp_0507_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
Resp_0507 <- Resp.Master_OM %>% dplyr::filter(Date %in% '5/7/2021') %>% dplyr::filter(!resp_ug_L_hr >1)
# model effect of treatment on resp rate 20210507
mod <- aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0507))
summary(mod)
Resp_0507_FIGS <- Resp_0507 %>% dplyr::select(c('resp_ug_L_hr', 'Temp', 'pCO2', 'Salinity'))
Resp_0507_melt <- melt(Resp_0507_FIGS, id=c("resp_ug_L_hr"))
ggplot(Resp_0507_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
Resp_0430 <- Resp.Master_OM %>% dplyr::filter(Date %in% '4/30/2021')
Resp_0430
# model effect of treatment on resp rate 20210507
Resp_0430 <- Resp.Master_OM %>% dplyr::filter(Date %in% '4/30/2021') %>% dplyr::filter(!resp_ug_L_hr >1)
mod <- aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0430))
summary(mod)
Resp_0430_FIGS <- Resp_0507 %>% dplyr::select(c('resp_ug_L_hr', 'Temp', 'pCO2', 'Salinity'))
Resp_0430_melt <- melt(Resp_0430_FIGS, id=c("resp_ug_L_hr"))
ggplot(Resp_0430_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
Resp_0430_FIGS <- Resp_0430 %>% dplyr::select(c('resp_ug_L_hr', 'Temp', 'pCO2', 'Salinity'))
Resp_0430_melt <- melt(Resp_0430_FIGS, id=c("resp_ug_L_hr"))
ggplot(Resp_0430_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
Resp_0430 <- Resp.Master_OM %>% dplyr::filter(Date %in% '4/30/2021')
mod <- aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0430))
summary(mod)
Resp_0430_melt <- melt(Resp_0430_FIGS, id=c("resp_ug_L_hr"))
ggplot(Resp_0430_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
# model effect of treatment on resp rate 20210507
Resp_0430 <- Resp.Master_OM %>% dplyr::filter(Date %in% '4/30/2021') %>% dplyr::filter(!resp_ug_L_hr >1)
mod <- aov(lm(resp_ug_L_hr~Temp*pCO2*Salinity,data=Resp_0430))
summary(mod)
Resp_0430_FIGS <- Resp_0430 %>% dplyr::select(c('resp_ug_L_hr', 'Temp', 'pCO2', 'Salinity'))
Resp_0430_melt <- melt(Resp_0430_FIGS, id=c("resp_ug_L_hr"))
ggplot(Resp_0430_melt, aes(value , resp_ug_L_hr , fill = factor(value ))) +
theme(panel.grid=element_blank()) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw() +
facet_wrap(~variable, scales = "free_y")
Plot <- Resp_0430_FIGS %>%
dplyr::mutate(full.treatment = (paste(Temp, pCO2, Salinity,sep=''))) %>%
dplyr::mutate(full.treatment = fct_relevel(full.treatment,
"HHH", "HLH", "LHH",'LLH',
"HHL", "LHL",'LLL')) %>%
ggplot(aes(full.treatment, resp_ug_L_hr , fill = factor(full.treatment))) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
Plot
Plot <- Resp_0430_FIGS %>%
dplyr::mutate(full.treatment = (paste(Temp, pCO2, Salinity,sep=''))) %>%
dplyr::mutate(full.treatment = fct_relevel(full.treatment,
"HHH", "HLH", "LHH",'LLH',
"HHL", "HLL", "LHL", 'LLL')) %>%
ggplot(aes(full.treatment, resp_ug_L_hr , fill = factor(full.treatment))) +
scale_color_manual(values=c("#56B4E9","#D55E00")) +
geom_point(shape = 21, size = 2, position = position_jitterdodge(jitter.width = 0.5))+
geom_boxplot(size=0.2, alpha=0.1) +
theme_bw()
Plot