[REFERENCE RMD FILE: https://cdn.rawgit.com/OHI-Science/ohiprep/master/globalprep/mar/v2017/mar_dataprep.html]
This analysis converts FAO mariculture data into data used to calculate the OHI global mariculture status score. This also calculates the genetic escapee from mariculture pressure data.
New year of FAO mariculture yield data, but no changes to sustainability or genetic escapee data or general methods.
A few small corrections to make sure the FAO_species fields matched in the species_list and Trujillo data.
Reference:
http://www.fao.org/fishery/statistics/software/fishstatj/en#downlApp Release date: July 2017 FAO Global Aquaculture Production Quantity 1950_2014
Downloaded: 8/10/2017
Description: Quantity (tonnes) of mariculture for each county, species, year.
Time range: 1950-2015
# load libraries, set directories
library(ohicore) #devtools::install_github('ohi-science/ohicore@dev')
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(stringr)
library(tidyr)
## comment out when knitting
#setwd("globalprep/mar/v2017")
### Load FAO-specific user-defined functions
source('mar_fxs.R') # functions specific to mariculture dealing with compound countries
source('../../../src/R/fao_fxn.R') # function for cleaning FAO files
source('../../../src/R/common.R') # directory locations
Clean mariculture data: Filter freshwater mariculture, make long format, and clean FAO codes.
mar <- read.csv(file.path(dir_M, 'git-annex/globalprep/_raw_data/FAO_mariculture/d2017/FAO_GlobalAquacultureProduction_Quantity_1950_2015.csv'), check.names=FALSE, stringsAsFactors=FALSE) ; head(mar)
## Country (Country) Species (ASFIS species)
## 1 Afghanistan Cyprinids nei
## 2 Afghanistan Rainbow trout
## 3 Albania Bighead carp
## 4 Albania Common carp
## 5 Albania Crucian carp
## 6 Albania European seabass
## Aquaculture area (FAO major fishing area) Environment (Environment) Unit
## 1 Asia - Inland waters Freshwater t
## 2 Asia - Inland waters Freshwater t
## 3 Europe - Inland waters Freshwater t
## 4 Europe - Inland waters Freshwater t
## 5 Europe - Inland waters Freshwater t
## 6 Mediterranean and Black Sea Marine t
## 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963
## 1 ... ... ... ... ... ... ... ... ... ... ... ... ... ...
## 2 ... ... ... ... ... ... ... ... ... ... ... ... ... ...
## 3 - - - - - - - - - - - - - -
## 4 ... ... ... ... ... ... ... ... ... ... ... ... ... ...
## 5 ... ... ... ... ... ... ... ... ... ... ... ... ... ...
## 6 ... ... ... ... ... ... ... ... ... ... ... ... ... ...
## 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977
## 1 ... ... ... ... ... 50 F 50 F 50 F 50 F 50 F 50 F 50 F 150 F 150 F
## 2 ... ... ... ... ... 10 F 10 F 10 F 10 F 10 F 10 F 10 F 20 F 20 F
## 3 - - - - - - - - - - - - - -
## 4 ... ... ... ... ... ... ... ... ... ... ... ... ... ...
## 5 ... ... ... ... ... ... ... ... ... ... ... ... ... ...
## 6 ... ... ... ... ... ... ... ... ... ... ... ... ... ...
## 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989
## 1 150 F 150 F 150 F 150 F 150 F 150 F 150 F 150 F 150 F 150 F 150 F 150 F
## 2 20 F 20 F 20 F 20 F 20 F 20 F 20 F 20 F 20 F 20 F 20 F 20 F
## 3 - - - - - - - - - - - -
## 4 ... ... ... ... 4 F 10 F 10 20 48 42 62 126
## 5 ... ... ... 1 F 6 F 8 F 10 10 12 5 2 7
## 6 ... ... ... ... ... ... ... ... ... ... ... ...
## 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001
## 1 300 F 300 F 300 F 300 F 300 F 300 F 300 F 300 F 300 F 300 F 300 F 400 F
## 2 ... ... ... ... ... ... ... ... ... ... ... 50 F
## 3 - - - - - - - - - - - -
## 4 76 F 23 F 13 F 13 F 14 F 34 F 45 F 4 4 2 2 3
## 5 5 F 2 F 1 F 2 F 1 F - - - - - - -
## 6 ... ... ... ... ... ... ... ... ... ... ... ...
## 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013
## 1 400 F 400 F 400 F 400 F 400 F 900 F 900 F 900 F 900 F 900 F 900 F 900 F
## 2 50 F 50 F 50 F 50 F 50 F 150 F 150 F 150 F 150 F 150 F 150 F 150 F
## 3 - - - - - - - - - - - -
## 4 4 6 8 6 10 10 74 6 6 8 222 200 F
## 5 - - - - - - - - - - - -
## 6 ... ... ... ... 87 84 142 135 135 170 170 170 F
## 2014 2015
## 1 950 F 1000 F
## 2 150 F 150 F
## 3 - 16
## 4 214 26.8
## 5 - 12
## 6 129.4 392
# mar <- read.csv('D:/git-annex/globalprep/_raw_data/FAO_mariculture/d2017/FAO_GlobalAquacultureProduction_Quantity_1950_2015.csv', check.names=FALSE, stringsAsFactors=FALSE) ; head(mar)
mar <- mar %>%
rename(country = `Country (Country)`,
FAO_name = `Species (ASFIS species)`,
fao = `Aquaculture area (FAO major fishing area)`,
environment = `Environment (Environment)`)
table(mar$environment)
##
## Brackishwater Freshwater Marine
## 491 1722 1041
# include only marine environments
mar <- mar %>%
filter(environment %in% c("Brackishwater", "Marine"))
## long format and clean FAO codes:
mar <- mar %>%
select(-Unit)
## for some reason, I can't provide the data range in gather programatically!
col_num <- ncol(data.frame(mar))
range <- 5:col_num
mar <- mar %>%
gather(key="year", value="value", 5:70) %>%
fao_clean_data()
Update species names and exclude non-food species. I simplified the species_list. I cut the “species”" name columns because it wasn’t clear what this was trying to accomplish and created potential error.
mar_sp <- read.csv('raw/species_list.csv', stringsAsFactors=FALSE) %>%
select(FAO_name, exclude, alias, Taxon_code)
new.spp <- setdiff(mar$FAO_name, mar_sp$FAO_name)
new.spp # check: if dim has 0 rows it means all match
## character(0)
# if length(new.spp) >0 , hand check whether to keep (exclude seaweeds and species harvested for ornamental/medicinal), check if synonyms match Trujillo names
# Remove species not relevant to mariculuture goal (i.e., non-food species)
mar <- left_join (mar, mar_sp, by="FAO_name")
mar <- filter (mar, exclude==0)
# change names using species name and the species alias (global changes)
mar$species <- ifelse(!is.na(mar$alias), mar$alias, mar$FAO_name)
# sum duplicates after name change (this also gets rid of the NA values)
mar <- mar %>%
filter(!is.na(value)) %>%
group_by(country, fao, environment, species, year, Taxon_code) %>%
summarize(value = sum(value)) %>%
ungroup()
# eliminate time-series with all 0s
mar <- mar %>%
group_by(country, species) %>%
mutate(total_value = sum(value)) %>%
filter(total_value > 0) %>%
select(-total_value) %>%
ungroup()
Convert country names to OHI regions
# Divide mariculture from countries that we report as separate regions (assume equal production in all regions)
# Netherlands Antilles: Conch restoration among Aruba, Bonaire, Curacao
# Channel Islands: Jersey and Guernsey
# Bonaire/S.Eustatius/Saba
# Yugoslavia SFR: no longer a country after 1992
mar <- mar %>%
mutate(country = ifelse(country=="R\xe9union", "Reunion", country)) %>% # this one is hard to get right
mar_split() # function in mar_fxs.R
mar_rgn <- name_2_rgn(df_in = mar,
fld_name='country',
flds_unique=c('species', 'fao', 'environment', 'Taxon_code', 'year'))
##
## These data were removed for not having any match in the lookup tables:
##
## Yugoslavia SFR
## 1
##
## These data were removed for not being of the proper rgn_type (eez,ohi_region) or mismatching region names in the lookup tables:
## tmp_type
## tmp_name disputed
## Palestine, Occupied Tr. 9
##
## DUPLICATES found. Consider using collapse2rgn to collapse duplicates (function in progress).
## # A tibble: 15 x 1
## country
## <chr>
## 1 Aruba
## 2 Bonaire
## 3 China
## 4 China, Hong Kong SAR
## 5 Curacao
## 6 Guadeloupe
## 7 Guam
## 8 Martinique
## 9 Montenegro
## 10 Northern Mariana Is.
## 11 Russian Federation
## 12 Serbia and Montenegro
## 13 Tanzania, United Rep. of
## 14 Un. Sov. Soc. Rep.
## 15 Zanzibar
### sum values of regions with multiple subregions
mar_rgn <- mar_rgn %>%
group_by(fao, environment, species, year, Taxon_code, rgn_id) %>%
summarize(value = sum(value)) %>%
ungroup()
data.frame(filter(mar_rgn, rgn_id==130) %>%
filter(year==2013) %>%
arrange(species))
## fao environment species year
## 1 Pacific, Eastern Central Marine Natantian decapods nei 2013
## 2 Pacific, Eastern Central Brackishwater Pacific cupped oyster 2013
## 3 Pacific, Eastern Central Brackishwater Spotted rose snapper 2013
## 4 Pacific, Eastern Central Brackishwater Whiteleg shrimp 2013
## Taxon_code rgn_id value
## 1 CRUST 130 0
## 2 BI 130 20
## 3 F 130 180
## 4 SH 130 2890
For some regions, a specific species can be altered so that it matches more general Trujillo sustainability data. In this case, I don’t want the name changes to be global because some regions may have more specific species data.
(Will explore this in the future, but will not implement this year).
# ## based on looking at the list, make a few name changes to match the regions Trujillo data
# # Chile name modification
# mar_rgn$species[mar_rgn$rgn_id==224 & mar_rgn$species == "Red abalone"] <- "Abalones nei"
# mar_rgn$species[mar_rgn$rgn_id==224 & mar_rgn$species == "Japanese abalone"] <- "Abalones nei"
#
# # China
# mar_rgn$species[mar_rgn$rgn_id==209 & mar_rgn$species == "Areolate grouper"] <- "Groupers nei"
# mar_rgn$species[mar_rgn$rgn_id==209 & mar_rgn$species == "Greasy grouper"] <- "Groupers nei"
# mar_rgn$species[mar_rgn$rgn_id==209 & mar_rgn$species == "Hong Kong grouper"] <- "Groupers nei"
# mar_rgn$species[mar_rgn$rgn_id==209 & mar_rgn$species == "Orange-spotted grouper"] <- "Groupers nei"
#
# # Honduras
# mar_rgn$species[mar_rgn$rgn_id==133 & mar_rgn$species == "Whiteleg shrimp"] <- "Penaeus shrimps nei"
#
# # Italy
# mar_rgn$species[mar_rgn$rgn_id==84 & mar_rgn$species == "Pacific cupped oyster"] <- "Cupped oysters nei"
#
# # New Zealand
# mar_rgn$species[mar_rgn$rgn_id==162 & mar_rgn$species == "Rainbow abalone"] <- "Abalones nei"
#
# # Pakistan
# mar_rgn$species[mar_rgn$rgn_id==53 & mar_rgn$species == "Penaeus shrimps nei"] <- "Marine crustaceans nei"
#
# # Philippines
# mar_rgn$species[mar_rgn$rgn_id==15 & mar_rgn$species == "Whiteleg shrimp"] <- "Penaeus shrimps nei"
#
# # Portugal
# mar_rgn$species[mar_rgn$rgn_id==183 & mar_rgn$species == "Golden carpet shell"] <- "Marine molluscs nei"
# mar_rgn$species[mar_rgn$rgn_id==183 & mar_rgn$species == "Peppery furrow"] <- "Marine molluscs nei"
# mar_rgn$species[mar_rgn$rgn_id==183 & mar_rgn$species == "Solen razor clams nei"] <- "Razor clams nei"
# mar_rgn$species[mar_rgn$rgn_id==183 & mar_rgn$species == "Atlantic bluefin tuna"] <- "Marine fishes nei"
# mar_rgn$species[mar_rgn$rgn_id==183 & mar_rgn$species == "Meagre"] <- "Marine fishes nei"
# mar_rgn$species[mar_rgn$rgn_id==183 & mar_rgn$species == "Seabasses nei"] <- "Marine fishes nei"
# mar_rgn$species[mar_rgn$rgn_id==183 & mar_rgn$species == "Soles nei"] <- "Marine fishes nei"
# mar_rgn$species[mar_rgn$rgn_id==183 & mar_rgn$species == "White seabream"] <- "Marine fishes nei"
#
# # Spain
# mar_rgn$species[mar_rgn$rgn_id==182 & mar_rgn$species == "Atlantic bluefin tuna"] <- "Tuna-like fishes nei"
#
# # Turkey
# mar_rgn$species[mar_rgn$rgn_id==76 & mar_rgn$species == "Atlantic bluefin tuna"] <- "Tuna-like fishes nei"
# mar_rgn$species[mar_rgn$rgn_id==76 & mar_rgn$species == "European seabass"] <- "Seabasses nei"
#
# ### sum values of regions with multiple subregions
# mar_rgn <- mar_rgn %>%
# group_by(fao, environment, species, year, Taxon_code, rgn_id) %>%
# summarize(value = sum(value)) %>%
# ungroup()
Fill in missing years after first harvest with 0 values
mar_rgn_spread <- spread(mar_rgn, year, value)
dim(mar_rgn_spread)
## [1] 1301 71
mar_rgn_gf <- gather(mar_rgn_spread, "year", "value", 6:71) %>%
arrange(rgn_id, species, year, Taxon_code, fao, environment)
## NA values are converted to zero. I checked to make sure there
## weren't instances in which in made more sense to carry the previous
## years data forward as a method of gapfilling. This didn't seem to be the case
mar_rgn_gf <- mar_rgn_gf %>%
mutate(year = as.numeric(as.character(year))) %>%
mutate(value_w_0 = ifelse(is.na(value), 0, value)) %>%
group_by(fao, environment, species, Taxon_code, rgn_id) %>%
mutate(cum_value = cumsum(value_w_0)) %>%
ungroup() %>%
filter(cum_value > 0) %>%
mutate(gap_0_fill = ifelse(is.na(value), "NA_to_zero", "0")) %>%
mutate(value = ifelse(is.na(value), 0, value)) %>%
select(-cum_value, -value_w_0)
table(mar_rgn_gf$gap_0_fill)
##
## 0 NA_to_zero
## 25842 3344
## 3344 of these out of 25842+3344 cases
Remove time series with less than four non-zero datapoints (assume these are not established mariculture programs).
mar_rgn_gf = mar_rgn_gf %>%
group_by(rgn_id, species, fao, environment) %>%
mutate (not_0 = length(value[value>0])) %>%
filter (not_0>3) %>%
ungroup() %>%
select(rgn_id, species, fao, environment, year, value, Taxon_code, gap_0_fill)
Add a unique identifier per cultivated stock that describes species, fao region, and environment.
# add a unique identifier per cultivated stock
identifier = mar_rgn_gf %>%
select(rgn_id, species, fao, environment) %>%
unique() %>%
mutate(species_code = 1:n())
mar_rgn_gf = left_join(mar_rgn_gf, identifier)
## Joining, by = c("rgn_id", "species", "fao", "environment")
maric <- mar_rgn_gf
Save file to estimate total mariculture yield per country.
write.csv(maric, 'output/MAR_FP_data.csv', row.names=FALSE)
These data describe the sustainability and genetic escapes for country/species combinations (and, in a couple cases, environment and fao region combinations). In cases where these data were not available for a specific county/species, we averaged the data across taxonomic groups to gapfill the missing data.
Convert country names to OHI region names.
# Trujillo sustainability data:
sus = read.csv('raw/Truj_label_sust.csv', stringsAsFactors = FALSE, na.strings = NA)
## these need to be re-added (get cut when associated with region ids)
sus_no_rgn <- filter(sus, is.na(country))
# convert country names to OHI region names:
sus_rgn <- name_2_rgn(df_in = sus,
fld_name='country',
flds_unique=c('species_fao', 'fao', 'environment', 'species_Truj'))
##
## These data were removed for not having any match in the lookup tables:
## < table of extent 0 >
sus_rgn <- bind_rows(sus_rgn, sus_no_rgn) %>%
unique()
# check the fao spp list in the Trujillo sustainability file matches FAO mariculture species
setdiff(sus_rgn$species_fao, maric$species) # species that are no longer have mariculture industry or are not included due to being freshwater or non-food
## [1] "River Plata mussel" "Gracilaria seaweeds"
## [3] "Laver (Nori)" "Atlantic wolffish"
## [5] "Spotted wolffish" "Bagrid catfish"
## [7] "Freshwater fishes nei" "Tilapias nei"
## [9] "Torpedo catfishes nei" "Brill"
## [11] "Razor clams nei" "Brown seaweeds"
## [13] "Brown seaweeds (Pac)" "Silver carp"
## [15] "Sturgeons nei" "Blackchin tilapia"
## [17] "Giant river prawn" "Nile tilapia"
## [19] "Aquatic plants nei" "Tuna-like fishes nei"
## [21] "Algae & marine plants" "All others"
## [23] "Bivalve & gastropod" "Blue tilapia"
## [25] "Cephalopod" "Crabs and lobsters"
## [27] "Eucheuma seaweeds nei" "Fish"
## [29] "Importo totale" "Inverts"
## [31] "Japanese kelp" "Molluscs"
## [33] "Mozambique tilapia" "Non-crustacean invert"
## [35] "Nori nei" "Shrimp & prawn"
## [37] "Spiny eucheuma" "Trouts nei"
## [39] "Tunicate" "Urchin"
## [41] "Wakame" "Warty gracilaria"
sort(setdiff(maric$species, sus_rgn$species_fao)) # species with no Trujillo data
## [1] "Akiami paste shrimp" "Amberjacks nei"
## [3] "Anadara clams nei" "Aquatic invertebrates nei"
## [5] "Areolate grouper" "Atlantic ditch shrimp"
## [7] "Australian mussel" "Banded carpet shell"
## [9] "Bastard halibut" "Bastard halibuts nei"
## [11] "Bear paw clam" "Blackhead seabream"
## [13] "Blacklip pearl oyster" "Blackspot(=red) seabream"
## [15] "blood cockle" "Blue crab"
## [17] "Blue swimming crab" "Brine shrimp"
## [19] "Brown tiger prawn" "Butter clam"
## [21] "Caramote prawn" "Chars nei"
## [23] "Chilean flat oyster" "Chilean mussel"
## [25] "Cholga mussel" "Choro mussel"
## [27] "Cobia" "Cockles nei"
## [29] "Common dentex" "Common pandora"
## [31] "Common prawn" "Cortez oyster"
## [33] "Crevalle jack" "Crimson seabream"
## [35] "Croakers, drums nei" "Crocus giant clam"
## [37] "Donax clams" "Dotted gizzard shad"
## [39] "Drums nei" "Eastern king prawn"
## [41] "Eastern school shrimp" "Elongate giant clam"
## [43] "European flounder" "European whitefish"
## [45] "Filefishes, leatherjackets nei" "Filefishes nei"
## [47] "Finfishes nei" "Flathead lobster"
## [49] "Fleshy prawn" "Florida pompano"
## [51] "Fluted giant clam" "Fourfinger threadfin"
## [53] "Gastropods nei" "Gazami crab"
## [55] "Giant clam" "Giant clams nei"
## [57] "Globose clam" "Golden carpet shell"
## [59] "Golden trevally" "Goldlined seabream"
## [61] "Goldsilk seabream" "Greasy grouper"
## [63] "Great Atlantic scallop" "Greater amberjack"
## [65] "Green crab" "Green tiger prawn"
## [67] "Groundfishes nei" "Gudgeons, sleepers nei"
## [69] "Hong Kong grouper" "Hooded oyster"
## [71] "Horned turban" "Horse mussels nei"
## [73] "Humpback grouper" "Indian backwater oyster"
## [75] "Indo-Pacific swamp crab" "Inflated ark"
## [77] "Jacks, crevalles nei" "Japanese abalone"
## [79] "Japanese amberjack" "Japanese eel"
## [81] "Japanese hard clam" "Japanese jack mackerel"
## [83] "Japanese meagre" "Japanese seabass"
## [85] "Japanese sea cucumber" "Japanese spiny lobster"
## [87] "Jellyfishes nei" "Korean rockfish"
## [89] "Largemouth black bass" "Large yellow croaker"
## [91] "Lebranche mullet" "Lefteye flounders nei"
## [93] "Mackerels nei" "Malabar grouper"
## [95] "Mangrove cupped oyster" "Marbled spinefoot"
## [97] "Marine crabs nei" "Meagre"
## [99] "Mud spiny lobster" "Northern quahog(=Hard clam)"
## [101] "Northern white shrimp" "Octopuses, etc. nei"
## [103] "Okhotsk atka mackerel" "Olympia oyster"
## [105] "Orange mud crab" "Pacific bluefin tuna"
## [107] "Pacific calico scallop" "Pacific geoduck"
## [109] "Pacific horse clam" "Pacific lion's paw"
## [111] "Pacific littleneck clam" "Palaemonid shrimps nei"
## [113] "Papuan black snapper" "Pargo breams nei"
## [115] "Pearl oyster shells nei" "Penguin wing oyster"
## [117] "Pen shells nei" "Peppery furrow"
## [119] "Periwinkles nei" "Pod razor shell"
## [121] "Pollack" "Porgies, seabreams nei"
## [123] "Portunus swimcrabs nei" "Puffers nei"
## [125] "Queen conch" "Queen scallop"
## [127] "Rainbow abalone" "Red abalone"
## [129] "Red porgy" "Redtail prawn"
## [131] "Righteye flounders nei" "Russell's snapper"
## [133] "Salmonids nei" "Salmonoids nei"
## [135] "Sand gaper" "Scats"
## [137] "Sciaenas nei" "Scorpionfishes nei"
## [139] "Sea cucumbers nei" "Sea snails"
## [141] "Sea squirts nei" "Senegalese sole"
## [143] "Sharpsnout seabream" "Shi drum"
## [145] "Sixfinger threadfin" "Slipper cupped oyster"
## [147] "Smooth giant clam" "Snappers, jobfishes nei"
## [149] "Snooks(=Robalos) nei" "Snubnose pompano"
## [151] "Sobaity seabream" "[Solea spp]"
## [153] "Solen razor clams nei" "Soles nei"
## [155] "South American rock mussel" "Southern Australia scallop"
## [157] "Southern white shrimp" "Speckled shrimp"
## [159] "Spiny lobsters nei" "Spotted rose snapper"
## [161] "Spotted seabass" "Squaretail mullet"
## [163] "Stony sea urchin" "Streaked spinefoot"
## [165] "Striped bass, hybrid" "Stromboid conchs nei"
## [167] "Sydney cupped oyster" "Thinlip grey mullet"
## [169] "Tropical spiny lobsters nei" "Trumpet emperor"
## [171] "Variegated scallop" "Venus clams nei"
## [173] "Warty venus" "Whitemouth croaker"
## [175] "White seabream" "White-spotted spinefoot"
## [177] "White trevally" "Yellowfin seabream"
Match the sustainability score to the FAO mariculture data.
The following joins the sustainability scores to regions/species that have Trujillo data.
table(sus_rgn$match_type)
##
## c_sp c_sp_env c_sp_fao species taxon
## 301 4 2 110 12
# join taxa specific to country/species/environment
c_sp_env = sus_rgn %>%
filter(match_type == 'c_sp_env') %>%
select(rgn_id, species=species_fao, environment, Sust_c_sp_env = Maric_sustainability)
mar_sus <- maric %>%
left_join(c_sp_env, by= c("species", "environment", "rgn_id"))
# join taxa specific to country/species/fao region
c_sp_fao = sus_rgn %>%
filter(match_type == 'c_sp_fao') %>%
select(rgn_id, species=species_fao, fao, Sust_c_sp_fao = Maric_sustainability)
mar_sus <- mar_sus %>%
left_join(c_sp_fao, by= c("species", "fao", "rgn_id"))
data.frame(filter(mar_sus, rgn_id==218 & species == "Atlantic salmon"))
## rgn_id species fao environment year value
## 1 218 Atlantic salmon Atlantic, Northwest Marine 1979 5
## 2 218 Atlantic salmon Atlantic, Northwest Marine 1980 27
## 3 218 Atlantic salmon Atlantic, Northwest Marine 1981 76
## 4 218 Atlantic salmon Atlantic, Northwest Marine 1982 143
## 5 218 Atlantic salmon Atlantic, Northwest Marine 1983 68
## 6 218 Atlantic salmon Atlantic, Northwest Marine 1984 222
## 7 218 Atlantic salmon Atlantic, Northwest Marine 1985 349
## 8 218 Atlantic salmon Atlantic, Northwest Marine 1986 682
## 9 218 Atlantic salmon Atlantic, Northwest Marine 1987 1382
## 10 218 Atlantic salmon Pacific, Northeast Marine 1987 3
## 11 218 Atlantic salmon Atlantic, Northwest Marine 1988 3351
## 12 218 Atlantic salmon Pacific, Northeast Marine 1988 80
## 13 218 Atlantic salmon Atlantic, Northwest Marine 1989 4687
## 14 218 Atlantic salmon Pacific, Northeast Marine 1989 1280
## 15 218 Atlantic salmon Atlantic, Northwest Marine 1990 7835
## 16 218 Atlantic salmon Pacific, Northeast Marine 1990 1790
## 17 218 Atlantic salmon Atlantic, Northwest Marine 1991 9848
## 18 218 Atlantic salmon Pacific, Northeast Marine 1991 3651
## 19 218 Atlantic salmon Atlantic, Northwest Marine 1992 10520
## 20 218 Atlantic salmon Pacific, Northeast Marine 1992 6785
## 21 218 Atlantic salmon Atlantic, Northwest Marine 1993 11123
## 22 218 Atlantic salmon Pacific, Northeast Marine 1993 12360
## 23 218 Atlantic salmon Atlantic, Northwest Marine 1994 12426
## 24 218 Atlantic salmon Pacific, Northeast Marine 1994 15347
## 25 218 Atlantic salmon Atlantic, Northwest Marine 1995 15235
## 26 218 Atlantic salmon Pacific, Northeast Marine 1995 18439
## 27 218 Atlantic salmon Atlantic, Northwest Marine 1996 17800
## 28 218 Atlantic salmon Pacific, Northeast Marine 1996 18675
## 29 218 Atlantic salmon Atlantic, Northwest Marine 1997 20310
## 30 218 Atlantic salmon Pacific, Northeast Marine 1997 30705
## 31 218 Atlantic salmon Atlantic, Northwest Marine 1998 16418
## 32 218 Atlantic salmon Pacific, Northeast Marine 1998 33057
## 33 218 Atlantic salmon Atlantic, Northwest Marine 1999 23190
## 34 218 Atlantic salmon Pacific, Northeast Marine 1999 38800
## 35 218 Atlantic salmon Atlantic, Northwest Marine 2000 33195
## 36 218 Atlantic salmon Pacific, Northeast Marine 2000 39300
## 37 218 Atlantic salmon Atlantic, Northwest Marine 2001 37606
## 38 218 Atlantic salmon Pacific, Northeast Marine 2001 58000
## 39 218 Atlantic salmon Atlantic, Northwest Marine 2002 42121
## 40 218 Atlantic salmon Pacific, Northeast Marine 2002 72800
## 41 218 Atlantic salmon Atlantic, Northwest Marine 2003 34550
## 42 218 Atlantic salmon Pacific, Northeast Marine 2003 72678
## 43 218 Atlantic salmon Atlantic, Northwest Marine 2004 35000
## 44 218 Atlantic salmon Pacific, Northeast Marine 2004 61774
## 45 218 Atlantic salmon Atlantic, Northwest Marine 2005 35000
## 46 218 Atlantic salmon Pacific, Northeast Marine 2005 63370
## 47 218 Atlantic salmon Atlantic, Northwest Marine 2006 47880
## 48 218 Atlantic salmon Pacific, Northeast Marine 2006 70181
## 49 218 Atlantic salmon Atlantic, Northwest Marine 2007 31511
## 50 218 Atlantic salmon Pacific, Northeast Marine 2007 70998
## 51 218 Atlantic salmon Atlantic, Northwest Marine 2008 30810
## 52 218 Atlantic salmon Pacific, Northeast Marine 2008 73265
## 53 218 Atlantic salmon Atlantic, Northwest Marine 2009 31550
## 54 218 Atlantic salmon Pacific, Northeast Marine 2009 68662
## 55 218 Atlantic salmon Atlantic, Northwest Marine 2010 30713
## 56 218 Atlantic salmon Pacific, Northeast Marine 2010 70831
## 57 218 Atlantic salmon Atlantic, Northwest Marine 2011 27184
## 58 218 Atlantic salmon Pacific, Northeast Marine 2011 83144
## 59 218 Atlantic salmon Atlantic, Northwest Marine 2012 36120
## 60 218 Atlantic salmon Pacific, Northeast Marine 2012 79981
## 61 218 Atlantic salmon Atlantic, Northwest Marine 2013 25453
## 62 218 Atlantic salmon Pacific, Northeast Marine 2013 72176
## 63 218 Atlantic salmon Atlantic, Northwest Marine 2014 23872
## 64 218 Atlantic salmon Pacific, Northeast Marine 2014 62475
## 65 218 Atlantic salmon Atlantic, Northwest Marine 2015 29000
## 66 218 Atlantic salmon Pacific, Northeast Marine 2015 92926
## Taxon_code gap_0_fill species_code Sust_c_sp_env Sust_c_sp_fao
## 1 F 0 1004 NA 0.17
## 2 F 0 1004 NA 0.17
## 3 F 0 1004 NA 0.17
## 4 F 0 1004 NA 0.17
## 5 F 0 1004 NA 0.17
## 6 F 0 1004 NA 0.17
## 7 F 0 1004 NA 0.17
## 8 F 0 1004 NA 0.17
## 9 F 0 1004 NA 0.17
## 10 F 0 1005 NA 0.27
## 11 F 0 1004 NA 0.17
## 12 F 0 1005 NA 0.27
## 13 F 0 1004 NA 0.17
## 14 F 0 1005 NA 0.27
## 15 F 0 1004 NA 0.17
## 16 F 0 1005 NA 0.27
## 17 F 0 1004 NA 0.17
## 18 F 0 1005 NA 0.27
## 19 F 0 1004 NA 0.17
## 20 F 0 1005 NA 0.27
## 21 F 0 1004 NA 0.17
## 22 F 0 1005 NA 0.27
## 23 F 0 1004 NA 0.17
## 24 F 0 1005 NA 0.27
## 25 F 0 1004 NA 0.17
## 26 F 0 1005 NA 0.27
## 27 F 0 1004 NA 0.17
## 28 F 0 1005 NA 0.27
## 29 F 0 1004 NA 0.17
## 30 F 0 1005 NA 0.27
## 31 F 0 1004 NA 0.17
## 32 F 0 1005 NA 0.27
## 33 F 0 1004 NA 0.17
## 34 F 0 1005 NA 0.27
## 35 F 0 1004 NA 0.17
## 36 F 0 1005 NA 0.27
## 37 F 0 1004 NA 0.17
## 38 F 0 1005 NA 0.27
## 39 F 0 1004 NA 0.17
## 40 F 0 1005 NA 0.27
## 41 F 0 1004 NA 0.17
## 42 F 0 1005 NA 0.27
## 43 F 0 1004 NA 0.17
## 44 F 0 1005 NA 0.27
## 45 F 0 1004 NA 0.17
## 46 F 0 1005 NA 0.27
## 47 F 0 1004 NA 0.17
## 48 F 0 1005 NA 0.27
## 49 F 0 1004 NA 0.17
## 50 F 0 1005 NA 0.27
## 51 F 0 1004 NA 0.17
## 52 F 0 1005 NA 0.27
## 53 F 0 1004 NA 0.17
## 54 F 0 1005 NA 0.27
## 55 F 0 1004 NA 0.17
## 56 F 0 1005 NA 0.27
## 57 F 0 1004 NA 0.17
## 58 F 0 1005 NA 0.27
## 59 F 0 1004 NA 0.17
## 60 F 0 1005 NA 0.27
## 61 F 0 1004 NA 0.17
## 62 F 0 1005 NA 0.27
## 63 F 0 1004 NA 0.17
## 64 F 0 1005 NA 0.27
## 65 F 0 1004 NA 0.17
## 66 F 0 1005 NA 0.27
data.frame(filter(mar_sus, !is.na(Sust_c_sp_fao)))
## rgn_id species fao environment year value
## 1 218 Atlantic salmon Atlantic, Northwest Marine 1979 5
## 2 218 Atlantic salmon Atlantic, Northwest Marine 1980 27
## 3 218 Atlantic salmon Atlantic, Northwest Marine 1981 76
## 4 218 Atlantic salmon Atlantic, Northwest Marine 1982 143
## 5 218 Atlantic salmon Atlantic, Northwest Marine 1983 68
## 6 218 Atlantic salmon Atlantic, Northwest Marine 1984 222
## 7 218 Atlantic salmon Atlantic, Northwest Marine 1985 349
## 8 218 Atlantic salmon Atlantic, Northwest Marine 1986 682
## 9 218 Atlantic salmon Atlantic, Northwest Marine 1987 1382
## 10 218 Atlantic salmon Pacific, Northeast Marine 1987 3
## 11 218 Atlantic salmon Atlantic, Northwest Marine 1988 3351
## 12 218 Atlantic salmon Pacific, Northeast Marine 1988 80
## 13 218 Atlantic salmon Atlantic, Northwest Marine 1989 4687
## 14 218 Atlantic salmon Pacific, Northeast Marine 1989 1280
## 15 218 Atlantic salmon Atlantic, Northwest Marine 1990 7835
## 16 218 Atlantic salmon Pacific, Northeast Marine 1990 1790
## 17 218 Atlantic salmon Atlantic, Northwest Marine 1991 9848
## 18 218 Atlantic salmon Pacific, Northeast Marine 1991 3651
## 19 218 Atlantic salmon Atlantic, Northwest Marine 1992 10520
## 20 218 Atlantic salmon Pacific, Northeast Marine 1992 6785
## 21 218 Atlantic salmon Atlantic, Northwest Marine 1993 11123
## 22 218 Atlantic salmon Pacific, Northeast Marine 1993 12360
## 23 218 Atlantic salmon Atlantic, Northwest Marine 1994 12426
## 24 218 Atlantic salmon Pacific, Northeast Marine 1994 15347
## 25 218 Atlantic salmon Atlantic, Northwest Marine 1995 15235
## 26 218 Atlantic salmon Pacific, Northeast Marine 1995 18439
## 27 218 Atlantic salmon Atlantic, Northwest Marine 1996 17800
## 28 218 Atlantic salmon Pacific, Northeast Marine 1996 18675
## 29 218 Atlantic salmon Atlantic, Northwest Marine 1997 20310
## 30 218 Atlantic salmon Pacific, Northeast Marine 1997 30705
## 31 218 Atlantic salmon Atlantic, Northwest Marine 1998 16418
## 32 218 Atlantic salmon Pacific, Northeast Marine 1998 33057
## 33 218 Atlantic salmon Atlantic, Northwest Marine 1999 23190
## 34 218 Atlantic salmon Pacific, Northeast Marine 1999 38800
## 35 218 Atlantic salmon Atlantic, Northwest Marine 2000 33195
## 36 218 Atlantic salmon Pacific, Northeast Marine 2000 39300
## 37 218 Atlantic salmon Atlantic, Northwest Marine 2001 37606
## 38 218 Atlantic salmon Pacific, Northeast Marine 2001 58000
## 39 218 Atlantic salmon Atlantic, Northwest Marine 2002 42121
## 40 218 Atlantic salmon Pacific, Northeast Marine 2002 72800
## 41 218 Atlantic salmon Atlantic, Northwest Marine 2003 34550
## 42 218 Atlantic salmon Pacific, Northeast Marine 2003 72678
## 43 218 Atlantic salmon Atlantic, Northwest Marine 2004 35000
## 44 218 Atlantic salmon Pacific, Northeast Marine 2004 61774
## 45 218 Atlantic salmon Atlantic, Northwest Marine 2005 35000
## 46 218 Atlantic salmon Pacific, Northeast Marine 2005 63370
## 47 218 Atlantic salmon Atlantic, Northwest Marine 2006 47880
## 48 218 Atlantic salmon Pacific, Northeast Marine 2006 70181
## 49 218 Atlantic salmon Atlantic, Northwest Marine 2007 31511
## 50 218 Atlantic salmon Pacific, Northeast Marine 2007 70998
## 51 218 Atlantic salmon Atlantic, Northwest Marine 2008 30810
## 52 218 Atlantic salmon Pacific, Northeast Marine 2008 73265
## 53 218 Atlantic salmon Atlantic, Northwest Marine 2009 31550
## 54 218 Atlantic salmon Pacific, Northeast Marine 2009 68662
## 55 218 Atlantic salmon Atlantic, Northwest Marine 2010 30713
## 56 218 Atlantic salmon Pacific, Northeast Marine 2010 70831
## 57 218 Atlantic salmon Atlantic, Northwest Marine 2011 27184
## 58 218 Atlantic salmon Pacific, Northeast Marine 2011 83144
## 59 218 Atlantic salmon Atlantic, Northwest Marine 2012 36120
## 60 218 Atlantic salmon Pacific, Northeast Marine 2012 79981
## 61 218 Atlantic salmon Atlantic, Northwest Marine 2013 25453
## 62 218 Atlantic salmon Pacific, Northeast Marine 2013 72176
## 63 218 Atlantic salmon Atlantic, Northwest Marine 2014 23872
## 64 218 Atlantic salmon Pacific, Northeast Marine 2014 62475
## 65 218 Atlantic salmon Atlantic, Northwest Marine 2015 29000
## 66 218 Atlantic salmon Pacific, Northeast Marine 2015 92926
## Taxon_code gap_0_fill species_code Sust_c_sp_env Sust_c_sp_fao
## 1 F 0 1004 NA 0.17
## 2 F 0 1004 NA 0.17
## 3 F 0 1004 NA 0.17
## 4 F 0 1004 NA 0.17
## 5 F 0 1004 NA 0.17
## 6 F 0 1004 NA 0.17
## 7 F 0 1004 NA 0.17
## 8 F 0 1004 NA 0.17
## 9 F 0 1004 NA 0.17
## 10 F 0 1005 NA 0.27
## 11 F 0 1004 NA 0.17
## 12 F 0 1005 NA 0.27
## 13 F 0 1004 NA 0.17
## 14 F 0 1005 NA 0.27
## 15 F 0 1004 NA 0.17
## 16 F 0 1005 NA 0.27
## 17 F 0 1004 NA 0.17
## 18 F 0 1005 NA 0.27
## 19 F 0 1004 NA 0.17
## 20 F 0 1005 NA 0.27
## 21 F 0 1004 NA 0.17
## 22 F 0 1005 NA 0.27
## 23 F 0 1004 NA 0.17
## 24 F 0 1005 NA 0.27
## 25 F 0 1004 NA 0.17
## 26 F 0 1005 NA 0.27
## 27 F 0 1004 NA 0.17
## 28 F 0 1005 NA 0.27
## 29 F 0 1004 NA 0.17
## 30 F 0 1005 NA 0.27
## 31 F 0 1004 NA 0.17
## 32 F 0 1005 NA 0.27
## 33 F 0 1004 NA 0.17
## 34 F 0 1005 NA 0.27
## 35 F 0 1004 NA 0.17
## 36 F 0 1005 NA 0.27
## 37 F 0 1004 NA 0.17
## 38 F 0 1005 NA 0.27
## 39 F 0 1004 NA 0.17
## 40 F 0 1005 NA 0.27
## 41 F 0 1004 NA 0.17
## 42 F 0 1005 NA 0.27
## 43 F 0 1004 NA 0.17
## 44 F 0 1005 NA 0.27
## 45 F 0 1004 NA 0.17
## 46 F 0 1005 NA 0.27
## 47 F 0 1004 NA 0.17
## 48 F 0 1005 NA 0.27
## 49 F 0 1004 NA 0.17
## 50 F 0 1005 NA 0.27
## 51 F 0 1004 NA 0.17
## 52 F 0 1005 NA 0.27
## 53 F 0 1004 NA 0.17
## 54 F 0 1005 NA 0.27
## 55 F 0 1004 NA 0.17
## 56 F 0 1005 NA 0.27
## 57 F 0 1004 NA 0.17
## 58 F 0 1005 NA 0.27
## 59 F 0 1004 NA 0.17
## 60 F 0 1005 NA 0.27
## 61 F 0 1004 NA 0.17
## 62 F 0 1005 NA 0.27
## 63 F 0 1004 NA 0.17
## 64 F 0 1005 NA 0.27
## 65 F 0 1004 NA 0.17
## 66 F 0 1005 NA 0.27
# join taxa specific to country/species
c_sp = sus_rgn %>%
filter(match_type == 'c_sp') %>%
select(rgn_id, species=species_fao, Sust_c_sp = Maric_sustainability)
mar_sus <- mar_sus %>%
left_join(c_sp, by= c("species", "rgn_id"))
summary(mar_sus)
## rgn_id species fao environment
## Min. : 5.0 Length:27001 Length:27001 Length:27001
## 1st Qu.: 51.0 Class :character Class :character Class :character
## Median :163.0 Mode :character Mode :character Mode :character
## Mean :130.3
## 3rd Qu.:205.0
## Max. :250.0
##
## year value Taxon_code gap_0_fill
## Min. :1950 Min. : 0 Length:27001 Length:27001
## 1st Qu.:1991 1st Qu.: 1 Class :character Class :character
## Median :2002 Median : 97 Mode :character Mode :character
## Mean :1998 Mean : 17348
## 3rd Qu.:2009 3rd Qu.: 1818
## Max. :2015 Max. :4573953
##
## species_code Sust_c_sp_env Sust_c_sp_fao Sust_c_sp
## Min. : 1.0 Min. :0.170 Min. :0.170 Min. :0.100
## 1st Qu.: 246.0 1st Qu.:0.170 1st Qu.:0.170 1st Qu.:0.330
## Median : 537.0 Median :0.230 Median :0.170 Median :0.470
## Mean : 536.2 Mean :0.231 Mean :0.214 Mean :0.521
## 3rd Qu.: 833.0 3rd Qu.:0.270 3rd Qu.:0.270 3rd Qu.:0.770
## Max. :1068.0 Max. :0.270 Max. :0.270 Max. :1.000
## NA's :26911 NA's :26935 NA's :17238
### merge these into a single sustainability score
mar_sus = mar_sus %>%
mutate(Sust = ifelse(!is.na(Sust_c_sp_env), Sust_c_sp_env, Sust_c_sp_fao)) %>%
mutate(Sust = ifelse(is.na(Sust), Sust_c_sp, Sust)) %>%
select(-Sust_c_sp_env, -Sust_c_sp_fao, -Sust_c_sp)
This joins the sustainability data that is gapfilled either at the species level (average of specific species/genera across regions) or at a higher course taxonomic levels and documents which data are gapfilled and how.
## Gapfilled at the species/genera level:
gf_sp_sus <- filter(sus_rgn, gapfill != "actuals" & match_type == "species") %>%
select(species = species_fao, gapfill, Sust_gf_sp = Maric_sustainability)
## check that there are no duplicated species_fao
gf_sp_sus[duplicated(gf_sp_sus$species), ]
## [1] species gapfill Sust_gf_sp
## <0 rows> (or 0-length row.names)
# Match gapfilling values by species
mar_sus_gf = mar_sus %>%
left_join(gf_sp_sus, by = 'species')
# Gapfilled at the coarse taxon level:
gf_taxon_sus <- filter(sus_rgn, gapfill != "actuals" & match_type == "taxon") %>%
select(Taxon_code=taxon, Sust_gf_taxon = Maric_sustainability)
# Match gapfilling values by species
mar_sus_gf = mar_sus_gf %>%
left_join(gf_taxon_sus, by = c('Taxon_code'))
summary(mar_sus_gf)
## rgn_id species fao environment
## Min. : 5.0 Length:27001 Length:27001 Length:27001
## 1st Qu.: 51.0 Class :character Class :character Class :character
## Median :163.0 Mode :character Mode :character Mode :character
## Mean :130.3
## 3rd Qu.:205.0
## Max. :250.0
##
## year value Taxon_code gap_0_fill
## Min. :1950 Min. : 0 Length:27001 Length:27001
## 1st Qu.:1991 1st Qu.: 1 Class :character Class :character
## Median :2002 Median : 97 Mode :character Mode :character
## Mean :1998 Mean : 17348
## 3rd Qu.:2009 3rd Qu.: 1818
## Max. :2015 Max. :4573953
##
## species_code Sust gapfill Sust_gf_sp
## Min. : 1.0 Min. :0.100 Length:27001 Min. :0.100
## 1st Qu.: 246.0 1st Qu.:0.330 Class :character 1st Qu.:0.375
## Median : 537.0 Median :0.470 Mode :character Median :0.478
## Mean : 536.2 Mean :0.516 Mean :0.546
## 3rd Qu.: 833.0 3rd Qu.:0.770 3rd Qu.:0.757
## Max. :1068.0 Max. :1.000 Max. :0.902
## NA's :17082 NA's :8214
## Sust_gf_taxon
## Min. :0.3667
## 1st Qu.:0.4440
## Median :0.4440
## Mean :0.5587
## 3rd Qu.:0.8118
## Max. :0.8118
##
table(mar_sus_gf$gapfill)
##
## genus_average sp_average
## 2269 16518
#Obtain a sustainability score for each record, and a book-keeping column of whether it's actual or gap-filled
mar_sus_final = mar_sus_gf %>%
mutate(gapfill = ifelse(!is.na(Sust), "none", gapfill)) %>%
mutate(Sust = ifelse(is.na(Sust), Sust_gf_sp, Sust)) %>%
mutate(gapfill = ifelse(is.na(Sust), "taxon_average", gapfill)) %>%
mutate(Sust = ifelse(is.na(Sust), Sust_gf_taxon, Sust)) %>%
mutate(taxa_code = paste(species, species_code, sep="_")) %>%
select(rgn_id, species, species_code, taxa_code, year, gapfill_sus = gapfill, gapfill_fao = gap_0_fill, tonnes=value, Sust)
## save data layers
mar_harvest_tonnes = mar_sus_final %>%
select(rgn_id, taxa_code, year, tonnes)
anyDuplicated(mar_harvest_tonnes)
## [1] 0
write.csv(mar_harvest_tonnes, 'output/mar_harvest_tonnes.csv', row.names=F)
mar_harvest_tonnes_gf = mar_sus_final %>%
select(rgn_id, taxa_code, year, tonnes=gapfill_fao)
write.csv(mar_harvest_tonnes, 'output/mar_harvest_tonnes_gf.csv', row.names=F)
mar_sustainability_score = mar_sus_final %>%
mutate(year = 2012) %>%
select(rgn_id, year, taxa_code, sust_coeff = Sust) %>%
unique()
anyDuplicated(mar_sustainability_score)
## [1] 0
write.csv(mar_sustainability_score, 'output/mar_sustainability.csv', row.names=F)
mar_sustainability_score_gf = mar_sus_final %>%
select(rgn_id, taxa_code, sust_coeff = gapfill_sus) %>%
unique()
write.csv(mar_sustainability_score, 'output/mar_sustainability_gf.csv', row.names=F)
These data are used as a pressure layer to describe the risk of genetic escapees due to mariculture.
First merge with the species data (no gapfilling) for each country/species/fao region combination.
# can eliminate the environment category because these have the same scores
esc = sus_rgn %>%
filter(!is.na(Genetic.escapees)) %>%
mutate(match_type = ifelse(match_type == "c_sp_env", "c_sp", match_type)) %>%
group_by(rgn_id, species=species_fao, fao, match_type, taxon, gapfill) %>%
summarize(Genetic.escapees = mean(Genetic.escapees)) %>%
ungroup()
# join taxa specific to country/species/fao
c_sp_fao = esc %>%
filter(match_type == 'c_sp_fao') %>%
select(rgn_id, species, fao, Esc_c_sp_fao = Genetic.escapees)
mar_esc <- maric %>%
left_join(c_sp_fao, by= c("species", "fao", "rgn_id"))
data.frame(filter(mar_esc, !is.na(Esc_c_sp_fao)))
## rgn_id species fao environment year value
## 1 218 Atlantic salmon Atlantic, Northwest Marine 1979 5
## 2 218 Atlantic salmon Atlantic, Northwest Marine 1980 27
## 3 218 Atlantic salmon Atlantic, Northwest Marine 1981 76
## 4 218 Atlantic salmon Atlantic, Northwest Marine 1982 143
## 5 218 Atlantic salmon Atlantic, Northwest Marine 1983 68
## 6 218 Atlantic salmon Atlantic, Northwest Marine 1984 222
## 7 218 Atlantic salmon Atlantic, Northwest Marine 1985 349
## 8 218 Atlantic salmon Atlantic, Northwest Marine 1986 682
## 9 218 Atlantic salmon Atlantic, Northwest Marine 1987 1382
## 10 218 Atlantic salmon Pacific, Northeast Marine 1987 3
## 11 218 Atlantic salmon Atlantic, Northwest Marine 1988 3351
## 12 218 Atlantic salmon Pacific, Northeast Marine 1988 80
## 13 218 Atlantic salmon Atlantic, Northwest Marine 1989 4687
## 14 218 Atlantic salmon Pacific, Northeast Marine 1989 1280
## 15 218 Atlantic salmon Atlantic, Northwest Marine 1990 7835
## 16 218 Atlantic salmon Pacific, Northeast Marine 1990 1790
## 17 218 Atlantic salmon Atlantic, Northwest Marine 1991 9848
## 18 218 Atlantic salmon Pacific, Northeast Marine 1991 3651
## 19 218 Atlantic salmon Atlantic, Northwest Marine 1992 10520
## 20 218 Atlantic salmon Pacific, Northeast Marine 1992 6785
## 21 218 Atlantic salmon Atlantic, Northwest Marine 1993 11123
## 22 218 Atlantic salmon Pacific, Northeast Marine 1993 12360
## 23 218 Atlantic salmon Atlantic, Northwest Marine 1994 12426
## 24 218 Atlantic salmon Pacific, Northeast Marine 1994 15347
## 25 218 Atlantic salmon Atlantic, Northwest Marine 1995 15235
## 26 218 Atlantic salmon Pacific, Northeast Marine 1995 18439
## 27 218 Atlantic salmon Atlantic, Northwest Marine 1996 17800
## 28 218 Atlantic salmon Pacific, Northeast Marine 1996 18675
## 29 218 Atlantic salmon Atlantic, Northwest Marine 1997 20310
## 30 218 Atlantic salmon Pacific, Northeast Marine 1997 30705
## 31 218 Atlantic salmon Atlantic, Northwest Marine 1998 16418
## 32 218 Atlantic salmon Pacific, Northeast Marine 1998 33057
## 33 218 Atlantic salmon Atlantic, Northwest Marine 1999 23190
## 34 218 Atlantic salmon Pacific, Northeast Marine 1999 38800
## 35 218 Atlantic salmon Atlantic, Northwest Marine 2000 33195
## 36 218 Atlantic salmon Pacific, Northeast Marine 2000 39300
## 37 218 Atlantic salmon Atlantic, Northwest Marine 2001 37606
## 38 218 Atlantic salmon Pacific, Northeast Marine 2001 58000
## 39 218 Atlantic salmon Atlantic, Northwest Marine 2002 42121
## 40 218 Atlantic salmon Pacific, Northeast Marine 2002 72800
## 41 218 Atlantic salmon Atlantic, Northwest Marine 2003 34550
## 42 218 Atlantic salmon Pacific, Northeast Marine 2003 72678
## 43 218 Atlantic salmon Atlantic, Northwest Marine 2004 35000
## 44 218 Atlantic salmon Pacific, Northeast Marine 2004 61774
## 45 218 Atlantic salmon Atlantic, Northwest Marine 2005 35000
## 46 218 Atlantic salmon Pacific, Northeast Marine 2005 63370
## 47 218 Atlantic salmon Atlantic, Northwest Marine 2006 47880
## 48 218 Atlantic salmon Pacific, Northeast Marine 2006 70181
## 49 218 Atlantic salmon Atlantic, Northwest Marine 2007 31511
## 50 218 Atlantic salmon Pacific, Northeast Marine 2007 70998
## 51 218 Atlantic salmon Atlantic, Northwest Marine 2008 30810
## 52 218 Atlantic salmon Pacific, Northeast Marine 2008 73265
## 53 218 Atlantic salmon Atlantic, Northwest Marine 2009 31550
## 54 218 Atlantic salmon Pacific, Northeast Marine 2009 68662
## 55 218 Atlantic salmon Atlantic, Northwest Marine 2010 30713
## 56 218 Atlantic salmon Pacific, Northeast Marine 2010 70831
## 57 218 Atlantic salmon Atlantic, Northwest Marine 2011 27184
## 58 218 Atlantic salmon Pacific, Northeast Marine 2011 83144
## 59 218 Atlantic salmon Atlantic, Northwest Marine 2012 36120
## 60 218 Atlantic salmon Pacific, Northeast Marine 2012 79981
## 61 218 Atlantic salmon Atlantic, Northwest Marine 2013 25453
## 62 218 Atlantic salmon Pacific, Northeast Marine 2013 72176
## 63 218 Atlantic salmon Atlantic, Northwest Marine 2014 23872
## 64 218 Atlantic salmon Pacific, Northeast Marine 2014 62475
## 65 218 Atlantic salmon Atlantic, Northwest Marine 2015 29000
## 66 218 Atlantic salmon Pacific, Northeast Marine 2015 92926
## Taxon_code gap_0_fill species_code Esc_c_sp_fao
## 1 F 0 1004 1.0
## 2 F 0 1004 1.0
## 3 F 0 1004 1.0
## 4 F 0 1004 1.0
## 5 F 0 1004 1.0
## 6 F 0 1004 1.0
## 7 F 0 1004 1.0
## 8 F 0 1004 1.0
## 9 F 0 1004 1.0
## 10 F 0 1005 0.1
## 11 F 0 1004 1.0
## 12 F 0 1005 0.1
## 13 F 0 1004 1.0
## 14 F 0 1005 0.1
## 15 F 0 1004 1.0
## 16 F 0 1005 0.1
## 17 F 0 1004 1.0
## 18 F 0 1005 0.1
## 19 F 0 1004 1.0
## 20 F 0 1005 0.1
## 21 F 0 1004 1.0
## 22 F 0 1005 0.1
## 23 F 0 1004 1.0
## 24 F 0 1005 0.1
## 25 F 0 1004 1.0
## 26 F 0 1005 0.1
## 27 F 0 1004 1.0
## 28 F 0 1005 0.1
## 29 F 0 1004 1.0
## 30 F 0 1005 0.1
## 31 F 0 1004 1.0
## 32 F 0 1005 0.1
## 33 F 0 1004 1.0
## 34 F 0 1005 0.1
## 35 F 0 1004 1.0
## 36 F 0 1005 0.1
## 37 F 0 1004 1.0
## 38 F 0 1005 0.1
## 39 F 0 1004 1.0
## 40 F 0 1005 0.1
## 41 F 0 1004 1.0
## 42 F 0 1005 0.1
## 43 F 0 1004 1.0
## 44 F 0 1005 0.1
## 45 F 0 1004 1.0
## 46 F 0 1005 0.1
## 47 F 0 1004 1.0
## 48 F 0 1005 0.1
## 49 F 0 1004 1.0
## 50 F 0 1005 0.1
## 51 F 0 1004 1.0
## 52 F 0 1005 0.1
## 53 F 0 1004 1.0
## 54 F 0 1005 0.1
## 55 F 0 1004 1.0
## 56 F 0 1005 0.1
## 57 F 0 1004 1.0
## 58 F 0 1005 0.1
## 59 F 0 1004 1.0
## 60 F 0 1005 0.1
## 61 F 0 1004 1.0
## 62 F 0 1005 0.1
## 63 F 0 1004 1.0
## 64 F 0 1005 0.1
## 65 F 0 1004 1.0
## 66 F 0 1005 0.1
# join taxa specific to country/species
c_sp = esc %>%
filter(match_type == 'c_sp') %>%
select(rgn_id, species, Esc_c_sp = Genetic.escapees)
mar_esc <- mar_esc %>%
left_join(c_sp, by= c("species", "rgn_id"))
summary(mar_esc)
## rgn_id species fao environment
## Min. : 5.0 Length:27001 Length:27001 Length:27001
## 1st Qu.: 51.0 Class :character Class :character Class :character
## Median :163.0 Mode :character Mode :character Mode :character
## Mean :130.3
## 3rd Qu.:205.0
## Max. :250.0
##
## year value Taxon_code gap_0_fill
## Min. :1950 Min. : 0 Length:27001 Length:27001
## 1st Qu.:1991 1st Qu.: 1 Class :character Class :character
## Median :2002 Median : 97 Mode :character Mode :character
## Mean :1998 Mean : 17348
## 3rd Qu.:2009 3rd Qu.: 1818
## Max. :2015 Max. :4573953
##
## species_code Esc_c_sp_fao Esc_c_sp
## Min. : 1.0 Min. :0.100 Min. :0.100
## 1st Qu.: 246.0 1st Qu.:0.100 1st Qu.:0.500
## Median : 537.0 Median :1.000 Median :1.000
## Mean : 536.2 Mean :0.605 Mean :0.739
## 3rd Qu.: 833.0 3rd Qu.:1.000 3rd Qu.:1.000
## Max. :1068.0 Max. :1.000 Max. :1.000
## NA's :26935 NA's :17148
### merge these into a single sustainability score
mar_esc = mar_esc %>%
mutate(Escapees = ifelse(!is.na(Esc_c_sp_fao), Esc_c_sp_fao, Esc_c_sp)) %>%
select(-Esc_c_sp_fao, -Esc_c_sp)
Join the sustainability data that is gapfilled either at the species level (average of specific species/genera across regions) or at a higher course taxonomic levels and documents which data are gapfilled and how.
## Gapfilled at the species/genera level:
gf_species_esc <- filter(esc, gapfill != "actuals" & match_type == "species") %>%
select(species, gapfill, Esc_gf_sp = Genetic.escapees)
## check that there are no duplicated species_fao
gf_species_esc[duplicated(gf_species_esc$species), ]
## # A tibble: 0 x 3
## # ... with 3 variables: species <chr>, gapfill <chr>, Esc_gf_sp <dbl>
# Match gapfilling values by species
mar_esc_gf = mar_esc %>%
left_join(gf_species_esc, by = 'species')
# Gapfilled at the coarse taxon level:
gf_taxon_sus <- filter(esc, gapfill != "actuals" & match_type == "taxon") %>%
select(Taxon_code=taxon, Esc_gf_taxon = Genetic.escapees)
# Match gapfilling values by species
mar_esc_gf = mar_esc_gf %>%
left_join(gf_taxon_sus, by = c('Taxon_code'))
summary(mar_esc_gf)
## rgn_id species fao environment
## Min. : 5.0 Length:27001 Length:27001 Length:27001
## 1st Qu.: 51.0 Class :character Class :character Class :character
## Median :163.0 Mode :character Mode :character Mode :character
## Mean :130.3
## 3rd Qu.:205.0
## Max. :250.0
##
## year value Taxon_code gap_0_fill
## Min. :1950 Min. : 0 Length:27001 Length:27001
## 1st Qu.:1991 1st Qu.: 1 Class :character Class :character
## Median :2002 Median : 97 Mode :character Mode :character
## Mean :1998 Mean : 17348
## 3rd Qu.:2009 3rd Qu.: 1818
## Max. :2015 Max. :4573953
##
## species_code Escapees gapfill Esc_gf_sp
## Min. : 1.0 Min. :0.100 Length:27001 Min. :0.500
## 1st Qu.: 246.0 1st Qu.:0.500 Class :character 1st Qu.:0.500
## Median : 537.0 Median :1.000 Mode :character Median :0.625
## Mean : 536.2 Mean :0.738 Mean :0.678
## 3rd Qu.: 833.0 3rd Qu.:1.000 3rd Qu.:0.797
## Max. :1068.0 Max. :1.000 Max. :0.925
## NA's :17082 NA's :24732
## Esc_gf_taxon
## Min. :0.1000
## 1st Qu.:0.7423
## Median :0.7423
## Mean :0.7045
## 3rd Qu.:0.7664
## Max. :0.7664
##
table(mar_esc_gf$gapfill)
##
## genus_average
## 2269
#Obtain a sustainability score for each record, and a book-keeping column of whether it's actual or gap-filled
tonnes_esc = mar_esc_gf %>%
mutate(gapfill = ifelse(!is.na(Escapees), "none", gapfill)) %>%
mutate(Escapees = ifelse(is.na(Escapees), Esc_gf_sp, Escapees)) %>%
mutate(gapfill = ifelse(is.na(Escapees), "taxon_average", gapfill)) %>%
mutate(Escapees = ifelse(is.na(Escapees), Esc_gf_taxon, Escapees)) %>%
select(rgn_id, species, species_code, year, gapfill_escapees = gapfill, tonnes=value, Escapees)
summary(tonnes_esc)
## rgn_id species species_code year
## Min. : 5.0 Length:27001 Min. : 1.0 Min. :1950
## 1st Qu.: 51.0 Class :character 1st Qu.: 246.0 1st Qu.:1991
## Median :163.0 Mode :character Median : 537.0 Median :2002
## Mean :130.3 Mean : 536.2 Mean :1998
## 3rd Qu.:205.0 3rd Qu.: 833.0 3rd Qu.:2009
## Max. :250.0 Max. :1068.0 Max. :2015
## gapfill_escapees tonnes Escapees
## Length:27001 Min. : 0 Min. :0.1000
## Class :character 1st Qu.: 1 1st Qu.:0.5807
## Mode :character Median : 97 Median :0.7664
## Mean : 17348 Mean :0.7093
## 3rd Qu.: 1818 3rd Qu.:0.9000
## Max. :4573953 Max. :1.0000
Final formatting of the escapee data. This is used as a pressure layer.
# for each region/year: average the genetic escape probability for each taxa based on tonnes mariculture
genEscapes <- tonnes_esc %>%
group_by(rgn_id, year) %>%
summarize(genEscapes = weighted.mean(Escapees, tonnes, na.rm=TRUE))
# obtain corresponding gapfilling information for each region (average of gapfilled data, weighted by tonnes of mariculture).
genEscapes_gf <- tonnes_esc %>%
mutate(gapfill = ifelse(gapfill_escapees=="none", 1, 0)) %>%
group_by(rgn_id, year) %>%
summarize(genEscapes = weighted.mean(gapfill, tonnes, na.rm=TRUE)) %>%
ungroup() %>%
filter(year==2015) %>%
select(rgn_id, pressures.score=genEscapes) %>%
mutate(pressures.score=ifelse(pressures.score=="NaN", NA, pressures.score)) %>%
data.frame()
write.csv(genEscapes_gf, 'output/GenEsc_gf.csv', row.names=FALSE)
# create the escapee data layers:
data <- genEscapes %>%
select(rgn_id, year, pressure_score = genEscapes)
write.csv(data, 'output/GenEsc.csv', row.names=FALSE)
old <- read.csv("../v2016/output/GenEsc_v2016.csv") %>%
select(rgn_id, prs_score_old=pressure_score)
new <- read.csv("../v2017/output/GenEsc.csv") %>%
filter(year == 2014)
full_join(old, new, by="rgn_id")
## rgn_id prs_score_old year pressure_score
## 1 5 0.7964807 2014 0.7964807
## 2 6 0.7971429 2014 0.7971429
## 3 7 NA 2014 NA
## 4 8 0.7514532 2014 0.7604475
## 5 9 NA 2014 NA
## 6 10 0.7663669 2014 0.7663669
## 7 13 0.6735327 2014 0.6691120
## 8 14 0.7241200 2014 0.7241206
## 9 15 0.9411440 2014 0.9411440
## 10 16 0.3838975 2014 0.3838975
## 11 17 0.5582235 2014 0.5582235
## 12 18 0.5806985 2014 0.5806985
## 13 19 0.7663669 2014 0.7663669
## 14 20 0.3069893 2014 0.3069893
## 15 21 0.5008329 2014 0.5011867
## 16 24 0.6074649 2014 0.6074649
## 17 25 0.3925215 2014 0.3739447
## 18 29 0.7663669 2014 0.7663669
## 19 31 NA 2014 NA
## 20 32 0.7663669 2014 0.7663669
## 21 37 0.7657989 2014 0.7658158
## 22 40 0.9990298 2014 0.9990298
## 23 41 0.7547626 2014 0.7663669
## 24 42 0.9993118 2014 0.9993118
## 25 43 NA 2014 NA
## 26 45 NA 2014 NA
## 27 47 NA 2014 NA
## 28 48 0.5806985 2014 0.5806985
## 29 50 0.6230114 2014 0.6230114
## 30 51 0.7663669 2014 0.7663669
## 31 52 0.7797302 2014 0.7797302
## 32 53 0.5806985 2014 0.5806985
## 33 54 0.6648295 2014 0.6648295
## 34 61 0.7660007 2014 0.7660007
## 35 62 0.4204691 2014 0.4204691
## 36 65 0.7423177 2014 0.7423177
## 37 66 0.7090517 2014 0.7109449
## 38 67 NA 2014 NA
## 39 68 0.7663669 2014 0.7663669
## 40 70 NA 2014 NA
## 41 71 0.7423177 2014 0.7423177
## 42 72 0.7423177 2014 0.7423177
## 43 73 0.2176174 2014 0.2283597
## 44 75 0.1488866 2014 0.1488866
## 45 76 0.7779444 2014 0.7779444
## 46 78 0.5806985 2014 0.5806985
## 47 79 0.7663669 2014 0.7663669
## 48 80 0.9517867 2014 0.9517867
## 49 81 0.7654591 2014 0.7654591
## 50 82 0.7491413 2014 0.7491413
## 51 84 0.7655622 2014 0.7655622
## 52 95 NA 2014 NA
## 53 101 0.1221808 2014 0.1187643
## 54 102 0.5719148 2014 0.5719148
## 55 110 NA 2014 NA
## 56 111 0.7423177 2014 0.7423177
## 57 112 0.6239894 2014 0.6149838
## 58 115 0.6619284 2014 0.6619284
## 59 116 NA 2014 NA
## 60 129 0.9661499 2014 0.9661499
## 61 130 0.9054489 2014 0.9798884
## 62 131 1.0000000 2014 1.0000000
## 63 132 0.9883649 2014 0.9883649
## 64 133 0.5806985 2014 0.5806985
## 65 134 0.5842325 2014 0.5842325
## 66 135 0.9435785 2014 0.9435785
## 67 136 0.5806985 2014 0.5806985
## 68 137 1.0000000 2014 1.0000000
## 69 138 0.6762505 2014 0.6762505
## 70 139 0.1000354 2014 0.1000354
## 71 140 0.7663669 2014 0.7663669
## 72 141 1.0000000 2014 1.0000000
## 73 143 0.5387474 2014 0.5387474
## 74 147 0.7446706 2014 0.7446706
## 75 152 NA 2014 NA
## 76 153 NA 2014 0.7423177
## 77 155 0.7423177 2014 0.7423177
## 78 162 0.5056614 2014 0.5058548
## 79 163 0.5479550 2014 0.5479550
## 80 164 0.1000000 2014 0.1000000
## 81 166 NA 2014 NA
## 82 167 0.6527165 2014 0.6527165
## 83 168 0.5806985 2014 0.5806985
## 84 171 0.2615382 2014 0.2614700
## 85 172 0.5458015 2014 0.5458015
## 86 173 NA 2014 NA
## 87 174 0.7663669 2014 0.7663669
## 88 175 0.7903328 2014 0.7903328
## 89 176 0.9857486 2014 0.9857486
## 90 177 0.9790048 2014 0.9744183
## 91 179 0.5502637 2014 0.5499130
## 92 180 0.9915456 2014 0.9908737
## 93 181 0.7350241 2014 0.7350241
## 94 182 0.7751808 2014 0.7751800
## 95 183 0.8981931 2014 0.8981930
## 96 184 0.8127234 2014 0.8261301
## 97 186 0.7499655 2014 0.7499655
## 98 187 0.7644352 2014 0.7644352
## 99 188 0.7459432 2014 0.7455204
## 100 190 NA 2014 NA
## 101 191 0.5806985 2014 0.5806985
## 102 196 NA 2014 NA
## 103 202 0.6474867 2014 0.6476013
## 104 203 0.6767328 2014 0.6767328
## 105 204 0.6782781 2014 0.6782781
## 106 205 0.8498617 2014 0.8498617
## 107 206 0.7785543 2014 0.7790076
## 108 207 0.4795483 2014 0.5009622
## 109 208 0.7126076 2014 0.7128166
## 110 209 0.7106795 2014 0.7106828
## 111 210 0.8357228 2014 0.8356385
## 112 212 1.0000000 2014 1.0000000
## 113 214 0.6960988 2014 0.6960988
## 114 216 0.8360407 2014 0.8360407
## 115 218 0.5145825 2014 0.4974722
## 116 219 0.7423177 2014 0.7423177
## 117 222 0.3488323 2014 0.3488323
## 118 223 0.9862647 2014 0.9876013
## 119 224 0.3137570 2014 0.3137570
## 120 231 0.7354222 2014 0.7354222
## 121 232 0.7619943 2014 0.7619943
## 122 244 NA 2014 NA
## 123 245 NA 2014 NA
## 124 247 0.7958587 2014 0.7958587
## 125 250 NA 2014 NA
tmp_old <- read.csv("../v2016/raw/Truj_label_sust.csv")
tmp_new <- read.csv("../v2017/raw/Truj_label_sust.csv")
test <- full_join(tmp_new, tmp_old, by=c("country", "species_fao", "fao", "environment" ))
## Warning: Column `species_fao` joining factors with different levels,
## coercing to character vector