-
Notifications
You must be signed in to change notification settings - Fork 0
/
99_SM_plots.Rmd
1270 lines (1163 loc) · 58.6 KB
/
99_SM_plots.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
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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
```{r, include=FALSE}
library(maptools)
library(RColorBrewer)
library(ggplot2)
library(dplyr)
library(maps)
library(mapdata)
library(mapproj)
knitr::opts_chunk$set(warning=FALSE, message = FALSE)
new_pento <- filter(pento, SpeciesCode != 'CH.ORNA') %>%
mutate(j_fg = as.character(j_fg)) %>%
mutate(j_fg = replace(j_fg, j_fg == 'He', 'HE/DE')) %>%
mutate(j_fg = factor(.$j_fg, levels=c('Pi', 'BI', 'ZP', 'HE/DE', 'C')))
```
```{r, echo=FALSE, fig.height=6, fig.width=6, fig.cap='**Figure S1.** Study site, Kiritimati (Christmas) Island, showing the 23 sampling locations around the atoll.'}
# Kiritimati map
kiM <- readShapePoly("KI_maps/Line_v3_Island__Kiritimati",
proj4string=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
)
sites <- read.csv(file = "KI_maps/Sites.csv", header = TRUE,
stringsAsFactors = FALSE) %>% dplyr::as_data_frame()
jd_sites <- subset(sites, sites$SiteName %in% unique(pento$Site))
# Must tell R what the coordinate values are. This does not need to be set more
# than once.
coordinates(jd_sites)<-c("Longitude","Latitude")
#proj4string(sites09)<- CRS("+proj=longlat+ellps=WGS84")
KI_map <- plot(kiM,
col = ifelse(kiM$RB_DEPTH_A == "land", "light grey", "dark grey"),
axes = FALSE,
xlim = c(-157.6, -157.1), ylim = c(1.6, 2.15)
)
par(mar = c(5.3, 5.1, 4.1, 5.1))
#box(bty = 'L')
points(jd_sites, pch = 21, col = "black", bg = "white", cex = 1.1)
points(jd_sites, pch = 21, col = "black", bg = "black", cex = 0.3)
#points(jd_sites, pch = 21, cex = 1.25, bg = as.character(jd_sites$colour))
axis(side = 2, cex.axis = 0.8, pos = -157.6) #mgp = c(2, 0.5, 0))
axis(side = 1, cex.axis = 0.8, pos = 1.6)
title(xlab = "Longitude", line = 2, ylab = "Latitude")
#mtext("Latitude", side = 2, line = 1)
# legend(x = -157.583, y = 1.76,
# legend = fp_colours$reg,
# pch = 21,
# pt.bg = as.character(fp_colours$colour),
# bty = 'n',
# cex = 0.7,
# pt.cex = 1.2,
# y.intersp = 1.1
# )
map.scale(x = -157.45, y = 1.68, relwidth = 0.2, cex = 0.7, ratio = FALSE)
x <- c(-157.56, -157.573, -157.56, -157.547, -157.56) + 0.04
y <- c(2.08, 2.04, 2.05, 2.04, 2.08) - 0.38
polygon(x = x, y = y, border = "black", col = "black")
text(x = x[3], y = 1.72, "N")
```
--------------------------------------------------------------------------------
```{r, include=FALSE}
#===============================================================================
# Predator prey size graphs
#===============================================================================
#===============================================================================
# STANDARD LENGTH PRED - PREY
# Graphs for piscivores prey size - predator GAPE HEIGHT
P_prey_SL <- prey_PiBI[which(prey_PiBI$j_fg == 'Pi'), ]
P_prey_SL <- mutate(P_prey_SL, j_fg = 'All Piscivores') %>% filter(!is.na(gh))
df.n <- ddply(.data=P_prey_SL, .(j_fg), summarize, n=paste("n ==", length(gh)))
pisc_prey <-
ggplot(data = P_prey_SL, aes(x = gh, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
scale_shape_manual(values=c(1, 19)) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
facet_wrap(~ j_fg)
df.n <- ddply(.data=filter(P_prey_SL, Family == 'Lutjanidae'), .(j_fg), summarize, n=paste("n ==", length(gh)))
pisc_prey_lut <-
ggplot(data = filter(P_prey_SL, Family == 'Lutjanidae'), aes(x = gh, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
scale_shape_manual(values=c(1, 19)) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
theme(axis.text.y = element_blank()) +
facet_wrap(~ Family)
df.n <- ddply(.data=filter(P_prey_SL, Family == 'Serranidae'), .(j_fg), summarize, n=paste("n ==", length(gh)))
pisc_prey_ser <-
ggplot(data = filter(P_prey_SL, Family == 'Serranidae'), aes(x = gh, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
scale_shape_manual(values=c(1, 19)) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
theme(axis.text.y = element_blank()) +
facet_wrap(~ Family)
# Benthic invertivore stomach contents for predator GAPE HEIGHT
B_prey_SL <- prey_PiBI[which(prey_PiBI$j_fg == 'BI'), ]
B_prey_SL <- mutate(B_prey_SL, j_fg = 'All Benthic Invertivores') %>% filter(!is.na(gh))
# Graph of just benthic invertivore stomach contents:
df.n <- ddply(.data=B_prey_SL, .(j_fg), summarize, n=paste("n ==", length(j_fg)))
benth_prey <-
ggplot(data = B_prey_SL, aes(x = gh, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
scale_shape_manual(values=c(1, 19)) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
theme(axis.text.y = element_blank()) +
facet_wrap(~ j_fg)
B_prey_SL <- prey_PiBI[which(prey_PiBI$j_fg == 'BI'), ]
B_prey_SL <- mutate(B_prey_SL, j_fg = 'All Benthic Invertivores') %>% filter(!is.na(gh))
# Graph of just benthic invertivore stomach contents:
df.n <- ddply(.data=filter(B_prey_SL, Family == 'Mullidae'), .(j_fg), summarize, n=paste("n ==", length(j_fg)))
benth_prey_mul <-
ggplot(data = filter(B_prey_SL, Family == 'Mullidae'), aes(x = gh, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
scale_shape_manual(values=c(1, 19)) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
theme(axis.text.y = element_blank()) +
facet_wrap(~ Family)
# Gape width
P_prey_SL <- prey_PiBI[which(prey_PiBI$j_fg == 'Pi'), ]
P_prey_SL <- mutate(P_prey_SL, j_fg = 'All Piscivores') %>% filter(!is.na(gw))
df.n <- ddply(.data=P_prey_SL, .(j_fg), summarize, n=paste("n ==", length(gw)))
pisc_prey_gw <-
ggplot(data = P_prey_SL, aes(x = gw, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
scale_shape_manual(values=c(1, 19)) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
facet_wrap(~ j_fg)
df.n <- ddply(.data=filter(P_prey_SL, Family == 'Lutjanidae'), .(j_fg), summarize, n=paste("n ==", length(gw)))
pisc_prey_lut_gw <-
ggplot(data = filter(P_prey_SL, Family == 'Lutjanidae'), aes(x = gw, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
scale_shape_manual(values=c(1, 19)) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
theme(axis.text.y = element_blank()) +
facet_wrap(~ Family)
df.n <- ddply(.data=filter(P_prey_SL, Family == 'Serranidae'), .(j_fg), summarize, n=paste("n ==", length(gw)))
pisc_prey_ser_gw <-
ggplot(data = filter(P_prey_SL, Family == 'Serranidae'), aes(x = gw, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
scale_shape_manual(values=c(1, 19)) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
theme(axis.text.y = element_blank()) +
facet_wrap(~ Family)
# Benthic invertivore stomach contents for predator STANDARD LENGTH
B_prey_SL <- prey_PiBI[which(prey_PiBI$j_fg == 'BI'), ]
B_prey_SL <- mutate(B_prey_SL, j_fg = 'All Benthic Invertivores') %>% filter(!is.na(gw))
# Graph of just benthic invertivore stomach contents:
df.n <- ddply(.data=B_prey_SL, .(j_fg), summarize, n=paste("n ==", length(j_fg)))
benth_prey_gw <-
ggplot(data = B_prey_SL, aes(x = gw, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
scale_shape_manual(values=c(1, 19)) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
theme(axis.text.y = element_blank()) +
facet_wrap(~ j_fg)
B_prey_SL <- prey_PiBI[which(prey_PiBI$j_fg == 'BI'), ]
B_prey_SL <- mutate(B_prey_SL, j_fg = 'All Benthic Invertivores') %>% filter(!is.na(gw))
# Graph of just benthic invertivore stomach contents:
df.n <- ddply(.data=filter(B_prey_SL, Family == 'Mullidae'), .(j_fg), summarize, n=paste("n ==", length(j_fg)))
benth_prey_mul_gw <-
ggplot(data = filter(B_prey_SL, Family == 'Mullidae'), aes(x = gw, y = pSize)) +
geom_point(aes(shape = pType)) +
geom_point(aes(x = 100, y = 258), alpha = 0.0) +
scale_shape_manual(values=c(1, 19)) +
stat_quantile(geom = "quantile", quantiles = c(0.10, 0.50, 0.90), method = "rq",
colour = "black") +
geom_text(data = df.n, aes(x = 25, y = 230, label = n), parse = TRUE,
size = 3, hjust = 0) +
theme_bw() +
theme(panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black'),
legend.position = "none",
axis.title = element_blank(),
axis.ticks.length = unit(-0.2, "cm"),
axis.text.y = element_text(margin = margin(0, 8, 0, 0)),
axis.text.x = element_text(margin = margin(8, 0, 0, 0), vjust = 1),
strip.background = element_blank()) +
theme(axis.text.y = element_blank()) +
facet_wrap(~ Family)
```
```{r, echo=FALSE, fig.height=6.4, fig.width=11, fig.cap='**Figure S2.** Quantile regressions (10th, 50th, and 90th quantiles) of the relationships between prey total length (mm) and (a) predator gape height (mm) and (b) for predator gape width for all piscivores,the two most sampled piscivore families Lutjanidae and Serranidae, all benthic invertivores, and the most sampled benthic invertivore *Parupeneus insularis* . Each point represents a single fish (open circles) or invertebrate (solid circles) prey item found in a predator stomach. Prey size is the measured length (mm) of the intact or partially digested prey items, and hence taken to be the minimum prey size.'}
master_layout <-
grid.layout(nrow = 4, ncol = 10,
widths = unit(c(0.1, 1.2, 0.1, 1, 0.1, 1, 0.1, 1, 0.1, 1), "null"),
heights = unit(c(1, 0.15, 1, 0.15), "null"))
grid.newpage()
pushViewport(viewport(layout = master_layout))
print(pisc_prey, vp = set_vp(1, 2))
print(pisc_prey_lut, vp = set_vp(1, 4))
print(pisc_prey_ser, vp = set_vp(1, 6))
print(benth_prey, vp = set_vp(1, 8))
print(benth_prey_mul, vp = set_vp(1, 10))
print(pisc_prey_gw, vp = set_vp(3, 2))
print(pisc_prey_lut_gw, vp = set_vp(3, 4))
print(pisc_prey_ser_gw, vp = set_vp(3, 6))
print(benth_prey_gw, vp = set_vp(3, 8))
print(benth_prey_mul_gw, vp = set_vp(3, 10))
grid.text(
expression( paste("Gape height (", mm, ")", sep = "") ),
#vp = viewport(layout.pos.row = 2, layout.pos.col = 2:4),
vp = viewport(layout.pos.row = 2, layout.pos.col = 6),
gp = gpar(fontsize = 10), vjust = -0.25
)
grid.text(
expression( paste("Gape width (", mm, ")", sep = "") ),
#vp = viewport(layout.pos.row = 2, layout.pos.col = 2:4),
vp = viewport(layout.pos.row = 4, layout.pos.col = 6),
gp = gpar(fontsize = 10), vjust = -0.25
)
grid.text(
"Prey total length (mm)",
vp = viewport(layout.pos.row = 1, layout.pos.col = 1),
gp = gpar(fontsize = 10), rot = 90, vjust = 0.5#1.6
)
grid.text(
"Prey total length (mm)",
vp = viewport(layout.pos.row = 3, layout.pos.col = 1),
gp = gpar(fontsize = 10), rot = 90, vjust = 0.5#1.6
)
grid.text(
"a)", vp = viewport(layout.pos.row = 1, layout.pos.col = 1),
gp = gpar(fontsize = 9), vjust = -10.5 #-13
)
grid.text(
"b)", vp = viewport(layout.pos.row = 3, layout.pos.col = 1),
gp = gpar(fontsize = 9), vjust = -10.5 #-13
)
```
```{r, include=FALSE}
#===============================================================================
# Absolute/Relative gape size - code
#===============================================================================
# Pento factored by functional group then absolute gape size
SpeciesCode <- c('CE.UROD', 'LU.BOHA', 'CA.MELA', 'AP.FURC', 'CE.ARGU', 'VA.LOUT',
'PA.ARCA', 'PA.INSU', 'MO.GRAN',
'CH.VAND', 'PS.BART', 'PS.OLIV', 'PS.DISP', 'PT.TILE', 'CA.TERE',
'CE.FLAV', 'AC.NIGR', 'AC.OLIV', 'CH.SORD', 'SC.FREN', 'SC.RUBR'
)
sp_name_by_slope <-
c('Cephalopholis urodeta', 'Lutjanus bohar', 'Caranx melampygus',
'Aphareus furca', 'Cephalopholis argus', 'Variola louti',
'Paracirrhites arcatus', 'Parupeneus insularis', 'Monotaxis grandoculis',
'Chromis vanderbilti', 'Pseudanthias bartlettorum', 'Pseudanthias olivaceus',
'Pseudanthias dispar', 'Pterocaesio tile', 'Caesio tile',
'Centropyge flavissima', 'Acanthurus nigricans', 'Acanthurus olivaceus',
'Chlorurus sordidus', 'Scarus frenatus', 'Scarus rubroviolaceus')
spp_key <- data.frame(SpeciesCode, sp_name_by_slope)
pento_by_slope <- merge(x = new_pento, y = spp_key, all.x = TRUE, all.y = FALSE)
#pento_by_slope$SpeciesCode <- factor(pento_by_slope$SpeciesCode, levels = SpeciesCode)
pento_by_slope$sp_name_by_slope <- factor(pento_by_slope$sp_name_by_slope, levels = rev(sp_name_by_slope))
#-------------------------------------------------------------------------------
# Removing ceargu_out (CE.ARGU outlier)
#-------------------------------------------------------------------------------
# Finding outlier in boxplot Cephalopholis argus
ceargu_df <- fish[(which(fish$SpeciesCode == "CE.ARGU")), ]
ceargu_out <- which(ceargu_df$gh_ratio == max(ceargu_df$gh_ratio))
ceargu_df[ceargu_out, ]
# SpecimenID Family Order Genus SpeciesCode j_fg Site
#633 KIF12_171 Serranidae Perciformes Cephalopholis CE.ARGU Pi 40
# Region TL SL FL wt length.cm. a..cm. b..cm. calc_wt gh gw
#633 HP.MF 138.6 134.2 NA 380 NA NA NA NA 63.9 66.5
# dissected_by stomach_contents prey_size coll_notes dis_notes ga
#633 MW shrimp; see photo 30.1mm 3337.432
# gh_ratio gw_ratio ga_ratio observer_id
#633 0.476155 0.4955291 0.1853136 13
bp_outlier <- which(pento_by_slope$SpecimenID == "KIF12_171")
pento_by_slope <- pento_by_slope[-bp_outlier, ]
# With facets:
fgs <- list('Pi' = "PI",
'BI' = "BI",
'ZP' = "ZP",
'HE/DE' = "HE/DE")
fg_labeller <- function(variable, value){
return(fgs[value])
}
abs_gh <-
ggplot(pento_by_slope, aes(.id, value, dodge = j_fg)) +
geom_boxplot(aes(x=sp_name_by_slope, y=gw)) +
xlab("Species") +
ylab("Absolute gape width (mm)\n") +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
theme(axis.text.x = element_blank()) +#element_text(angle=45, colour="black", hjust=1, size = 9)) +
theme(axis.text.y = element_text(colour="black")) +
theme(axis.title.x = element_blank()) + #element_text(vjust = -0.2, size = 9)) +
theme(axis.title.y = element_text(vjust = 0.15, size = 9)) +
theme(legend.position = c(0.64, 0.9)) +
theme(legend.background = element_rect(fill = "#FFFFFFaa", colour = 'NA')) +
theme(legend.text = element_text(size = 8)) +
theme(panel.margin = unit(0.8, "cm")) +
theme(panel.border = element_blank()) +
theme(strip.background = element_rect(fill = "white", colour = "white")) +
theme(axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black')) +
facet_grid(. ~ j_fg, space = "free", scales = "free", labeller = labeller(fgs = fg_labeller))
# RELATIVE GAPE WIDTH- CODE
rel_gh <-
ggplot(pento_by_slope, aes(.id, value, dodge = j_fg)) +
geom_boxplot(aes(x=sp_name_by_slope, y=gw/SL)) +
xlab("Species") +
ylab("Relative gape width\n") +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
theme(axis.text.x = element_text(angle=45, colour="black", hjust=1, size = 9)) +
theme(axis.text.y = element_text(colour="black")) +
theme(axis.title.x = element_text(vjust = -0.2, size = 9)) +
theme(axis.title.y = element_text(vjust = 0.15, size = 9)) +
theme(legend.position = c(0.64, 0.9)) +
theme(legend.background = element_rect(fill = "#FFFFFFaa", colour = 'NA')) +
theme(legend.text = element_text(size = 8)) +
theme(panel.margin = unit(0.8, "cm")) +
theme(panel.border = element_blank()) +
theme(strip.background = element_rect(fill = "white", colour = "white"),
strip.text = element_blank()) +
theme(axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black')) +
facet_grid(. ~ j_fg, space = "free", scales = "free", labeller = labeller(fgs = fg_labeller))
```
```{r, echo=FALSE, fig.height = 6, fig.width = 8, fig.cap = '**Figure S3.** (a) Absolute gape width (mm) and (b) relative gape width, calculated as gape width (mm) / standard length (mm) for all species ordered within each functional group by decreasing absolute gape height. A single outlier (67 mm) for *Cephalopholis argus* is not shown.'}
# ABSOLUTE GAPE WIDTH PLOT
master_layout <-
grid.layout(nrow = 4, ncol = 2,
widths = unit(c(0.03, 1), "null"),
heights = unit(c(0.65, 0.05, 1, 0.05), "null"))
grid.newpage()
pushViewport(viewport(layout = master_layout))
print(abs_gh, vp = set_vp(1, 2))
print(rel_gh, vp = set_vp(3, 2))
grid.text("a)", vp = viewport(layout.pos.row = 1, layout.pos.col = 1),
gp = gpar(fontsize = 9), hjust = 0, vjust = -10)
grid.text("b)", vp = viewport(layout.pos.row = 3, layout.pos.col = 1),
gp = gpar(fontsize = 9), hjust = 0, vjust = -16)
# Figure label
grid.text("Figure S3", vp = viewport(layout.pos.row = 4, layout.pos.col = 1),
gp = gpar(fontsize = 9), hjust = 0, vjust = 0)
```
--------------------------------------------------------------------------------
```{r, include=FALSE}
# CODE FOR VISREG STYLE FG COMPARISON
# Fit random effects model with family as a random effect (phylogenetic non-independence)
#-------------------------------------------------------------------------------
# SMA regression for each species
all_spp_GH <- sma(gh ~ wt * SpeciesCode, data = new_pento, log = "xy",
method = "SMA", robust = T, slope.test = 1,
multcomp = F, multcompmethod = "adjusted")
#check_assump(allGA, "Species Gape Area All")
allGH_bySPP_summ <- mk_spp_summary(all_spp_GH, 21, grouping=TRUE)
all_spp_GW <- sma(gw ~ wt * SpeciesCode, data = new_pento, log = "xy",
method = "SMA", robust = T, slope.test = 1,
multcomp = F, multcompmethod = "adjusted")
#check_assump(allGA, "Species Gape Area All")
allGW_bySPP_summ <- mk_spp_summary(all_spp_GW, 21, grouping=TRUE)
spp_names <- c("Acanthurus nigricans", "Acanthurus olivaceus", "Aphareus furca",
"Lutjanus bohar", "Caesio teres", "Pterocaesio tile",
"Pseudanthias bartlettorum", "Pseudanthias dispar",
"Pseudanthias olivaceus",
"Cephalopholis argus", "Cephalopholis urodeta", "Variola louti",
"Chromis vanderbilti", "Monotaxis grandoculis",
"Chlorurus sordidus", "Scarus frenatus", "Scarus rubroviolaceus",
"Paracirrhites arcatus", "Caranx melampygus",
"Parupeneus insularis", "Centropyge flavissima")
spp_codes <- c('AC.NIGR', 'AC.OLIV', 'AP.FURC', 'LU.BOHA', 'CA.TERE',
'PT.TILE', 'PS.BART', 'PS.DISP', 'PS.OLIV', 'CE.ARGU',
'CE.UROD', 'VA.LOUT', 'CH.VAND', 'MO.GRAN', 'CH.SORD',
'SC.FREN', 'SC.RUBR', 'PA.ARCA', 'CA.MELA', 'PA.INSU',
'CE.FLAV')
# Create lookup dataframes
fg_lookup <- unique(data.frame('codes' = new_pento$SpeciesCode, 'fg' = new_pento$j_fg))
spp_lookup_df <- data.frame('species' = spp_names, 'codes' = spp_codes)
fam_lookup <- ddply(fish, .(SpeciesCode), summarise, 'Family' = unique(Family),
'Order' = unique(Order))
spp_lookup_df <- left_join(spp_lookup_df, fg_lookup) %>%
left_join(., fam_lookup, by = c('codes' = 'SpeciesCode'))
all_spp_summ_df_gh <- left_join(allGH_bySPP_summ, spp_lookup_df, by = c('group' = 'codes'))
# Gape width
all_spp_summ_df_gw <- left_join(allGW_bySPP_summ, spp_lookup_df, by = c('group' = 'codes'))
#test_gh <- lme4::lmer(slope ~ fg + 0 + (1 | Family), data = all_spp_summ_df_gh)
test_gh <- lm(slope ~ fg + 0, data = all_spp_summ_df_gh)
test_gh_ci <- confint(test_gh)
test_gh_summ <- data_frame(fg = factor(c('Pi', 'BI', 'ZP', 'HE/DE'), levels = c('Pi', 'BI', 'ZP', 'HE/DE')),
estimate = summary(test_gh)$coefficients[, 1],
lwr = test_gh_ci[, 1],
upr = test_gh_ci[, 2])
#all_spp_summ_df_gh2 <-
# mean_spp_summ_gh %>%
# mutate(id = as.numeric(codes)) %>%
# mutate(fg = factor(fg, levels = levels(mean_spp_summ_gh$fg))) %>%
# arrange(., fg)
all_spp_summ_df_gh2 <-
all_spp_summ_df_gh %>%
mutate(id = as.numeric(group)) %>%
mutate(fg = factor(fg, levels = levels(all_spp_summ_df_gh$fg))) %>%
arrange(., fg)
#spacing <- c(seq(0, 1, length.out = 6), seq(0, 1, length.out = 3),
# seq(0, 1, length.out = 6), seq(0, 1, length.out = 6))
#all_spp_summ_df_gh2$spacing <- spacing
all_spp_summ_df_gh2$spacing <- seq(from = 0, by = 0.2, length.out = 21)
test_gh_summ$start <- c(0.0, 1.2, 1.8, 3.0)
test_gh_summ$end <- c(1.0, 1.6, 2.8, 4.0)
gh_plot <-
ggplot(all_spp_summ_df_gh2) +
geom_rect(data = test_gh_summ, aes(xmin = start - 0.05, xmax = end + 0.05, ymin = lwr, ymax = upr), fill = "gray85") +
#geom_point(aes(x = -0.2, y = 1), alpha = 0) +
geom_point(aes(x = spacing, y = slope), size = 1, colour = "gray50") +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
theme(panel.margin = unit(0, "cm")) +
theme(panel.border = element_blank()) +
theme(plot.margin = unit(c(1.5,0.5,0.5,1.5), "lines")) +
theme(strip.background = element_rect(fill = "white", colour = "white")) +
theme(axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black')) +
theme(strip.text.x = element_blank()) +
theme(axis.text.x = element_blank(),
axis.text.y = element_text(margin = margin(0, 6, 0, 0)),
#axis.ticks.x=element_blank(),
axis.title.x=element_blank(),
axis.title.y = element_blank(),
axis.ticks.length = unit(-0.1, "cm")) +
geom_segment(data=test_gh_summ, aes(y = estimate, yend = estimate, x = start - 0.05, xend = end + 0.05), colour = '#099DFFFF', size = 1, lineend = 'round') +
geom_hline(aes(yintercept = 0.33), colour = 'red', linetype = 2) +
#scale_x_continuous(breaks = 0.5) +
#scale_y_continuous(breaks = c(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6), lim =c(0, 0.6)) +
facet_wrap(~ fg, scales = 'free_x', ncol = 4) +
ylim(c(0.1, 0.6))
#test_gw <- lme4::lmer(slope ~ fg + 0 + (1 | Family), data = all_spp_summ_df_gw)
test_gw <- lm(slope ~ fg + 0, data = all_spp_summ_df_gw)
test_gw_ci <- confint(test_gw)
test_gw_summ <- data_frame(fg = factor(c('Pi', 'BI', 'ZP', 'HE/DE'),
levels = c('Pi', 'BI', 'ZP', 'HE/DE')),
estimate = summary(test_gw)$coefficients[, 1],
lwr = test_gw_ci[, 1],
upr = test_gw_ci[, 2])
all_spp_summ_df_gw2 <-
all_spp_summ_df_gw %>%
mutate(id = as.numeric(group)) %>%
mutate(fg = factor(fg, levels = levels(all_spp_summ_df_gw$fg))) %>%
arrange(., fg)
all_spp_summ_df_gw2$spacing <- seq(from = 0, by = 0.2, length.out = 21)
test_gw_summ$start <- c(0.0, 1.2, 1.8, 3.0)
test_gw_summ$end <- c(1.0, 1.6, 2.8, 4.0)
gw_plot <-
ggplot(all_spp_summ_df_gw2) +
geom_rect(data = test_gw_summ, aes(xmin = start - 0.05, xmax = end + 0.05, ymin = lwr, ymax = upr), fill = "gray85") +
#geom_point(aes(x = -0.2, y = 1), alpha = 0) +
geom_point(aes(x = spacing, y = slope), size = 1, colour = "gray50") +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
theme(panel.margin = unit(0, "cm")) +
theme(panel.border = element_blank()) +
theme(plot.margin = unit(c(1.5,0.5,0.5,1.5), "lines")) +
theme(strip.background = element_rect(fill = "white", colour = "white")) +
theme(axis.line.x = element_line(color = 'black'),
axis.line.y = element_line(color = 'black')) +
theme(strip.text.x = element_blank()) +
theme(axis.text.x = element_text(angle=45, colour="black", hjust=1, size = 8),
axis.text.y = element_text(margin = margin(0, 6, 0, 0)),
#axis.ticks.x=element_blank(),
axis.title.x=element_blank(),
axis.title.y = element_blank(),
axis.ticks.length = unit(-0.1, "cm")) +
geom_segment(data=test_gw_summ, aes(y = estimate, yend = estimate, x = start - 0.05, xend = end + 0.05), colour = '#099DFFFF', size = 1, lineend = 'round') +
geom_hline(aes(yintercept = 0.33), colour = 'red', linetype = 2) +
#scale_x_continuous(breaks = 0.5) +
#scale_y_continuous(breaks = c(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7), lim =c(0, 0.7)) +
facet_wrap(~ fg, scales = 'free_x', ncol=4) +
scale_x_continuous(breaks = all_spp_summ_df_gw2$spacing,
labels = c('Caranx melampygus', 'Aphareus furca', 'Lutjanus bohar',
'Cephalopholis argus', 'Cephalopholis urodeta', 'Variola louti',
'Paracirrhites arcatus', 'Monotaxis grandoculis', 'Parupeneus insularis',
'Caesio teres', 'Pterocaesio tile', 'Chromis vanderbilti',
'Pseudanthias bartlettorum', 'Pseudanthias dispar', 'Pseudanthias olivaceus',
'Acanthurus nigricans', 'Acanthurus olivaceus', 'Centropyge flavissima',
'Chlorurus sordidus', 'Scarus frenatus', 'Scarus rubroviolaceus')) +
ylim(c(0.1, 0.65))
```
```{r, echo=FALSE, fig.height=7, fig.width=5.2, fig.cap='**Figure S4.** Comparison of allometric coefficients across functional groups, calculated using a linear model for (a) gape height ~ body mass and (b) gape width ~ body mass relationships. Estimates of functional group mean slopes are shown by the blue line, species mean slopes are plotted as grey points, and confidence limits are bounded by the grey box. For reference, isometry (slope = 0.33) is plotted as the red dashed line.'}
# CODE FOR VISREG STYLE FG COMPARISON PLOT
master_layout <-
grid.layout(nrow = 3, ncol = 6,
widths = unit(c(0.2, 0.2, 1, 1, 1, 1), "null"),
heights = unit(c(0.8, 1, 0.1), "null"))
grid.newpage()
pushViewport(viewport(layout=master_layout))
print(gh_plot, vp = viewport(layout.pos.row = 1, layout.pos.col = 2:6))
print(gw_plot, vp = viewport(layout.pos.row = 2, layout.pos.col = 2:6))
grid.text(
"a)", vp = viewport(layout.pos.row = 1, layout.pos.col = 1),
gp = gpar(fontsize = 9), vjust = -12
)
grid.text(
"b)", vp = viewport(layout.pos.row = 2, layout.pos.col = 1),
gp = gpar(fontsize = 9), vjust = -16
)
grid.text(
"Gape height slope estimate",
vp = viewport(layout.pos.row = 1, layout.pos.col = 1),
rot = 90, gp = gpar(fontsize = 9), vjust = 1, hjust = 0.6
)
grid.text(
"Gape width slope estimate",
vp = viewport(layout.pos.row = 2, layout.pos.col = 1),
rot = 90, gp = gpar(fontsize = 9), vjust = 1, hjust = 0.2
)
grid.text(
"Piscivore",
vp = viewport(layout.pos.row = 1, layout.pos.col = 3),
vjust = -12, gp = gpar(fontsize = 9), hjust = 0.1
)
grid.text(
expression(" Benthic \nInvertivore"),
vp = viewport(layout.pos.row = 1, layout.pos.col = 4),
vjust = -11, gp = gpar(fontsize = 9), hjust = 0.22
)
grid.text(
"Zooplanktivore",
vp = viewport(layout.pos.row = 1, layout.pos.col = 5),
vjust = -12, gp = gpar(fontsize = 9), hjust = 0.45
)
grid.text(
"Herbivore/\nDetritivore",
vp = viewport(layout.pos.row = 1, layout.pos.col = 6),
vjust = -3.75, gp = gpar(fontsize = 9), hjust = 0.55
)
#grid.text("Functional group", vp = viewport(layout.pos.row = 4, layout.pos.col = 3:6),
#gp = gpar(fontsize = 9), vjust = -1, hjust = 0.5)
#grid.text("Figure 3", vp = viewport(layout.pos.row = 4, layout.pos.col = 1:3),
# gp = gpar(fontsize = 9), vjust = 0, hjust = 1.3)
```
```{r, include=FALSE}
#===============================================================================
# Multipanel plot with functional group and species GAPE WIDTH
#===============================================================================
# Get community level midpoint
allGW <- sma(gw ~ SL, data = new_pento, log = "xy", method = "SMA", robust = T, slope.test = 1)
#check_assump(allGW, "new_pento Gape Area All")
allGW_summ <- mk_sma_summary(allGW, 1)
allGW_graph_df <- mk_sma_graph_df(allGW_summ, 1, "j_fg")
names(allGW_graph_df)
# Get functional group level metrics: midpoints of data
# Using a single sma() iteration because this does not alter results, nor the
# visual display of the data.
all_spp_GW <- sma(gw ~ SL * SpeciesCode, data = new_pento, log = "xy",
method = "SMA", robust = T, slope.test = 1,
multcomp = F, multcompmethod = "adjusted")
#check_assump(allGA, "Species Gape Area All")
allGW_bySPP_summ <- mk_spp_summary(all_spp_GW, 21, grouping=TRUE)
# Gape width
all_spp_summ_df_gw <- left_join(allGW_bySPP_summ, spp_lookup_df, by = c('group' = 'codes'))
test_gw <- lm(slope ~ fg + 0, data = all_spp_summ_df_gw)
pento_slopes_gw <- summary(test_gw)$coefficients[, 1]
names(pento_slopes_gw) <- c('Pi', 'Bi', 'ZP', 'HE/DE')
all_fg_GW <- sma(gw ~ SL * j_fg, data = new_pento, log = "xy", method = "SMA",
robust = T, slope.test = 1, multcomp = F)
all_fg_GW_summ <- mk_spp_summary(all_fg_GW, 4, grouping=TRUE)
all_fg_GW_graph_df <- mk_smaSPP_graph_df(all_fg_GW_summ, 4, "j_fg", iso_slope = 1)
all_fg_GW_graph_df$boot_slope <- c(pento_slopes_gw)
all_fg_GW_graph_df <-
all_fg_GW_graph_df %>%
dplyr::mutate(boot_ref_int = log10(midpoint_y / (midpoint_x ^ boot_slope)))
# SMA regression for each species
all_spp_GW <- sma(gw ~ SL * SpeciesCode, data = new_pento, log = "xy",
method = "SMA", robust = T, slope.test = 1,
multcomp = F, multcompmethod = "adjusted")
#check_assump(allGA, "Species Gape Area All")
allGW_bySPP_summ <- mk_spp_summary(all_spp_GW, 22, grouping=TRUE)
allometry <- NA
for (i in seq_along(allGW_bySPP_summ[[1]])) {
allometry[i] <- get_allometry(slope = allGW_bySPP_summ$slope[i],
p_val = allGW_bySPP_summ$slp_p_val[i],
iso_val = 1)
}
sig <- NA
for (i in seq_along(allGW_bySPP_summ[[1]])) {
sig[i] <- get_sig(p_val = allGW_bySPP_summ$slp_p_val[i])
}
allGW_bySPP_summ$allometry <- allometry
#allGW_bySPP_summ$sig <- '*'
allGW_bySPP_graph_df <- mk_smaSPP_graph_df(allGW_bySPP_summ, 21, "SpeciesCode", iso_slope = 1)
allGW_bySPP_graph_df$allometry <- allometry
#-------------------------------------------------------------------------------
# Setting up values to plot the lines at the species level
spp_lines <- allGW_bySPP_graph_df
# Setting up equation, r^2, and n values that will be written on the graphs
spp_sma_eqns <- write_group_sma_eqn(allGW_bySPP_summ, allGW_bySPP_summ$group)
names(spp_sma_eqns) <- c("SpeciesCode", "eqn_r2", "eqn", "r2", "n")
```
```{r, include=FALSE}
#-------------------------------------------------------------------------------
# Multipanel comparison of 3 predatory functional groups
#-------------------------------------------------------------------------------
apfurc <-
mk_multipanel_plots2(fg_point_df = p, spp_point_df = p_spp_dfs$AP.FURC,
spp_line_df_row = spp_lines[2, ], eqn_df = spp_sma_eqns[2, ],
eqn_x = 700, eqn_y = 13, r2_x = 700, r2_y = 18,
n_x = 700, n_y = 23, x_axis_labels = FALSE, y_axis_labels = FALSE,
fg_line_intercept = all_fg_GW_graph_df$ref_intercept_iso[1],
x_axis_text = FALSE, y_axis_text = TRUE,
plot_title = "Aphareus furca", gape_dim = 'gw') +
geom_abline(data = all_fg_GW_graph_df[1, ],
aes(slope = boot_slope, intercept = boot_ref_int), linetype = 2) +
scale_x_log10(breaks = c(50, 100, 250, 500)) +
scale_y_log10(breaks = c(20, 50, 100)) +
geom_point(aes(x = 100, y = 95), alpha = 0) +
geom_text(data = allGW_bySPP_graph_df[2, ], aes_string(x = 80, y = 100,
label = 'allometry'), parse = TRUE, size = 3, hjust = 1)
luboha <-
mk_multipanel_plots2(fg_point_df = p, spp_point_df = p_spp_dfs$LU.BOHA,
spp_line_df_row = spp_lines[3, ], eqn_df = spp_sma_eqns[3, ],
eqn_x = 700, eqn_y = 13, r2_x = 700, r2_y = 18,
n_x = 700, n_y = 23, x_axis_labels = FALSE, y_axis_labels = FALSE,
fg_line_intercept = all_fg_GW_graph_df$ref_intercept[1],
x_axis_text = FALSE, y_axis_text = FALSE,
plot_title = "Lutjanus bohar", gape_dim = 'gw') +
geom_abline(data = all_fg_GW_graph_df[1, ],
aes(slope = boot_slope, intercept = boot_ref_int), linetype = 2) +
scale_x_log10(breaks = c(50, 100, 250, 500)) +
scale_y_log10(breaks = c(20, 50, 100)) +
geom_point(aes(x = 100, y = 95), alpha = 0) +
geom_text(data = allGW_bySPP_graph_df[3, ], aes_string(x = 80, y = 100,
label = 'allometry'), parse = TRUE, size = 3, hjust = 1)
valout <-
mk_multipanel_plots2(fg_point_df = p, spp_point_df = p_spp_dfs$VA.LOUT,
spp_line_df_row = spp_lines[6, ], eqn_df = spp_sma_eqns[6, ],
eqn_x = 700, eqn_y = 13, r2_x = 700, r2_y = 18,
n_x = 700, n_y = 23, x_axis_labels = FALSE, y_axis_labels = FALSE,
fg_line_intercept = all_fg_GW_graph_df$ref_intercept[1],
x_axis_text = TRUE, y_axis_text = TRUE,
plot_title = "Variola louti", gape_dim = 'gw') +
geom_abline(data = all_fg_GW_graph_df[1, ],
aes(slope = boot_slope, intercept = boot_ref_int), linetype = 2) +
scale_x_log10(breaks = c(50, 100, 250, 500)) +
scale_y_log10(breaks = c(20, 50, 100)) +
geom_point(aes(x = 100, y = 95), alpha = 0) +
geom_text(data = allGW_bySPP_graph_df[6, ], aes_string(x = 80, y = 100,
label = 'allometry'), parse = TRUE, size = 3, hjust = 1)
ceargu <-
mk_multipanel_plots2(fg_point_df = p, spp_point_df = p_spp_dfs$CE.ARGU,
spp_line_df_row = spp_lines[4, ], eqn_df = spp_sma_eqns[4, ],
eqn_x = 700, eqn_y = 13, r2_x = 700, r2_y = 18,
n_x = 700, n_y = 23, x_axis_labels = FALSE, y_axis_labels = FALSE,
fg_line_intercept = all_fg_GW_graph_df$ref_intercept[1],
x_axis_text = FALSE, y_axis_text = FALSE,
plot_title = "Cephalopholis argus", gape_dim = 'gw') +
geom_abline(data = all_fg_GW_graph_df[1, ],
aes(slope = boot_slope, intercept = boot_ref_int), linetype = 2) +
scale_x_log10(breaks = c(50, 100, 250, 500)) +
scale_y_log10(breaks = c(20, 50, 100)) +
geom_point(aes(x = 100, y = 95), alpha = 0) +
geom_text(data = allGW_bySPP_graph_df[4, ], aes_string(x = 80, y = 100,
label = 'allometry'), parse = TRUE, size = 3, hjust = 1)
ceurod <-
mk_multipanel_plots2(fg_point_df = p, spp_point_df = p_spp_dfs$CE.UROD,
spp_line_df_row = spp_lines[5, ], eqn_df = spp_sma_eqns[5, ],
eqn_x = 700, eqn_y = 13, r2_x = 700, r2_y = 18,
n_x = 700, n_y = 23, x_axis_labels = FALSE, y_axis_labels = FALSE,
fg_line_intercept = all_fg_GW_graph_df$ref_intercept[1],
x_axis_text = TRUE, y_axis_text = FALSE,
plot_title = "Cephalopholis urodeta", gape_dim = 'gw') +
geom_abline(data = all_fg_GW_graph_df[1, ],
aes(slope = boot_slope, intercept = boot_ref_int), linetype = 2) +
scale_x_log10(breaks = c(50, 100, 250, 500)) +
scale_y_log10(breaks = c(20, 50, 100)) +
geom_point(aes(x = 100, y = 95), alpha = 0) +
geom_text(data = allGW_bySPP_graph_df[5, ], aes_string(x = 80, y = 100,
label = 'allometry'), parse = TRUE, size = 3, hjust = 1)
camela <-
mk_multipanel_plots2(fg_point_df = p, spp_point_df = p_spp_dfs$CA.MELA,
spp_line_df_row = spp_lines[1, ], eqn_df = spp_sma_eqns[1, ],
eqn_x = 700, eqn_y = 13, r2_x = 700, r2_y = 18,
n_x = 700, n_y = 23, x_axis_labels = FALSE, y_axis_labels = FALSE,
fg_line_intercept = all_fg_GW_graph_df$ref_intercept[1],
x_axis_text = TRUE, y_axis_text = FALSE,
plot_title = "Caranx melampygus", gape_dim = 'gw') +
geom_abline(data = all_fg_GW_graph_df[1, ],
aes(slope = boot_slope, intercept = boot_ref_int), linetype = 2) +
scale_x_log10(breaks = c(50, 100, 250, 500)) +
scale_y_log10(breaks = c(20, 50, 100)) +
geom_point(aes(x = 100, y = 95), alpha = 0) +
geom_text(data = allGW_bySPP_graph_df[1, ], aes_string(x = 80, y = 100,
label = 'allometry'), parse = TRUE, size = 3, hjust = 1)
# Benthic invertivores
paarca <-
mk_multipanel_plots2(fg_point_df = b, spp_point_df = b_spp_dfs$PA.ARCA,
spp_line_df_row = spp_lines[7, ], eqn_df = spp_sma_eqns[7, ],
eqn_x = 350, eqn_y = 5.5, r2_x = 350, r2_y = 7.8,
n_x = 350, n_y = 10, x_axis_labels = FALSE, y_axis_labels = FALSE,
fg_line_intercept = all_fg_GW_graph_df$ref_intercept_iso[2],
x_axis_text = TRUE, y_axis_text = TRUE,
plot_title = "Paracirrhites arcatus", gape_dim = 'gw') +
geom_abline(data = all_fg_GW_graph_df[2, ],
aes(slope = boot_slope, intercept = boot_ref_int), linetype = 2) +
scale_x_log10(breaks = c(50, 100, 250)) +
scale_y_log10(breaks = c(5, 20, 50)) +
geom_point(aes(x = 100, y = 7), alpha = 0) +
geom_text(data = allGW_bySPP_graph_df[7, ], aes_string(x = 55, y = 45,
label = 'allometry'), parse = TRUE, size = 3, hjust = 1)
painsu <-
mk_multipanel_plots2(fg_point_df = b, spp_point_df = b_spp_dfs$PA.INSU,
spp_line_df_row = spp_lines[9, ], eqn_df = spp_sma_eqns[9, ],
eqn_x = 350, eqn_y = 5.5, r2_x = 350, r2_y = 7.8,
n_x = 350, n_y = 10, x_axis_labels = FALSE, y_axis_labels = FALSE,
fg_line_intercept = all_fg_GW_graph_df$ref_intercept[2], x_axis_text = TRUE,
y_axis_text = FALSE,
plot_title = "Parupeneus insularis", gape_dim = 'gw') +
geom_abline(data = all_fg_GW_graph_df[2, ],
aes(slope = boot_slope, intercept = boot_ref_int), linetype = 2) +
scale_x_log10(breaks = c(50, 100, 250)) +
scale_y_log10(breaks = c(5, 20, 50)) +
geom_point(aes(x = 100, y = 7), alpha = 0) +
geom_text(data = allGW_bySPP_graph_df[9, ], aes_string(x = 55, y = 45,
label = 'allometry'), parse = TRUE, size = 3, hjust = 1)
mogran <-
mk_multipanel_plots2(fg_point_df = b, spp_point_df = b_spp_dfs$MO.GRAN,
spp_line_df_row = spp_lines[8, ], eqn_df = spp_sma_eqns[8, ],
eqn_x = 350, eqn_y = 5.5, r2_x = 350, r2_y = 7.8,
n_x = 350, n_y = 10, x_axis_labels = FALSE, y_axis_labels = FALSE,
fg_line_intercept = all_fg_GW_graph_df$ref_intercept[2],
x_axis_text = TRUE, y_axis_text = FALSE,
plot_title = "Monotaxis grandoculis", gape_dim = 'gw' ) +
geom_abline(data = all_fg_GW_graph_df[2, ],
aes(slope = boot_slope, intercept = boot_ref_int), linetype = 2) +
scale_x_log10(breaks = c(50, 100, 250)) +
scale_y_log10(breaks = c(5, 20, 50)) +
geom_point(aes(x = 100, y = 7), alpha = 0) +
geom_text(data = allGW_bySPP_graph_df[8, ], aes_string(x = 55, y = 45,
label = 'allometry'), parse = TRUE, size = 3, hjust = 1)
```
--------------------------------------------------------------------------------
```{r, echo=FALSE, fig.height=8, fig.width=7, fig.cap='**Figure S5.** Gape width ~ standard length relationships for the nine species sampled from two predatory functional groups: (a) piscivores and (b) benthic invertivores. Plot details are the same as in Figure 4.'}
# With "Figure" labelled
master_layout <-
grid.layout(nrow = 5, ncol = 4,
widths = unit(c(0.2, 1, 0.9, 0.9), "null"),
heights = unit(c(1, 1.1, 0.2, 1.1, 0.2), "null"))
#grid.newpage()
pushViewport(viewport(layout = master_layout))
# piscs
print(apfurc, vp = set_vp(1, 2))
print(luboha, vp = set_vp(1, 3))
print(ceargu, vp = set_vp(1, 4))
print(valout, vp = set_vp(2, 2))
print(camela, vp = set_vp(2, 3))
print(ceurod, vp = set_vp(2, 4))
# benths
print(paarca, vp = set_vp(4, 2))
print(painsu, vp = set_vp(4, 3))
print(mogran, vp = set_vp(4, 4))
# Figure label
grid.text("Figure S5", vp = viewport(layout.pos.row = 5, layout.pos.col = 1),
gp = gpar(fontsize = 9), hjust = -1, vjust = 1)
# piscs
grid.text(
"a)", vp = viewport(layout.pos.row = 1, layout.pos.col = 1),
gp = gpar(fontsize = 9), vjust = -8
)
grid.text(
expression( paste("Gape width (", mm, ")", sep = "") ),
vp = viewport(layout.pos.row = 1:2, layout.pos.col = 1),
rot = 90, gp = gpar(fontsize = 9),
vjust = 1
)