Coral cover data

Wide format

Explore

Pocillopora

  • Pocillopora % cover (basic stats)
# Pocillopora mean, median, 

Pocillopora_plot <- ggplot(cover, aes(x=YR, y=Pocillopora)) +
  geom_boxplot(aes(group=YR), outlier.shape = NA) +
  stat_boxplot(aes(group=YR), geom = 'errorbar')+
  #geom_smooth(method = lm, se=FALSE, linetype = "dashed", colour="red")+
  #geom_smooth(span = 0.2, se=T, colour="darkgray")+ 
  stat_summary(fun.y=mean, geom="line") +
  
  #geom_point(aes(colour=Thermal_regime), alpha=0.5) + ylim(0,79) +
  scale_y_continuous("Pocillopora cover (%)", limits = c(-2, 101), breaks = seq(0, 100, by=20), expand = c(0,0))+
  #geom_line(aes(colour=Transect))+
  scale_x_continuous("", limits = c(1979, 2019),
                     breaks = seq(1980, 2018, by=2), expand = c(0,0))+
  #scale_color_manual(values=my_colours) + labs(title="b")+
  #annotate("text", x = 1983, y = 70, label = "*", size=8)+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 80,  alpha = .2, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 80,  alpha = .2, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 80,  alpha = .2, fill="red")
Pocillopora_plot+facet_grid(DataSet~.)

  • Pocillopora individual transects (all data)
#Pocillopora cover (raw data =  check transects)

Pocillopora_raw <- ggplot(cover, aes(x=YR, y=Pocillopora)) +
  stat_summary(fun.y=mean, geom="line", size=2 ) +
  scale_y_continuous("Pocillopora cover (%)", breaks = seq(0, 100, by=20), expand = c(0.02,0.02))+
  geom_line(aes(colour=Transect))+
  geom_point(aes(colour=Transect))+
  scale_x_continuous("", limits = c(1979, 2019),
                     breaks = seq(1980, 2018, by=2), expand = c(0,0))+
  #scale_color_manual(values=my_colours) + labs(title="b")+
  #annotate("text", x = 1983, y = 70, label = "*", size=8)+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 80,  alpha = .2, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 80,  alpha = .2, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 80,  alpha = .2, fill="red")
Pocillopora_raw+facet_grid(DataSet~., scales = "free_y")

  • Pocillopora 1m2 data
Pocillopora_raw_1m2 <- ggplot(data=subset(cover, DataSet=="Uva_1m2"), aes(x=YR, y=Pocillopora)) +
  stat_summary(fun.y=mean, geom="line", size=2 ) +
  scale_y_continuous("Pocillopora cover (%)", breaks = seq(0, 100, by=20), expand = c(0.02,0.02))+
  geom_line(aes(colour=Transect))+
  geom_point(aes(colour=Transect, shape=Transect))+
  scale_x_continuous("", limits = c(1993, 2019),
                     breaks = seq(1993, 2018, by=2), expand = c(0,0))+
  theme(legend.position="bottom")+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 80,  alpha = .2, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 80,  alpha = .2, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 80,  alpha = .2, fill="red")
Pocillopora_raw_1m2

Pocillopora_raw_1m2+ scale_x_continuous("", limits = c(2010, 2019),
                     breaks = seq(1993, 2018, by=2), expand = c(0,0))

  • Pocillopora chain data
Pocillopora_raw_chains <- ggplot(data=subset(cover, DataSet=="UvRf-Chains"), aes(x=YR, y=Pocillopora)) +
  stat_summary(fun.y=mean, geom="line", size=2 ) +
  scale_y_continuous("Pocillopora cover (%)", breaks = seq(0, 100, by=20), expand = c(0.02,0.02))+
  geom_line(aes(colour=Transect))+
  geom_point(aes(colour=Transect, shape=Transect))+
  scale_x_continuous("", limits = c(1996, 2019),
                     breaks = seq(1980, 2018, by=2), expand = c(0,0))+
  theme(legend.position="bottom")+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 80,  alpha = .2, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 80,  alpha = .2, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 80,  alpha = .2, fill="red")
Pocillopora_raw_chains

Non-Pocillopora scleractinians

  • Coral cover (basic stats)
Other_plot <- ggplot(cover, aes(x=YR, y=Other)) +
  #geom_smooth(method = lm, se=FALSE, linetype = "dashed", colour="red")+
  #geom_smooth(span = 0.2, se=T, colour="darkgray")+ 
  geom_boxplot(aes(group=YR), outlier.shape = NA) +
  stat_boxplot(aes(group=YR), geom = 'errorbar')+
  stat_summary(fun.y=mean, geom="line") +
  
  #geom_point(aes(colour=Thermal_regime), alpha=0.5) + ylim(0,79) +
  scale_y_continuous("Other scleractinians cover (%)", breaks = seq(0, 15, by=5), expand = c(0,0))+
  scale_x_continuous("", limits = c(1979, 2019),
                     breaks = seq(1980, 2018, by=2), expand = c(0,0))+
  #scale_color_manual(values=my_colours) + labs(title="b")+
  #annotate("text", x = 1983, y = 70, label = "*", size=8)+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 14,  alpha = .2, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 14,  alpha = .2, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 14,  alpha = .2, fill="red")
Other_plot+facet_grid(DataSet~.)

  • Non-Pocillopora individual transects
#Pocillopora cover (raw data =  check transects)

