knitr::opts_chunk$set(echo = FALSE)
library(mcmac)
library(dplyr)
library(ggplot2)
if(FALSE) {
  download_macdb(from_url = TRUE)
} else {
  download_macdb()
}

This is how many experiments are entered per taxon. This isn't unique papers.

experiments <- load_table("experiments_analysis_data")

experiments_summary <- experiments %>%
  group_by(taxa) %>%
  summarize(n_raw_abund = sum(raw_abundance),
            n_mean_abund = sum(mean_abundance)) %>%
  ungroup() %>%
  tidyr::gather(-taxa, key = "abundance_metric", value = "n_experiments")

exp_plot <- ggplot(data = experiments_summary, aes(x = taxa, y = n_experiments)) +
  geom_col() +
  facet_wrap(vars(abundance_metric)) +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1))

exp_plot

How many species are we looking at per taxon?

communities <- load_table("community_analysis_data")

species <- select(communities, siteID, family, genus, species, id2species) %>% 
  left_join(select(experiments, siteID, taxa), by = "siteID")

unique_species <- select(species, family, genus, species, id2species, taxa) %>%
  distinct()

ntaxa <- unique_species %>%
  group_by(taxa) %>%
  summarise(nspecies = dplyr::n()) %>%
  ungroup()

taxon_plot <- ggplot(data = ntaxa, aes(x = taxa, y = nspecies)) +
 geom_col() +
  geom_label(aes(x = taxa, y = nspecies + 25, label = nspecies)) +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
  ylab("Number of species")

taxon_plot

Here is how many species are not id'd to species (0), id'd to species (1), or id'd to a pair of morphospeices (2):

table(select(distinct(select(unique_species, -taxa)), id2species))


diazrenata/mcmac documentation built on Nov. 20, 2019, 1:31 p.m.