Taxonomic groups from gmbi package used in bbnj analysis

suppressPackageStartupMessages({
  library(dplyr)
  library(treemap)
  library(ggplot2)
  library(kableExtra)
})
## filter spp dataset by groups number
filter_group <- function (df, groupnumber) {
    df %>%
    filter(!is.na(UQ(sym(groupnumber))))
}

## summarise by taxonomic group name

summarise_group <- function(df, groupnumber) {
  groupnumber<- as.symbol(groupnumber)
  groupnumber<- enquo(groupnumber)
  df %>% 
  group_by((!!groupnumber)) %>%
  summarize(n = n())
}
# Read in spp_bbnj.csv with groupings:
  # groups00: All original AquaMaps species 
  # groups01: 1st taxonomic grouping [n = 23]
  # groups02: 1st grouping, species (prob≥ 0.5) in high seas
  # groups03: 1st grouping, species (prob ≥ 0.5) and 25% of its range in high seas
  # groups04: 2nd taxonomic grouping [n = 9]
  # groups05: 2nd grouping, species (prob≥ 0.5) in high seas
  # groups06: 2nd grouping, species (prob ≥ 0.5) and 25% of its range in high seas

spp <- readr::read_csv("extdata/spp_bbnj.csv") 
groupnumber<-"groups01"

spp_grp<-filter_group(spp,groupnumber)
nspp_grp<-nrow(spp_grp)
taxa_grp <-summarise_group(spp_grp,groupnumber)
ngrp_grp <-nrow(taxa_grp)

Groups v01


#Create treemap where size of rectangle corresponds to number of species in each group

taxa_treemap<- treemap(taxa_grp,
                       index=groupnumber,
                       vSize="n",
                       type="index",
                       force.print.labels = TRUE,
                       title="Number of species per group"
)

#Create table of nspp for each taxonomic group
knitr::kable(taxa_grp,
             col.names = c("Group",
                           "Number of Species")) %>% 
  kable_styling(bootstrap_options = "striped")
Group Number of Species
Bivalves 1018
Bony fishes 11409
Cephalopods 295
Cetaceans 82
Chitons 81
Corals 918
Crustaceans 3058
Echinoderms 956
Euphausiids 43
Forams 16
Gastropods 2852
Hydrozoans 321
Jellyfish 19
Mangroves 1
Other 973
Pinnipeds 32
Reptiles 34
Sea spiders 332
Seagrasses 10
Sharks & rays 834
Sponges 440
Tunas & billfishes 63
Tunicates 666
Worms 451
groupnumber<-"groups02"

spp_grp<-filter_group(spp,groupnumber)
nspp_grp<-nrow(spp_grp)
taxa_grp <-summarise_group(spp_grp,groupnumber)
ngrp_grp <-nrow(taxa_grp)

Groups v02


#Create treemap where size of rectangle corresponds to number of species in each group

taxa_treemap<- treemap(taxa_grp,
                       index=groupnumber,
                       vSize="n",
                       type="index",
                       force.print.labels = TRUE,
                       title="Number of species per group"
)

#Create table of nspp for each taxonomic group
knitr::kable(taxa_grp,
             col.names = c("Group",
                           "Number of Species")) %>% 
  kable_styling(bootstrap_options = "striped")
Group Number of Species
Bivalves 469
Bony fishes 5101
Cephalopods 155
Cetaceans 69
Chitons 19
Corals 435
Crustaceans 1913
Echinoderms 440
Euphausiids 35
Forams 6
Gastropods 962
Hydrozoans 260
Jellyfish 13
Other 546
Pinnipeds 25
Reptiles 20
Sea spiders 229
Seagrasses 3
Sharks & rays 396
Sponges 135
Tunas & billfishes 39
Tunicates 446
Worms 297
groupnumber<-"groups03"

