forked from jagephart/FishPrint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSI_results_table_and_source_plot.R
856 lines (735 loc) · 48.4 KB
/
SI_results_table_and_source_plot.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
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
# Bind results from posteriors for SI
# Set data directories
rm(list=ls())
datadir <- "/Volumes/jgephart/BFA Environment 2/Data"
outdir <- "/Volumes/jgephart/BFA Environment 2/Outputs"
#_______________________________________________________________________________________________________________________#
# Load packages and source functions
#_______________________________________________________________________________________________________________________#
library(tidyverse)
library(ggplot2)
library(ggpubr)
#_______________________________________________________________________________________________________________________#
# Combine tables for on and off farm stressors
#_______________________________________________________________________________________________________________________#
#_______________________________________________________________________________________________________________________#
# Load main results files and merge (Priors + Mass allocation + Edible Weight)
#_______________________________________________________________________________________________________________________#
# ON-FARM GHG
df <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Global warming potential_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
df <- df %>%
mutate(source = "on-farm", stressor = "GHG", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
# OFF-FARM GHG
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Global warming potential_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "GHG", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df <- df %>%
bind_rows(tmp)
# ON-FARM NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "N", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df <- df %>%
bind_rows(tmp)
# OFF-FARM NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "N", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df <- df %>%
bind_rows(tmp)
# ON-FARM PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "P", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df <- df %>%
bind_rows(tmp)
# OFF-FARM PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "P", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df <- df %>%
bind_rows(tmp)
# ON-FARM WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Water Consumption_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "Water", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df <- df %>%
bind_rows(tmp)
# OFF-FARM WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Water Consumption_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "Water", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df <- df %>%
bind_rows(tmp)
# ON-FARM LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Land-FCR-Priors-Only-Rerun/summary_Land Use_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "Land", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df <- df %>%
bind_rows(tmp)
# OFF-FARM LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Land-FCR-Priors-Only-Rerun/summary_Land Use_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "Land", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df <- df %>%
bind_rows(tmp)
# CAPTURE
# Capture fishery results (edible weight)
df_capture_edible <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Wild/summary_WILD-GHG-TAXA-LEVEL-WEIGHTED.csv"))
df_capture_edible <- df_capture_edible %>%
filter(.width == 0.95)
df_capture_edible <- df_capture_edible %>%
mutate(stressor = "GHG", full_taxa_name = taxa) %>%
mutate(source = "all", production = "capture", weight = "edible", allocation = "mass") %>%
select(production, taxa, full_taxa_name, stressor, source, "median" = "total_stressor",
"lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
#_______________________________________________________________________________________________________________________#
# Load SI results files and merge
# Priors + Mass allocation + Live Weight
#_______________________________________________________________________________________________________________________#
# ON-FARM GHG
df_mass_live <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Global warming potential_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
df_mass_live <- df_mass_live %>%
mutate(source = "on-farm", stressor = "GHG", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
# OFF-FARM GHG
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Global warming potential_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "GHG", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_mass_live <- df_mass_live %>%
bind_rows(tmp)
# ON-FARM NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "N", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_mass_live <- df_mass_live %>%
bind_rows(tmp)
# OFF-FARM NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "N", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_mass_live <- df_mass_live %>%
bind_rows(tmp)
# ON-FARM PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "P", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_mass_live <- df_mass_live %>%
bind_rows(tmp)
# OFF-FARM PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "P", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_mass_live <- df_mass_live %>%
bind_rows(tmp)
# ON-FARM WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Water Consumption_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "Water", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_mass_live <- df_mass_live %>%
bind_rows(tmp)
# OFF-FARM WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Water Consumption_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "Water", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_mass_live <- df_mass_live %>%
bind_rows(tmp)
# ON-FARM LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Land-FCR-Priors-Only/summary_Land Use_Mass-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "Land", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_mass_live <- df_mass_live %>%
bind_rows(tmp)
# OFF-FARM LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Land-FCR-Priors-Only/summary_Land Use_Mass-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "Land", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_mass_live <- df_mass_live %>%
bind_rows(tmp)
# Capture fishery results (live weight)
df_capture_live <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Wild/summary_WILD-GHG-TAXA-LEVEL-WEIGHTED.csv"))
df_capture_live <- df_capture_live %>%
filter(.width == 0.95)
df_capture_live <- df_capture_live %>%
mutate(stressor = "GHG", full_taxa_name = taxa) %>%
mutate(source = "all", production = "capture", weight = "live", allocation = "mass") %>%
select(production, taxa, full_taxa_name, stressor, source, "median" = "total_stressor",
"lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
#_______________________________________________________________________________________________________________________#
# Load SI results files and merge
# Priors + Economic allocation + Edible Weight
#_______________________________________________________________________________________________________________________#
# ON-FARM GHG
df_economic_edible <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Global warming potential_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
df_economic_edible <- df_economic_edible %>%
mutate(source = "on-farm", stressor = "GHG", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
# OFF-FARM GHG
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Global warming potential_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "GHG", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_edible <- df_economic_edible %>%
bind_rows(tmp)
# ON-FARM NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "N", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_edible <- df_economic_edible %>%
bind_rows(tmp)
# OFF-FARM NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "N", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_edible <- df_economic_edible %>%
bind_rows(tmp)
# ON-FARM PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "P", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_edible <- df_economic_edible %>%
bind_rows(tmp)
# OFF-FARM PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "P", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_edible <- df_economic_edible %>%
bind_rows(tmp)
# ON-FARM WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Water Consumption_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "Water", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_edible <- df_economic_edible %>%
bind_rows(tmp)
# OFF-FARM WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Water Consumption_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "Water", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_edible <- df_economic_edible %>%
bind_rows(tmp)
# ON-FARM LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Land-FCR-Priors-Only-Rerun/summary_Land Use_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "Land", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_edible <- df_economic_edible %>%
bind_rows(tmp)
# OFF-FARM LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Land-FCR-Priors-Only-Rerun/summary_Land Use_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "Land", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_edible <- df_economic_edible %>%
bind_rows(tmp)
#_______________________________________________________________________________________________________________________#
# Load SI results files and merge
# Priors + Economic allocation + Live Weight
#_______________________________________________________________________________________________________________________#
# GHG ON-FARM
df_economic_live <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Global warming potential_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
df_economic_live <- df_economic_live %>%
mutate(source = "on-farm", stressor = "GHG", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
# GHG OFF-FARM
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Global warming potential_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "GHG", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_live <- df_economic_live %>%
bind_rows(tmp)
# NITROGEN ON-FARM
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "N", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_live <- df_economic_live %>%
bind_rows(tmp)
# NITROGEN OFF-FARM
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "N", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_live <- df_economic_live %>%
bind_rows(tmp)
# PHOSPHORUS ON-FARM
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "P", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_live <- df_economic_live %>%
bind_rows(tmp)
# PHOSPHORUS OFF-FARM
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "P", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_live <- df_economic_live %>%
bind_rows(tmp)
# WATER ON-FARM
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Water Consumption_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "Water", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_live <- df_economic_live %>%
bind_rows(tmp)
# WATER OFF-FARM
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Water Consumption_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "Water", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_live <- df_economic_live %>%
bind_rows(tmp)
# LAND ON-FARM
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Land-FCR-Priors-Only/summary_Land Use_Economic-allocation_ON-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "on-farm", stressor = "Land", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "on_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_live <- df_economic_live %>%
bind_rows(tmp)
# LAND OFF-FARM
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Land-FCR-Priors-Only/summary_Land Use_Economic-allocation_OFF-FARM-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "off-farm", stressor = "Land", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "off_farm", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_economic_live <- df_economic_live %>%
bind_rows(tmp)
#_______________________________________________________________________________________________________________________#
# Write out results tables
#_______________________________________________________________________________________________________________________#
df_all <- df %>%
bind_rows(df_mass_live, df_economic_edible, df_economic_live) %>%
mutate(production = "aquaculture") %>%
mutate(full_taxa_name = if_else(taxa == "hypoph_carp", true = "silver/bighead", false = full_taxa_name)) %>% # Fix full taxa name for hypoph/carp
bind_rows(df_capture_edible) %>%
bind_rows(df_capture_live)
write.csv(df_all, file.path(outdir, "SI_stressor_results_on_off_farm.csv"), row.names = FALSE)
#_______________________________________________________________________________________________________________________#
# Combine tables for total stressors (i.e., on + off farm)
#_______________________________________________________________________________________________________________________#
#_______________________________________________________________________________________________________________________#
# Load main results files and merge (Priors + Mass allocation + Edible Weight)
#_______________________________________________________________________________________________________________________#
# TOTAL GHG
df_total <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Global warming potential_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
df_total <- df_total %>%
mutate(source = "total on- and off-farm", stressor = "GHG", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
# TOTAL NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "N", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total <- df_total %>%
bind_rows(tmp)
# TOTAL PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "P", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total <- df_total %>%
bind_rows(tmp)
# TOTAL WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Water Consumption_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "Water", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total <- df_total %>%
bind_rows(tmp)
# TOTAL LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Land-FCR-Priors-Only-Rerun/summary_Land Use_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "Land", weight = "edible", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total <- df_total %>%
bind_rows(tmp)
#_______________________________________________________________________________________________________________________#
# Load SI results files and merge
# Priors + Mass allocation + Live Weight
#_______________________________________________________________________________________________________________________#
# TOTAL GHG
df_total_mass_live <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Global warming potential_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
df_total_mass_live <- df_total_mass_live %>%
mutate(source = "total on- and off-farm", stressor = "GHG", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
# TOTAL NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "N", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_mass_live <- df_total_mass_live %>%
bind_rows(tmp)
# TOTAL PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "P", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_mass_live <- df_total_mass_live %>%
bind_rows(tmp)
# TOTAL WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Water Consumption_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "Water", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_mass_live <- df_total_mass_live %>%
bind_rows(tmp)
# TOTAL LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Land-FCR-Priors-Only/summary_Land Use_Mass-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "Land", weight = "live", allocation = "mass") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_mass_live <- df_total_mass_live %>%
bind_rows(tmp)
#_______________________________________________________________________________________________________________________#
# Load SI results files and merge
# Priors + Economic allocation + Edible Weight
#_______________________________________________________________________________________________________________________#
# TOTAL GHG
df_total_economic_edible <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Global warming potential_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
df_total_economic_edible <- df_total_economic_edible %>%
mutate(source = "total on- and off-farm", stressor = "GHG", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
# TOTAL NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "N", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_economic_edible <- df_total_economic_edible %>%
bind_rows(tmp)
# TOTAL PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "P", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_economic_edible <- df_total_economic_edible %>%
bind_rows(tmp)
# TOTAL WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/summary_Water Consumption_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "Water", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_economic_edible <- df_total_economic_edible %>%
bind_rows(tmp)
# TOTAL LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Land-FCR-Priors-Only-Rerun/summary_Land Use_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "Land", weight = "edible", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_economic_edible <- df_total_economic_edible %>%
bind_rows(tmp)
#_______________________________________________________________________________________________________________________#
# Load SI results files and merge
# Priors + Economic allocation + Live Weight
#_______________________________________________________________________________________________________________________#
# TOTAL GHG
df_total_economic_live <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Global warming potential_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
df_total_economic_live <- df_total_economic_live %>%
mutate(source = "total on- and off-farm", stressor = "GHG", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
# TOTAL NITROGEN
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Nitrogen/summary_Marine eutrophication_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "N", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_economic_live <- df_total_economic_live %>%
bind_rows(tmp)
# TOTAL PHOSPHORUS
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Phosphorus/summary_Freshwater eutrophication_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "P", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_economic_live <- df_total_economic_live %>%
bind_rows(tmp)
# TOTAL WATER
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Live-Weight/PRIORS/summary_Water Consumption_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "Water", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_economic_live <- df_total_economic_live %>%
bind_rows(tmp)
# TOTAL LAND
tmp <- read.csv(file.path(outdir, "Nature-submitted-2021-05/Bayesian-Means-Live-Weight/PRIORS/Land-FCR-Priors-Only/summary_Land Use_Economic-allocation_TOTAL-IMPACT-TAXA-LEVEL-WEIGHTED.csv"))
tmp <- tmp %>%
mutate(source = "total on- and off-farm", stressor = "Land", weight = "live", allocation = "economic") %>%
select(taxa, full_taxa_name, stressor, source, "median" = "total_stressor", "lower_95" = ".lower", "upper_95" = ".upper", weight, allocation)
df_total_economic_live <- df_total_economic_live %>%
bind_rows(tmp)
#_______________________________________________________________________________________________________________________#
# Write out results for total stressors
#_______________________________________________________________________________________________________________________#
df_total_all <- df_total %>%
bind_rows(df_total_mass_live, df_total_economic_edible, df_total_economic_live) %>%
mutate(production = "aquaculture") %>%
mutate(full_taxa_name = if_else(taxa == "hypoph_carp", true = "silver/bighead", false = full_taxa_name)) %>% # Fix full taxa name for hypoph/carp
bind_rows(df_capture_live) %>% # capture stressor source is designated as "all"
bind_rows(df_capture_edible)
write.csv(df_total_all, file.path(outdir, "SI_stressor_results_total.csv"), row.names = FALSE)
#_______________________________________________________________________________________________________________________#
# Summarize patterns for paper text
#_______________________________________________________________________________________________________________________#
# Load totals from above summary files
df_total <- read.csv("Data/Table S11.csv")
df_total_mass_lw <- df_total %>%
filter(weight == "edible", allocation == "mass")
df_source <- read.csv("Data/SI_stressor_results_on_off_farm.csv")
df_source_mass_lw <- df_source %>%
filter(weight == "edible", allocation == "mass")
# Lowest taxa across stressors
df_total_mass_lw %>%
group_by(stressor) %>%
slice_min(median, n = 4)
df_total_mass_lw %>%
group_by(stressor) %>%
slice_max(median, n = 3)
# Stressor correlations
tmp <- df_total_mass_lw %>%
filter(production == "aquaculture") %>%
select(taxa, stressor, median) %>%
pivot_wider(names_from = stressor, values_from = median)
cor(tmp[,2:6])
# Percent of on- versus off-farm
source_percent <- df_source_mass_lw %>%
select(taxa, full_taxa_name, stressor, source, median) %>%
pivot_wider(names_from = source, values_from = median) %>%
mutate(total = `on-farm` + `off-farm`) %>%
mutate(percent_onfarm = 100*(`on-farm`/total),
percent_offfarm = 100*(`off-farm`/total))
# GHG results
source_percent %>%
filter(stressor == "GHG") %>%
arrange(percent_onfarm)
source_percent %>%
filter(stressor == "GHG") %>%
arrange(`on-farm`)
source_percent %>%
filter(stressor == "GHG") %>%
arrange(total)
df_total_mass_lw %>%
filter(taxa %in% c("bivalves", "Bivalves"), stressor == "GHG")
df_total_mass_lw %>%
filter(taxa %in% c("shrimp", "Shrimps"), stressor == "GHG")
df_total_mass_lw %>%
filter(taxa %in% c("salmon", "trout", "Salmonids"), stressor == "GHG")
# Land results
source_percent %>%
filter(stressor == "Land") %>%
arrange(`on-farm`)
source_percent %>%
filter(stressor == "Land") %>%
arrange(`off-farm`)
source_percent %>%
filter(stressor == "Land") %>%
arrange(percent_offfarm)
source_percent %>%
filter(stressor == "Land") %>%
arrange(desc(total))
# Water results
source_percent %>%
filter(stressor == "Water") %>%
arrange(percent_offfarm)
source_percent %>%
filter(stressor == "Water") %>%
arrange(`off-farm`)
source_percent %>%
filter(stressor == "Water") %>%
arrange(total)
# N and P results
source_percent %>%
filter(stressor == "N") %>%
arrange(percent_offfarm)
source_percent %>%
filter(stressor == "P") %>%
arrange(percent_offfarm)
source_percent %>%
filter(stressor == "N") %>%
arrange(desc(total))
source_percent %>%
filter(stressor == "P") %>%
arrange(desc(total))
#_______________________________________________________________________________________________________________________#
# Stacked bar of impact by source
#_______________________________________________________________________________________________________________________#
df_plot <- df %>%
mutate(plot_taxa_name = case_when(taxa == "hypoph_carp" ~ "silver/bighead",
taxa == "misc_diad" ~ "misc diad",
taxa == "misc_marine" ~ "misc marine",
taxa == "oth_carp" ~ "misc carp",
taxa == "plants" ~ "seaweeds",
TRUE ~ taxa),
plot_taxa_name = as.factor(plot_taxa_name)) # Create new column for plotting taxa names
plot_taxa_name_order <- c("seaweeds",
"bivalves",
"silver/bighead",
"salmon",
"trout",
"misc carp",
"catfish",
"milkfish",
"shrimp",
"tilapia",
"misc marine",
"misc diad")
weight_type <- "edible weight"
units_for_ghg <- bquote(atop('kg'~CO[2]*' t'^-1~phantom(), .(weight_type))) # atop + phantom() to create line break
units_for_land <- bquote(atop('m'^2*' t'^-1~phantom(), .(weight_type)))
units_for_nitrogen <- bquote(atop('kg N-eq t'^-1~phantom(), .(weight_type)))
units_for_phosphorus <- bquote(atop('kg P-eq t'^-1~phantom(), .(weight_type)))
units_for_water <- bquote(atop('m'^3*' t'^-1~phantom(), .(weight_type)))
# df_plot$taxa <- factor(df_plot$taxa, levels = rev(c("misc_diad",
# "misc_marine",
# "tilapia",
# "shrimp",
# "milkfish",
# "catfish",
# "oth_carp",
# "trout",
# "salmon",
# "hypoph_carp",
# "bivalves",
# "plants")))
df_plot$plot_taxa_name <- factor(df_plot$plot_taxa_name, levels = plot_taxa_name_order)
base_size <- 12
base_family <- "sans"
# GHG plot
ghg_plot <- ggplot(df_plot %>% filter(stressor == "GHG"),
aes(x = median, y = plot_taxa_name, fill = source)) +
geom_bar(stat = "identity", position = "stack") +
scale_fill_manual(values = c("#70468C", "#57D182")) +
labs(title = "GHG", x = units_for_ghg, y = "") +
theme(axis.line.x = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.line.y = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.text = element_text(size = ceiling(base_size*0.7), colour = "black"),
axis.title = element_text(size = ceiling(base_size*0.8)),
axis.text.x = element_text(angle = 90),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.background = element_blank(), panel.border = element_blank(),
strip.background = element_rect(linetype = 1, fill = "white"),
strip.text = element_text(),
strip.text.x = element_text(vjust = 0.5),
strip.text.y = element_text(angle = -90),
strip.placement.y = "outside",
legend.position="bottom",
plot.title = element_text(size = ceiling(base_size*1.1), face = "bold"),
plot.subtitle = element_text(size = ceiling(base_size*1.05)))
# N plot
N_plot <- ggplot(df_plot %>% filter(stressor == "N"),
aes(x = median, y = plot_taxa_name, fill = source)) +
geom_bar(stat = "identity", position = "stack") +
scale_fill_manual(values = c("#70468C", "#57D182")) +
labs(title = "Nitrogen", x = units_for_nitrogen, y = "") +
theme(axis.line.x = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.line.y = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.text = element_blank(),
axis.title = element_text(size = ceiling(base_size*0.8)),
axis.text.x = element_text(angle = 90),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.background = element_blank(), panel.border = element_blank(),
strip.background = element_rect(linetype = 1, fill = "white"),
strip.text = element_text(),
strip.text.x = element_text(vjust = 0.5),
strip.text.y = element_text(angle = -90),
strip.placement.y = "outside",
legend.position="bottom",
plot.title = element_text(size = ceiling(base_size*1.1), face = "bold"),
plot.subtitle = element_text(size = ceiling(base_size*1.05)))
# P plot
P_plot <- ggplot(df_plot %>% filter(stressor == "P"),
aes(x = median, y = plot_taxa_name, fill = source)) +
geom_bar(stat = "identity", position = "stack") +
scale_fill_manual(values = c("#70468C", "#57D182")) +
labs(title = "Phosphorus", x = units_for_phosphorus, y = "") +
theme(axis.line.x = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.line.y = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.text = element_blank(),
axis.title = element_text(size = ceiling(base_size*0.8)),
axis.text.x = element_text(angle = 90),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.background = element_blank(), panel.border = element_blank(),
strip.background = element_rect(linetype = 1, fill = "white"),
strip.text = element_text(),
strip.text.x = element_text(vjust = 0.5),
strip.text.y = element_text(angle = -90),
strip.placement.y = "outside",
legend.position="bottom",
plot.title = element_text(size = ceiling(base_size*1.1), face = "bold"),
plot.subtitle = element_text(size = ceiling(base_size*1.05)))
# Land plot
land_plot <- ggplot(df_plot %>% filter(stressor == "Land"),
aes(x = median, y = plot_taxa_name, fill = source)) +
geom_bar(stat = "identity", position = "stack") +
scale_fill_manual(values = c("#70468C", "#57D182")) +
labs(title = "Land", x = units_for_land, y = "") +
theme(axis.line.x = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.line.y = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.text = element_blank(),
axis.title = element_text(size = ceiling(base_size*0.8)),
axis.text.x = element_text(angle = 90),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.background = element_blank(), panel.border = element_blank(),
strip.background = element_rect(linetype = 1, fill = "white"),
strip.text = element_text(),
strip.text.x = element_text(vjust = 0.5),
strip.text.y = element_text(angle = -90),
strip.placement.y = "outside",
legend.position="bottom",
plot.title = element_text(size = ceiling(base_size*1.1), face = "bold"),
plot.subtitle = element_text(size = ceiling(base_size*1.05)))
# Water plot
water_plot <- ggplot(df_plot %>% filter(stressor == "Water"),
aes(x = median, y = plot_taxa_name, fill = source)) +
geom_bar(stat = "identity", position = "stack") +
scale_fill_manual(values = c("#70468C", "#57D182")) +
labs(title = "Water", x = units_for_water, y = "") +
theme(axis.line.x = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.line.y = element_line(colour = "black", size = 0.5, linetype = "solid"),
axis.text = element_blank(),
axis.title = element_text(size = ceiling(base_size*0.8)),
axis.text.x = element_text(angle = 90),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.major.x = element_blank(),
panel.background = element_blank(), panel.border = element_blank(),
strip.background = element_rect(linetype = 1, fill = "white"),
strip.text = element_text(),
strip.text.x = element_text(vjust = 0.5),
strip.text.y = element_text(angle = -90),
strip.placement.y = "outside",
legend.position="bottom",
plot.title = element_text(size = ceiling(base_size*1.1), face = "bold"),
plot.subtitle = element_text(size = ceiling(base_size*1.05)))
png(file.path(outdir, "plot_stressor_by_source.png"), width = 8.5, height = 5, units = "in", res = 300)
ggarrange(ghg_plot, N_plot, P_plot, water_plot, land_plot, nrow = 1,
common.legend = TRUE, legend = "bottom", align = "h", widths = c(1.1, 0.7, 0.7, 0.7, 0.7))
dev.off()