order_bar2 <-
df_97 %>%
filter(!is.na(order) & habitat %in% c("Oak Woodland", "Scrub", "Grassland")) %>%
group_by(status, order) %>%
summarise(n = n_distinct(otu)) %>%
ungroup()
View(order_bar2)
order_bar2 <-
df_97 %>%
filter(!is.na(order) & habitat %in% c("Oak Woodland", "Scrub", "Grassland")) %>%
group_by(status, order) %>%
summarise(n = n_distinct(otu)) %>%
ungroup() %>%
arrange(status, desc(n)) %>%
mutate(order = factor(order, levels = unique(order))) %>%
mutate(status = ifelse(status == "Burn", "Burned", "Unburned")) %>%
rename(Order = order) %>%
ggplot(aes(x = status, y = n, fill = Order)) +
geom_bar(stat = "identity",  color = "black", alpha = 0.8) +
theme_minimal() +
#theme(axis.text.x = element_text(angle = 45)) +
scale_fill_manual(values = colors) +
ylab("Number of OTUs") +
xlab("")
order_bar2
df_97 %>% group_by(status) %>% summarise(n_distinct(otu))
nmds_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
#theme_minimal() +
theme_classic()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
#theme_minimal() +
theme_void()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
#theme_minimal() +
theme_linedraw()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
#theme_minimal() +
theme_bw()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
#theme_minimal() +
theme_classic2()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
#theme_minimal() +
theme_light()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
#theme_minimal() +
theme_minimal()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
#theme_minimal() +
theme_pubclean()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
#theme_minimal() +
theme_light()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
#theme_minimal() +
theme_light()
grass_2021
oak_2021 <-
oak_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.4) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
#theme_minimal() +
theme_light()
scrub_2021 <-
scrub_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.4) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
#theme_minimal() +
theme_light()
nmds_2021 <- ggpubr::ggarrange(grass_2021,
oak_2021,
scrub_2021,
ncol = 3, nrow = 1,
common.legend = TRUE)
nmds_2021
oak_2021 <-
oak_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.4) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_minimal()
scrub_2021 <-
scrub_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.4) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_minimal()
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_minimal()
nmds_2021 <- ggpubr::ggarrange(grass_2021,
oak_2021,
scrub_2021,
ncol = 3, nrow = 1,
common.legend = TRUE)
nmds_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_cleveland()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_grey()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_transparent()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_void()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_classic()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_light()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_minimal()
grass_2021
grass_2021 <-
grass_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
# geom_text(aes(label = sample_name), size = 1) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.5) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_light()
scrub_2021 <-
scrub_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.4) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_light()
oak_2021 <-
oak_df %>%
ggplot(aes(x = MDS1, y = MDS2, color = status)) +
geom_point(aes(shape = status), size = 2) +
stat_ellipse(aes(lty = status), alpha = 0.4) +
scale_color_manual(values = fire_color) +
xlab("") +
ylab("") +
theme_light()
nmds_2021 <- ggpubr::ggarrange(grass_2021,
oak_2021,
scrub_2021,
ncol = 3, nrow = 1,
common.legend = TRUE)
nmds_2021
knitr::opts_chunk$set(echo = TRUE)
# Change to home directory
knitr::opts_knit$set(root.dir = "/Users/aholmquist/Documents/GitHub/edna-fire/")
knitr::opts_chunk$set(echo = TRUE)
# Change to home directory
knitr::opts_knit$set(root.dir = "/Documents/GitHub/edna-fire/")
library(tidyverse)
library(reshape2)
library(ape)
library(vegan)
library(BAT)
library(venn)
library(ggpubr)
library(knitr)
library(kableExtra)
# Produced from cleanup script
df_97 <- read.csv("data/mco_97_wsites.csv")
getwd()
knitr::opts_chunk$set(echo = TRUE)
# Change to home directory
knitr::opts_knit$set(root.dir = "/Users/aholmquist/Documents/GitHub/edna-fire/")
# Produced from cleanup script
df_97 <- read.csv("data/mco_97_wsites.csv")
# Produced from cleanup script
df_97 <- read.csv("data/mco_97_wsites.csv")
sites <- read.csv("data/site_data.csv")
theme_minimal()
df_97 %>%
group_by(otu) %>%
filter(row_number() == 1) %>%
ungroup() %>%
ggplot(aes(x = percent)) +
geom_histogram() +
scale_fill_brewer(type = "qual", palette = 1)
df_97 %>%
group_by(otu) %>%
filter(row_number() == 1) %>%
ungroup() %>%
filter(!is.na(order)) %>%
ggplot(aes(x = order, y = percent)) +
geom_boxplot(aes(fill = order), alpha = 0.7) +
geom_jitter(alpha = 0.3) +
scale_fill_brewer(palette = "RdYlGn") +
theme_light() +
theme(axis.text.x = element_text(angle = 90))
order_bar
family_taxonomy_table <-
df_97 %>%
#filter(!is.na(family)) %>%
group_by(order, family, status) %>%
summarise(n = n_distinct(otu)) %>%
ungroup() %>%
pivot_wider(names_from = status, values_from = n, values_fill = 0)
family_taxonomy_table
x
p1
habitat_div
alpha_bar1
x3
beta_dist_plot
year_box
hab_beta
beta_all %>%
filter(habitat.x == habitat.y,
reserve.x == reserve.y) %>%
mutate(comparison = case_when(
status.x == status.y & status.x == "Unburn" ~ "Unburned",
status.x == status.y & status.x == "Burn" ~ "Burned",
TRUE ~ "Between")) %>%
#filter(beta_type == "total") %>%
filter(distance < 6000) %>%
ggplot(aes(distance, value)) +
geom_point(aes(color = beta_type)) +
geom_smooth(aes(color = beta_type), method = "lm", alpha = 0.1) +
facet_grid(comparison~habitat.x) +
theme_minimal()
beta_all %>%
filter(habitat.x == habitat.y,
reserve.x == reserve.y) %>%
mutate(comparison = case_when(
status.x == status.y & status.x == "Unburn" ~ "Unburned",
status.x == status.y & status.x == "Burn" ~ "Burned",
TRUE ~ "Between")) %>%
#filter(beta_type == "total") %>%
filter(distance < 6000) %>%
ggplot(aes(distance, value)) +
geom_point(aes(color = beta_type)) +
geom_smooth(aes(color = beta_type), method = "lm", alpha = 0.1) +
facet_grid(comparison~habitat.x) +
theme_minimal()
beta_reserve_diff
order_bar
knitr::opts_chunk$set(echo = TRUE)
# Change to home directory
# knitr::opts_knit$set(root.dir = "")
order_bar <-
df_97 %>%
filter(!is.na(order)) %>%
group_by(year, order, status) %>%
summarise(n = n_distinct(otu)) %>%
ungroup() %>%
arrange(year, desc(n)) %>%
mutate(order = factor(order, levels = unique(order))) %>%
mutate(year = ifelse(year == "pan2020", "Fall 2020", "Spring 2021")) %>%
mutate(status = ifelse(status == "Burn", "Burned", "Unburned")) %>%
rename(Order = order) %>%
ggplot(aes(x = year, y = n, fill = Order)) +
geom_bar(stat = "identity",  color = "black", alpha = 0.8) +
facet_grid(~status) +
theme_minimal() +
#theme(axis.text.x = element_text(angle = 45)) +
scale_fill_manual(values = colors) +
ylab("Number of OTUs") +
xlab("")
order_bar
ggsave("figures/figure2_family_bar.png", width = 6, height = 4, units = "in", bg = "white")
table
save_kable(table, "supplementary_taxonomy.png")
save_kable(table, "figures/supplementary_taxonomy.png")
habitat_div <-
diversity_shannon %>%
filter(!is.na(habitat)) %>%
mutate(year = ifelse(year == "pan2020", "Fall 2020", "Spring 2021")) %>%
ggplot(aes(year, div)) +
geom_boxplot(aes(fill = habitat), color = "black", alpha = 0.8, width = 0.5) +
geom_jitter(alpha = 0.4) +
stat_summary(aes(group = habitat),
fun = median,
geom = "line",
alpha = 0.7,
linewidth = 0.7) +
facet_grid(habitat ~ status, as.table = TRUE) +
scale_fill_manual(values = habitat) +
theme_classic() +
ylab("Shannon Diversity") +
xlab("") +
theme(axis.text.x = element_text(angle = 45,
size = 8,
margin = margin(t = 14)),
legend.position = "none")
ggsave("richness_habitat.png", width = 4, height = 5, units = "in", bg = "white")
ggsave("figures/figure3_richness_habitat.png", width = 4, height = 5, units = "in", bg = "white")
ggarrange(nmds_euc, nmds_year_p)
ggsave("nmds_season.png", width = 7, height = 5, units = "in", bg = "white")
ggsave("figures/figure4_nmds_season.png", width = 7, height = 5, units = "in", bg = "white")
ggsave("figures/figure4_nmds_season.png", width = 8, height = 5, units = "in", bg = "white")
ggsave("figures/figure4_nmds_season.png", width = 10, height = 5, units = "in", bg = "white")
beta_dist_plot <-
within %>%
#filter(beta_type != "total") %>%
filter(comparison == "Between") %>%
filter(distance < 6000) %>%
mutate(year.x = ifelse(year.x == "pan2020", "Fall", "Spring")) %>%
ggplot(aes(distance, value)) +
geom_point(aes(color = year.x, shape = beta_type, size = beta_type),
alpha = 0.5) +
geom_smooth(aes(lty = beta_type, color = year.x), method = "lm",
alpha = 0.1)  +
facet_grid(~year.x) +
xlab("Distance (km)") +
ylab("Beta Diversity") +
labs(color = "Season",
shape = "Beta Components",
lty = "Beta Components",
size = "Beta Components") +
#scale_shape_manual(values = c(7, 8)) +
scale_color_manual(values = c("#a384b3", "#41244f")) +
scale_size_manual(values = c(2, 2.5, 1.5),
labels = c("lossgain" = "Richness differences",
"replacement" = "Species replacement",
"total" = "Total beta diversity")) +
scale_linetype_manual(values = c("dotted", "longdash", "solid"),
labels = c("lossgain" = "Richness differences",
"replacement" = "Species replacement",
"total" = "Total beta diversity")) +
scale_shape_manual(values = c(16, 17, 18),
labels = c("lossgain" = "Richness differences",
"replacement" = "Species replacement",
"total" = "Total beta diversity")) +
#(~comparison) +
theme_minimal()
ggsave("figures/figure5_beta_dist.png", width = 7, height = 4.5, units = "in", bg = "white")
grass_nmds
nmds_2021
all_nmds <- ggpubr::ggarrange(grass_2020, grass_2021,
oak_2020, oak_2021,
scrub_2020, scrub_2021,
ncol = 2, nrow = 3,
common.legend = TRUE)
all_nmds
ggsave("figures/figure6_nmds", width = 7, height = 4, units = "in", bg = "white")
ggsave("figures/figure6_nmds.png", width = 7, height = 4, units = "in", bg = "white")
ggsave("figures/figure6_nmds.png", width = 7, height = 6, units = "in", bg = "white")
hab_beta <-
beta_narrowed %>%
#filter(comparison == "Between") %>%
filter(year.x == "pan2021") %>%
ggplot(aes(comparison, value)) +
geom_boxplot(aes(fill = habitat.x), alpha = 0.8) +
geom_jitter(aes(shape = comparison), alpha = 0.3) +
facet_grid(~habitat.x) +
scale_color_manual(values = fire_color) +
scale_fill_manual(values = habitat) +
labs(fill = "Habitat",
shape = "Burn Status") +
xlab("") +
ylab("Beta Diversity") +
theme_minimal() +
theme(axis.text.x = element_text(size = 8, angle = 45),
legend.key.size = unit(0.75, "lines"),
legend.text = element_text(size = 6))
ggsave("figures/figure7_hab_beta.png", width = 7, height = 4, units = "in", bg = "white")