spp_grp<-filter_group(spp,groupnumber)
nspp_grp<-nrow(spp_grp)
taxa_grp <-summarise_group(spp_grp,groupnumber)
ngrp_grp <-nrow(taxa_grp)

Groups v03


#Create treemap where size of rectangle corresponds to number of species in each group

taxa_treemap<- treemap(taxa_grp,
                       index=groupnumber,
                       vSize="n",
                       type="index",
                       force.print.labels = TRUE,
                       title="Number of species per group"
)

#Create table of nspp for each taxonomic group
knitr::kable(taxa_grp,
             col.names = c("Group",
                           "Number of Species")) %>% 
  kable_styling(bootstrap_options = "striped")
Group Number of Species
Bivalves 43
Bony fishes 1395
Cephalopods 42
Cetaceans 52
Chitons 2
Corals 12
Crustaceans 340
Echinoderms 61
Euphausiids 3
Forams 3
Gastropods 114
Hydrozoans 59
Jellyfish 3
Other 94
Pinnipeds 10
Reptiles 1
Sea spiders 128
Sharks & rays 52
Sponges 25
Tunas & billfishes 21
Tunicates 160
Worms 53
groupnumber<-"groups04"

spp_grp<-filter_group(spp,groupnumber)
nspp_grp<-nrow(spp_grp)
taxa_grp <-summarise_group(spp_grp,groupnumber)
ngrp_grp <-nrow(taxa_grp)

Groups v04


#Create treemap where size of rectangle corresponds to number of species in each group

taxa_treemap<- treemap(taxa_grp,
                       index=groupnumber,
                       vSize="n",
                       type="index",
                       force.print.labels = TRUE,
                       title="Number of species per group"
)

#Create table of nspp for each taxonomic group
knitr::kable(taxa_grp,
             col.names = c("Group",
                           "Number of Species")) %>% 
  kable_styling(bootstrap_options = "striped")
Group Number of Species
Bony fishes 11409
Cephalopods 295
Corals 918
Invertebrates 10550
Marine Mammals 119
Other 706
Seagrasses 10
Sharks & rays 834
Tunas & billfishes 63
groupnumber<-"groups05"

spp_grp<-filter_group(spp,groupnumber)
nspp_grp<-nrow(spp_grp)
taxa_grp <-summarise_group(spp_grp,groupnumber)
ngrp_grp <-nrow(taxa_grp)

Groups v05


#Create treemap where size of rectangle corresponds to number of species in each group

taxa_treemap<- treemap(taxa_grp,
                       index=groupnumber,
                       vSize="n",
                       type="index",
                       force.print.labels = TRUE,
                       title="Number of species per group"
)

#Create table of nspp for each taxonomic group
knitr::kable(taxa_grp,
             col.names = c("Group",
                           "Number of Species")) %>% 
  kable_styling(bootstrap_options = "striped")
Group Number of Species
Bony fishes 5101
Cephalopods 155
Corals 435
Invertebrates 5437
Marine Mammals 95
Other 352
Seagrasses 3
Sharks & rays 396
Tunas & billfishes 39
groupnumber<-"groups06"

spp_grp<-filter_group(spp,groupnumber)
nspp_grp<-nrow(spp_grp)
taxa_grp <-summarise_group(spp_grp,groupnumber)
ngrp_grp <-nrow(taxa_grp)

Groups v06


#Create treemap where size of rectangle corresponds to number of species in each group

taxa_treemap<- treemap(taxa_grp,
                       index=groupnumber,
                       vSize="n",
                       type="index",
                       force.print.labels = TRUE,
                       title="Number of species per group"
)

#Create table of nspp for each taxonomic group
knitr::kable(taxa_grp,
             col.names = c("Group",
                           "Number of Species")) %>% 
  kable_styling(bootstrap_options = "striped")
Group Number of Species
Bony fishes 1395
Cephalopods 42
Corals 12
Invertebrates 1037
Marine Mammals 62
Other 52
Sharks & rays 52
Tunas & billfishes 21