This code calculates the taxonomic coverage of the SCAR Antarctic Terrestrial Biodiversity Database. Taxonomic coverage is assessed by first assigning taxa to expert-defined functional groups (Priority Threat Management Groups, or ‘PTMs’; Lee et al. 2022), then grouping functional groups into ‘priority’ groups for modelling. These priority groups are also expert-defined (Lee et al. 2022) and separate out groups that are (1) at risk, and (2) have a poorly known geographic distribution. Finally, we count the number of records available per group as a proxy to assess whether that group could be modelled.
Load packages and set working directory.
library(tidyverse)
packages <- c("here", "gridExtra")
walk(packages, require, character.only = T)
here::here()
Read in the cleaned biodiversity database (cleaned in file “Terrestrial_Antarctic_Biodiversity_Database_Cleaning.Rmd”).
# Load biodiversity data as dataframe
Ant_biodf <- read.csv(here("Data/Ant_Terr_Bio_Data_Uncertainty_Terms_Removed_August_2023.csv"))
# dynamicProperties indicates whether a species is vagrant
PTM_count <- count(Ant_biodf, PTM_ID, PTM_NAME, scientificNameClean, dynamicProperties)
# Make sure there's no white space
Ant_biodf$PTM_NAME <- str_trim(Ant_biodf$PTM_NAME)
# Remove vagrant species or vagrant records of a species
Ant_biodf <- Ant_biodf %>%
filter(dynamicProperties != "Vagrant species")
# Remove those records that weren't able to be grouped into a PTM (PTM ID = ?)
# Now separate out PTM IDs into four columns, as some records have up to four PTMs that they are listed under
Ant_biodf_PTM <- Ant_biodf %>%
filter(PTM_ID != "?") %>%
separate(PTM_ID, into = c("PTM_1", "PTM_2", "PTM_3", "PTM_4"), sep = "&") %>%
.[, 30:33]
# Now count the total number of records per PTM across all columns
Ant_biodf_PTM_count <- data.frame(table(unlist(Ant_biodf_PTM[c("PTM_1", "PTM_2", "PTM_3", "PTM_4")])))
# Rename
colnames(Ant_biodf_PTM_count) <- c("PTM_ID", "Freq")
# Setting PTM IDs as numeric
Ant_biodf_PTM_count$PTM_ID <- as.numeric(levels(Ant_biodf_PTM_count$PTM_ID))[Ant_biodf_PTM_count$PTM_ID]
# Summing all records per PTM as some were split across rows
Ant_biodf_PTM_final <- Ant_biodf_PTM_count %>% dplyr::group_by(PTM_ID) %>%
dplyr::summarize(Freq = sum(Freq))
Load a .csv file with the two priority grouping variables (‘intactness’ and ‘wallacean’ - whether the group has a wallacean shortfall, i.e. their distribution is poorly known) assigned to each PTM.
# Load priority groupings
PTM_priority <- read.csv(here("Data/PTM_rankings.csv"))
PTM_priority$PTM_ID <- as.character(PTM_priority$PTM_ID)
Ant_biodf_PTM_final$PTM_ID <- as.character(Ant_biodf_PTM_final$PTM_ID)
# Match functional groups with their priority status
freq_intactness_wallacean <- full_join(Ant_biodf_PTM_final, PTM_priority, by = "PTM_ID")
# Assign NAs as Not assessed
freq_intactness_wallacean$intactness[is.na(freq_intactness_wallacean$intactness)] <- "Not assessed"
freq_intactness_wallacean$wallacean[is.na(freq_intactness_wallacean$wallacean)] <- "Not assessed"
# Remove a small number of vagrant and non-terrestrial species
freq_intactness_wallacean <- freq_intactness_wallacean %>%
filter(name != "vagrants") %>%
filter(name != "Vagrants") %>%
filter(name != "Invasive") %>%
filter(name != "Sea spiders") %>%
filter(name != "Marine algae") %>%
filter(name != "Marine invertebrates") %>%
filter(name != "Marine plankton") %>%
filter(name != "Marine invertebrates") %>%
filter(name != "Marine algae")
# Assign groups to frequency levels
freq_intactness_wallacean <- freq_intactness_wallacean %>%
mutate(type = ifelse(Freq < 100, "< 100", "")) %>%
mutate(type = ifelse(Freq > 100 & Freq < 500, "> 100 to 500", type)) %>%
mutate(type = ifelse(Freq > 500 & Freq < 1000, "> 500 to 1000", type)) %>%
mutate(type = ifelse(Freq > 1000, "> 1000", type))
# Relabel priority groups for plotting
freq_intactness_wallacean <- freq_intactness_wallacean %>%
mutate(Priority = if_else(intactness == "Decline" & wallacean == 1, "Both",
if_else(intactness == "Decline", "At risk",
if_else(wallacean == 1, "Distribution poorly known",
if_else(intactness == "Not assessed", "Not assessed", "Neither")))))
freq_intactness_wallacean %>%
arrange(desc(Freq)) %>%
.[1:15, c("PTM_ID", "Freq", "name", "Priority")] %>%
grid.table()
freq_intactness_wallacean %>%
count(Priority, type) %>%
grid.table()
# Reorder factor for plotting
freq_intactness_wallacean$Priority <- factor(freq_intactness_wallacean$Priority,
levels = c("Distribution poorly known",
"At risk",
"Both",
"Neither",
"Not assessed"))
PTM_priority_plot<- freq_intactness_wallacean %>%
arrange(-desc(Freq)) %>%
mutate(name = factor(name, name)) %>%
ggplot() +
geom_bar(stat = "identity", aes(fill = Priority), position = "dodge", width = 0.5)+
aes(x = name, y = Freq,label = Freq) +
scale_y_continuous(expand = c(0,0), limits = c(0, 5200), position = "right")+
labs(x = "Functional group", y = "Number of records", fill = "Priority grouping") +
scale_fill_manual(values = c("#E69F00","#56B4E9","#CC3399", "mediumpurple4", "gray70"))+
geom_hline(yintercept = 100, linetype = "dashed", linewidth = 0.8) +
geom_hline(yintercept = 500, linetype = "dashed", linewidth = 0.8) +
theme_classic()+
coord_flip()+
theme(axis.text.y=element_text(size = 8.5),
axis.text.x=element_text(size = 10),
axis.ticks.x=element_blank(),
axis.title.x=element_text(size = 16, vjust = -0.5),
axis.title.y = element_text(size=16, vjust = 0.8),
legend.text = element_text(size=14),
legend.title = element_text(size=14),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
strip.text = element_text(size = 11.75),
legend.position = c(.7, .35),
legend.box.background = element_rect(colour = "black",
linewidth = 0.7)) +
annotate("text", x = 9, y = 200, label = "100 records", angle = '270') +
annotate("text", x = 8.9, y = 600, label = "500 records", angle = '270')
PTM_priority_plot
# ggsave(plot = PTM_priority_plot, filename = here("Outputs/PTM_priority_plot.jpg"), w = 20, h = 23, units = "cm", dpi = 800, device = "jpeg" )
Lee, J.R., Terauds, A., Carwardine, J., Shaw, J.D., Fuller, R.A., Possingham, H.P., Chown, S.L., Convey, P., Gilbert, N., Hughes, K.A., McIvor, E., Robinson, S.A., Ropert-Coudert, Y., Bergstrom, D.M., Biersma, E.M., Christian, C., Cowan, D.A., Frenot, Y., Jenouvrier, S., Kelley, L., Lee, M.J., Lynch, H.J., Njåstad, B., Quesada, A., Roura, R.M., Shaw, E.A., Stanwell-Smith, D., Tsujimoto, M., Wall, D.H., Wilmotte, A., Chadès, I., 2022a. Threat management priorities for conserving Antarctic biodiversity. PLOS Biology 20, e3001921.
sessionInfo()
## R version 4.2.3 (2023-03-15 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19045)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8
## [3] LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C
## [5] LC_TIME=English_Australia.utf8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] gridExtra_2.3 here_1.0.1 lubridate_1.9.2 forcats_1.0.0
## [5] stringr_1.5.0 dplyr_1.1.1 purrr_1.0.1 readr_2.1.4
## [9] tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.2 tidyverse_2.0.0
##
## loaded via a namespace (and not attached):
## [1] highr_0.10 bslib_0.4.2 compiler_4.2.3 pillar_1.9.0
## [5] jquerylib_0.1.4 tools_4.2.3 digest_0.6.31 timechange_0.2.0
## [9] jsonlite_1.8.4 evaluate_0.20 lifecycle_1.0.3 gtable_0.3.3
## [13] pkgconfig_2.0.3 rlang_1.1.0 cli_3.6.1 rstudioapi_0.14
## [17] yaml_2.3.7 xfun_0.38 fastmap_1.1.1 withr_2.5.0
## [21] knitr_1.42 hms_1.1.3 generics_0.1.3 sass_0.4.5
## [25] vctrs_0.6.1 rprojroot_2.0.3 grid_4.2.3 tidyselect_1.2.0
## [29] glue_1.6.2 R6_2.5.1 fansi_1.0.4 rmarkdown_2.21
## [33] farver_2.1.1 tzdb_0.3.0 magrittr_2.0.3 scales_1.2.1
## [37] htmltools_0.5.5 colorspace_2.1-0 labeling_0.4.2 utf8_1.2.3
## [41] stringi_1.7.12 munsell_0.5.0 cachem_1.0.7