Denver Mites Preliminary Analysis

Author

Nathan Comai, John M. Mola

Show the code
df_all_bees <- read_csv("./2024-07-29-denver-bee-id-w-metadata.csv") %>% janitor::clean_names() %>% 
    filter(!is.na(genus), genus != "WASP")

df_mite_raw <- read_csv("./2024-07-26-denver-mite-data.csv") %>% janitor::clean_names()


df_landscape <- read_csv("./00a_clean_denver_landscape.csv") %>% janitor::clean_names()
Show the code
df_flt_mite <- df_mite_raw %>% 
  filter(!is.na(genus), genus != "WASP") %>% 
  dplyr::select(x1, mites_approximate, mite_species)

df_join <- df_all_bees %>% full_join(., df_flt_mite, by = c("x1")) %>% 
  mutate(sex = if_else(sex == "M", "male", "female")) %>% 
  mutate(has_mite = if_else(mites_approximate > 0, 1, 0),
         date = as.Date(date, "%m/%d/%Y")) %>% 
  filter(!is.na(sex))

Mite approximate abundance

By family

Show the code
df_join %>% 
  ggplot(., aes(x = family, y = mites_approximate, color = family)) +
  geom_jitter(size = 2, alpha = 0.5)

By genus

Show the code
df_join %>% 
  ggplot(., aes(x = reorder(genus, -mites_approximate), y = mites_approximate)) +
  geom_jitter(size = 2, alpha = 0.5) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

by genus mean

Attmpt to take into account fact that some genera are just more common…however, this is still not satisfying, because having more opportunities to have >0 is present for any species with lots of specimens

Show the code
df_join %>% 
  group_by(genus) %>% 
  summarise(mean_mite_count = mean(mites_approximate)) %>% 
  ggplot(., aes(x = reorder(genus, -mean_mite_count), y = mean_mite_count)) +
  geom_jitter(size = 2, alpha = 0.5) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

By genus x sex

Only keeping genera with at least one mite

Show the code
df_join %>% 
  group_by(genus, sex) %>% 
  summarise(mean_mite_count = mean(mites_approximate)) %>% 
  filter(mean_mite_count > 0) %>% 
  ggplot(., aes(x = reorder(genus, -mean_mite_count), y = mean_mite_count, color = sex)) +
  geom_point(size = 2, alpha = 0.5) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Within Bombus

This is dumb though because it doesn’t consider minimum sample size (e.g. I think there are two pensylvanicus males and one has a mite)

Show the code
df_join %>% 
  filter(genus == "Bombus") %>% 
  ggplot(., aes(x = reorder(species, -mites_approximate), y = mites_approximate, fill = sex)) +
  geom_boxplot() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Mite proportional presence/absence

By family

Show the code
df_join %>% 
  group_by(family) %>% 
  summarise(with_mites = sum(has_mite), total_n = n()) %>% 
  mutate(prop_mite = with_mites/total_n) %>% 
  ggplot(., aes(x = family, y = prop_mite)) +
  geom_bar(stat = "identity", position = position_dodge2())

By genus

Show the code
df_join %>% 
  group_by(genus) %>% 
  summarise(with_mites = sum(has_mite), total_n = n()) %>% 
  mutate(prop_mite = with_mites/total_n) %>% 
  filter(prop_mite > 0) %>% 
  ggplot(., aes(x = reorder(genus, -prop_mite), y = prop_mite)) +
  geom_bar(stat = "identity", position = position_dodge2())

Show the code
df_join %>% 
  group_by(genus) %>% 
  summarise(with_mites = sum(has_mite), total_n = n()) %>% 
  mutate(prop_mite = with_mites/total_n) %>% 
  ggplot(., aes(x = total_n, y = prop_mite)) +
  geom_point() +
  geom_smooth(method = "lm")

By genus x sex

(The ones with missing bars for a sex are because that genus/sex combo has no mites)

Show the code
df_join %>% 
  group_by(genus, sex) %>% 
  summarise(with_mites = sum(has_mite), total_n = n()) %>% 
  mutate(prop_mite = with_mites/total_n) %>% 
  filter(prop_mite > 0) %>% 
  ggplot(., aes(x = reorder(genus, -prop_mite), y = prop_mite, fill = sex)) +
  geom_bar(stat = "identity", position = position_dodge2()) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Within Bombus

With more strict filters. At least 10 specimens for each species/sex.

Show the code
df_join %>% 
  filter(genus == "Bombus") %>% 
  group_by(species, sex) %>% 
  filter(n() > 10) %>% 
  mutate(has_mite = if_else(mites_approximate > 0, 1, 0)) %>% 
  summarise(with_mites = sum(has_mite), total_n = n()) %>% 
  #doesn't have enough males, so filter pensylvanicus out
  filter(species != "pensylvanicus") %>% 
  mutate(prop_mite = with_mites/total_n) %>% 
  ggplot(., aes(x = species, y = prop_mite, fill = sex)) +
  geom_bar(stat = "identity", position = position_dodge2())

Mite presence/absence spatial patterns

Proportion impervious surface in 500m

Show the code
df_impervious <- df_landscape %>% 
  dplyr::select(park_name, imp_surface_prop_500)

df_join %>% 
  group_by(park_name, date) %>%
  summarise(with_mites = sum(has_mite), total_n = n()) %>% 
  mutate(prop_mites = with_mites/total_n) %>% 
  full_join(., df_impervious, by = c("park_name")) %>% 
  ggplot(., aes(x = imp_surface_prop_500, y = prop_mites)) +
  geom_point() +
  geom_smooth(method = "lm")

Mite presence/absence by date

Show the code
df_join %>% 
  ggplot(., aes(x = date, y = has_mite, color = sex)) +
  geom_point(alpha = 0.5, size = 2) +
  stat_smooth(method="glm", se=FALSE, method.args = list(family=binomial)) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  theme_classic()

Mite presence/absence by date; Bombus only

Only Bombus with at least 10 specimens for sex/species.

Show the code
df_join %>% 
  filter(genus == "Bombus") %>% 
  group_by(species, sex) %>% 
  filter(n() > 10) %>% 
  ungroup() %>% 
  ggplot(., aes(x = date, y = has_mite, color = sex)) +
  geom_point(alpha = 0.5, size = 2) +
  stat_smooth(method="glm", se=FALSE, method.args = list(family=binomial)) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  theme_classic()