Other_raw <- ggplot(cover, aes(x=YR, y=Other)) +
  stat_summary(fun.y=mean, geom="line", size=2 ) +
  geom_line(aes(colour=Transect))+
  geom_point(aes(colour=Transect))+
  
  scale_y_continuous("Other scleractinians cover (%)",
                     limits = c(0, 15), breaks = seq(0, 15, by=5), expand = c(0,0))+
  scale_x_continuous("", limits = c(1979, 2019),
                     breaks = seq(1980, 2018, by=2), expand = c(0,0))+
  #scale_color_manual(values=my_colours) + labs(title="b")+
  #annotate("text", x = 1983, y = 70, label = "*", size=8)+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 14,  alpha = .2, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 14,  alpha = .2, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 14,  alpha = .2, fill="red")
Other_raw+facet_grid(DataSet~., scales = "free_y")

  • Non-Pocillopora 1m2 data
Other_raw_1m2 <- ggplot(data=subset(cover, DataSet=="Uva_1m2"), aes(x=YR, y=Other)) +
  stat_summary(fun.y=mean, geom="line", size=2 ) +
  geom_line(aes(colour=Transect))+
  geom_point(aes(colour=Transect, shape=Transect), size=2)+
  
  scale_y_continuous("Other scleractinians cover (%)",
                     limits = c(0, 15), breaks = seq(0, 15, by=5), expand = c(0,0))+
  scale_x_continuous("", limits = c(1994, 2019),
                     breaks = seq(1994, 2018, by=2), expand = c(0,0))+
  #scale_color_manual(values=my_colours) + labs(title="b")+
  #annotate("text", x = 1983, y = 70, label = "*", size=8)+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 14,  alpha = .2, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 14,  alpha = .2, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 14,  alpha = .2, fill="red")
Other_raw_1m2+facet_grid(DataSet~., scales = "free_y")

Millepora

  • Millepora (individual transects)
Millepora.data<-subset(cover, DataSet !="4x5")
Millepora.data<-subset(Millepora.data, DataSet !="Canal de Afuera-Reef")

Millerpora_plot <- ggplot(Millepora.data, aes(x=YR, y=Millepora)) +
  geom_point(aes(colour=Transect, shape=Transect))+ 
  #geom_smooth(method = lm, se=FALSE, linetype = "dashed", colour="red")+
  #geom_smooth(span = 0.2, se=T, colour="darkgray")+ 
  
  #geom_boxplot(aes(group=YR), outlier.shape = NA) +
  #stat_boxplot(aes(group=YR), geom = 'errorbar')+
  geom_line(aes(colour=Transect))+
  geom_point(aes(colour=Transect, shape=Transect))+
  
  #geom_point(aes(colour=Thermal_regime), alpha=0.5) + ylim(0,79) +
  scale_y_continuous("Millepora cover (%)", expand = c(0.02,0.02))+
  scale_x_continuous("", limits = c(1979, 2019),
                     breaks = seq(1980, 2018, by=2), expand = c(0,0))+
  theme(legend.position="bottom")+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 4,  alpha = .2, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 4,  alpha = .2, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 4,  alpha = .2, fill="red")
Millerpora_plot+facet_grid(DataSet~., scales = "free_y")

Long format

Explore

  • All categories % cover (mean)
#Using raw data (Only thermal regime is significant in model)

Cover_plot <- ggplot(data=subset(cover_tall, DataSet !="Canal de Afuera-Reef"), aes(x=YR, y=Cover, colour=Category)) +
  stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2) +
  stat_summary(fun.y=mean, geom="point", size =2, alpha=0.5) +
  
  
  #geom_smooth(method = lm, se=FALSE, linetype = "dashed")+
  geom_smooth(span = 0.2, se=T)+ 
  scale_y_continuous("Cover (%)", limits = c(-2, 90), 
                     breaks = seq(0, 100, by=10), expand = c(0,0))+
  scale_x_continuous("", limits = c(1979, 2019),
                     breaks = seq(1980, 2018, by=2), expand = c(0,0))+
  
  theme(legend.position = c(0.1, 0.5))+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 90,  alpha = .1, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 90,  alpha = .1, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 90,  alpha = .1, fill="red")
Cover_plot+facet_grid(DataSet~.)

  • All categories log (% cover + 1)
#Using raw data (Only thermal regime is significant in model)

Cover_log <- ggplot(data=subset(cover_tall, DataSet !="Canal de Afuera-Reef"), aes(x=YR, y=log(1+Cover), 
      group=Category, colour=Category)) +
  stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2) +
  stat_summary(fun.y=mean, geom="point", size =2, alpha=0.8, shape=21) +
  
  
  #geom_smooth(method = lm, se=FALSE, linetype = "dashed")+
  geom_smooth(span = 0.2, se=F, alpha=0.5)+ 
  scale_y_continuous("log(% Cover+1)", limits = c(-0.1, 6), 
                     breaks = seq(0, 10, by=2), expand = c(0,0))+
  scale_x_continuous("", limits = c(1979, 2019),
                     breaks = seq(1980, 2018, by=2), expand = c(0,0))+
  
  theme(legend.position = c(0.1, 0.5))+
  annotate("rect", xmin = 1982, xmax = 1983, ymin = 0, ymax = 6,  alpha = .1, fill="red")+
  annotate("rect", xmin = 1997, xmax = 1998, ymin = 0, ymax = 6,  alpha = .1, fill="red")+
  annotate("rect", xmin = 2015, xmax = 2016, ymin = 0, ymax = 6,  alpha = .1, fill="red")
Cover_log+facet_grid(DataSet~.)

Generalized Linear Mixed Model

Packages used

# Creates bibliography 
# knitr::write_bib(c(.packages()), "packages.bib")

R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.

Wickham, Hadley, Winston Chang, Lionel Henry, Thomas Lin Pedersen, Kohske Takahashi, Claus Wilke, Kara Woo, and Hiroaki Yutani. 2019. Ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics. https://CRAN.R-project.org/package=ggplot2.