knitr::opts_chunk$set(echo = FALSE)
library(drake)
library(dplyr)
library(ggplot2)

all_di <- read.csv(here::here("analysis", "reports", "all_di.csv"), stringsAsFactors = F)

all_di <- all_di %>%
  mutate(log_nparts = log(gmp:::as.double.bigz(nparts)),
         log_nsamples = log(nsamples),
         log_s0 = log(s0),
         log_n0 = log(n0)) %>%
  filter(n0 != s0,
         s0 != 1,
         !singletons,
         n0 != (s0 + 1)) %>%
  mutate(dat = ifelse(grepl(dat, pattern = "fia"), "fia", dat),
         dat = ifelse(dat == "misc_abund_short", "misc_abund", dat)) %>%
  mutate(Dataset = dat,
         Dataset = ifelse(Dataset == "fia", "FIA", Dataset),
         Dataset = ifelse(Dataset == "bbs", "Breeding Bird Survey", Dataset),
         Dataset = ifelse(Dataset == "mcdb", "Mammal Communities", Dataset),
         Dataset = ifelse(Dataset == "gentry", "Gentry", Dataset),
         Dataset = ifelse(Dataset == "misc_abund", "Misc. Abundance", Dataset))

Figure S4

s4_fig1 <- ggplot(all_di, aes(x = s0, y = n0, color = Dataset)) +
  geom_point(alpha = .1) +
  geom_point(data = filter(all_di, log_nparts > log(50)), alpha = .4) +
  theme_bw() +
  scale_color_viridis_d(end = .9) +
  ggtitle("Communities by S and N") +
  xlab("Species richness (S); note log scale") +
  ylab("Total abundance (N); note log scale") +
  scale_x_log10() +
  scale_y_log10()


plot(s4_fig1)
# ggplot(all_di, aes(x = log_s0, y = log_n0, color = Dataset)) +
#   geom_point(alpha = .05) +
#   geom_point(data = filter(all_di, log_nparts > log(50)), alpha = .4) +
#   theme_bw() +
#   scale_color_viridis_d(end = .9) +
#   ggtitle("Communities by S and N") +
#   facet_wrap(vars(Dataset), scales = "free") +
#   theme(legend.position = "bottom")
# # geom_vline(xintercept = log(40)) +
# # geom_hline(yintercept = log(1000))

pdf("figure_s4.pdf", bg = "white")
plot(s4_fig1)
dev.off()

Legend. Distribution of communities from each dataset in termof total abundance (N) and species richness (S). Communities range from few species and individuals (lower left corner) to speciose communities with many individuals (upper right). However, datasets are not evenly distributed across this state space due to differences in their sampling intensity, design, and underlying biology (e.g. productivity, regional richness, taxonomic group, or other factors that influence the capacity of a community to support large numbers of species and individuals).



diazrenata/scadsanalysis documentation built on May 14, 2021, 6:59 p.m.