Jardim et al. (2022): Quantifying maerl (rhodolith) habitat complexity along an environmental gradient at regional scale

Read me

This is the code used for all analysis presented in the article and some supplementary material. You’ll find sections for each figure in the main article (except for fig. 2 which was completely created in adobe illustrator), and the two supp. materials mentioned in the text. Please contact me if you find any bugs or have any trouble running the code:

Set up

knitr::opts_chunk$set(echo = TRUE, message=FALSE, warning=FALSE, error = FALSE, eval = TRUE, cache = FALSE, tidy.opts = list(width.cutoff = 60), tidy = TRUE)

#code to set the document active folder (the one in which this .RMD file is located) as the working directory, if it doesn't work just set it manually.
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))

Packages

# Manipulating data
library(dplyr)
library(tidyverse)
library(magrittr)
library(reshape2)

#Visualization
library(ggplot2)
library(extrafont)
library(ggrepel)
library(ggpointdensity)
library(ggridges)
library(ggalt)
library(readr)
library(viridis)
library(ggthemes)
library(ggcorrplot)
library(ggpubr)
library(RColorBrewer)
library(compositions)
library(plotly)
library(ggtern)

#Maps
library(PBSmapping)
library(ggsn)
library(ggspatial)

#Modelling
library(jtools)
library(mgcv)
library(gratia)
library(ggvegan)
library(vegan)
library(adespatial)

#Permanova
library(devtools)
install_github("pmartinezarbizu/pairwiseAdonis/pairwiseAdonis")

#Variable transformation
library(EnvStats)

# Markdown
library(knitr)
library(kableExtra)

Functions

setwd("02_Functions/")
source("pca_victor.R")
source("box.cox.chord.R")
source("pca_chull_size.R")
source("triplot.rda.R")
source("utils.victor.R") #pour le plot rda
source("autoplot.rda.victor.R") #plot rda
pal <- c("#4477AA","#44AA99", "#80898f", "#e8bb5a", "#858c64", "#d44e65", "#EE8866","#8ECDDE", "#FFAABB", "#7b538c" )


pairwise.adonis <- function(x,factors, sim.function = 'vegdist', sim.method = 'eucl', p.adjust.m ='bonferroni')
{
  
  co = combn(unique(as.character(factors)),2)
  pairs = c()
  F.Model =c()
  R2 = c()
  p.value = c()
  
  
  for(elem in 1:ncol(co)){
    if(sim.function == 'daisy'){
      library(cluster); x1 = daisy(x[factors %in% c(co[1,elem],co[2,elem]),],metric=sim.method)
    } else{x1 = vegdist(x[factors %in% c(co[1,elem],co[2,elem]),],method=sim.method)}
    
    ad = adonis(x1 ~ factors[factors %in% c(co[1,elem],co[2,elem])], permutations = 9999 );
    pairs = c(pairs,paste(co[1,elem],'vs',co[2,elem]));
    F.Model =c(F.Model,ad$aov.tab[1,4]);
    R2 = c(R2,ad$aov.tab[1,5]);
    p.value = c(p.value,ad$aov.tab[1,6])
  }
  p.adjusted = p.adjust(p.value,method=p.adjust.m)
  sig = c(rep('',length(p.adjusted)))
  sig[p.adjusted <= 0.05] <-'.'
  sig[p.adjusted <= 0.01] <-'*'
  sig[p.adjusted <= 0.001] <-'**'
  sig[p.adjusted <= 0.0001] <-'***'
  
  pairw.res = data.frame(pairs,F.Model,R2,p.value)
  print("Signif. codes:  0 ???***??? 0.001 ???**??? 0.01 ???*??? 0.05 ???.??? 0.1 ??? ??? 1")
  return(pairw.res)
  
}

theme_set(theme_light()) 

setwd("..")

Loading data

#Set working directory
setwd("01_Data")

#Complexity Data
load("Complexity_data.RData")

#Environmental Data
load("Granulo_imputed_point_21_04_2021.Rdata") #granulometry
load("MA_hydrology_point.Rdata") #hidrology
load("Depth_27_11_2020.Rdata")#bathy
load("fetchDCE.Rdata")#fetch


setwd("..")

Complexity Data

comp <- complexity %>% 
  mutate(mini = paste(.$Code, .$Point, sep = "_")) %>% 
  mutate(site = recode(Code,"NBK" = "Rade de Brest - Keraliou", "MBE" = "Belle-ile", "MCM" = "Camaret", "MGL" = "Glenan","MME"= "Meaban","MMO" = "Molene", "MMX" = "Morlaix", "MRZ" = "Rade de Brest - Rozegat", "MPP" = "Baie de Saint-Brieuc", "MTR" = "Trevignon"))%>% 
  mutate(site = factor(site, levels = c("Baie de Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Rade de Brest - Keraliou", "Rade de Brest - Rozegat", "Trevignon"))) %>%
  mutate(Maerl_density = recode(site, "Rade de Brest - Keraliou" =  2288, "Belle-ile" = 1311, "Camaret" = 1322, "Glenan" = 2155, "Meaban" = 2222, "Molene" = 977, "Morlaix" = 3000, "Baie de Saint-Brieuc" = 277, "Rade de Brest - Rozegat" = 3377, "Trevignon" = 988)) %>%  ## add maerl density data at site level
  mutate(Sphericity = ((S^2)/(L*I))^(1/3)) %>% 
  mutate(DR1 = S/L) %>% 
  mutate(DR2 = ((L-I)/(L-S))) %>% 
  mutate(DR3 = I/L) %>% 
  mutate(point_name = paste(.$site, .$Point, sep = " ")) %>% 
  mutate(point_name = gsub("Rade de Brest - ", "", point_name)) %>%
  mutate(point_name = gsub("Baie de ", "", point_name)) %>%
  mutate(point_name = gsub("è", "e", point_name)) %>% 
  mutate(point_name = gsub("é", "e", point_name)) %>% 
  select(mini, site, point_name, everything(), -Code) %>%
  as.data.frame() %>%
  mutate_if(is.character, as.factor)

Box cox transformation

bccomp <- comp %>% 
  mutate(L = boxcoxTransform(L, boxcox(.$L, optimize = TRUE )$lambda)) %>%
  mutate(I = boxcoxTransform(I, boxcox(.$I, optimize = TRUE )$lambda)) %>%
  mutate(S = boxcoxTransform(S, boxcox(.$S, optimize = TRUE )$lambda)) %>%
  mutate(Maerl_density = boxcoxTransform(Maerl_density, boxcox(.$Maerl_density, optimize = TRUE )$lambda)) %>% 
  mutate(Broken_density = boxcoxTransform(Broken_density+1, boxcox(.$Broken_density+1, optimize = TRUE )$lambda)) %>% 
   mutate(site = gsub("Rade de Brest - ", "", .$site)) %>% 
  mutate(site = gsub("Baie de ", "", .$site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon")))

Checking correlation biplots after transformation

Figure 4 - Complexity PCA

# Allow us to see intra and intersite variability 

compnum <- bccomp %>% 
  select(Branching_density:DR3)
complexpca <- rda(compnum, scale = TRUE)

#summary(complexpca)
screeplot(complexpca,bstick=TRUE) #only look at pc1 and pc2, maybe pc5

## save as PDF
# pdf("03_Figures/pca_complex_wb.pdf", width = 20, height = 8.75)

pca_victor(pca = complexpca, metadata = bccomp, main.group = "site", scale.fill = pal, scale.colour = pal, goodness.thresh = 0.0, add.centroids = TRUE, nudge.x = c(0, 0.09, -0.055, .14, -0.05, 0, 0.06, -0.14, 0, 0), nudge.y = c(-.05, .06, -.05, .005, 0.055, -.05, -.05, .005, .05, -.05), stat1 = "ellipse", conf.level = .8, ysites = c(-0.65, 0.65), xsites = c(-0.65, 0.65), ysp = c(-2.1, 1.5), xsp = c(-2.1, 1.5), font.size = 20/.pt, axis.size = 22, axis.text = 20, c.size = 4)

# dev.off()


pca_victor(axes = c(1,5),pca = complexpca, metadata = comp, main.group = "site", scale.fill = pal, scale.colour = pal, stat1 = "ellipse" ,ysites = c(-.8, .8), xsites = c(-.8, .8), ysp= c(-2.1,1.6), xsp = c(-2.1,1.6))

#Extract PC1 and PC2 scores for exploration against environmental variables 
bccomp <- bccomp %>% 
  mutate(PC1_score =  scores(complexpca,choices = 1, scaling = 1, display = "sites")) %>% 
  mutate(PC2_score =  scores(complexpca,choices = 2, scaling = 1, display = "sites")) %>% 
  mutate(PC5_score =  scores(complexpca,choices = 5, scaling = 1, display = "sites"))

We can take a look at a cluster analysis in order to verify if we find similar groupings to what we see in the first 2 PCA axis.

Cluster

bccomp_sc <- bccomp %>% 
  group_by(site, point_name) %>% 
  summarise_at(vars(Branching_density:Sphericity), .funs = median) %>% #lets cluster by point and not by sample, so we take each point's median
  ungroup() %>% 
  set_rownames(paste(.$point_name)) %>% 
  as.data.frame() %>% 
  select(3:11)

bccomp_sc <- scale(bccomp_sc) #scale variables before clustering
  

comp.clust <- hclust(dist(bccomp_sc), "ward.D2")
plot(comp.clust, main = "Ward - Point", cex = 1, xaxt = "none")

Figure 3 - Shape triplots

#get the coordinates
triplot_pos <- comp %>% 
  select(mini,Point, point_name, Sample, site, DR1, DR2, DR3) %>% 
  mutate(x = (1-DR3 + (0.5 * DR1))) %>% # x coordinates based on Graham and Midgley (2000), “Graphical Representation of Particle Shape Using Triangular Diagrams.”
  mutate(y =  ((DR1*.866) * 1.15)) %>% # y coordinates
  mutate(Point = as.factor(Point)) %>% 
  mutate(site = gsub("Rade de Brest - ", "", site)) %>% 
  mutate(site = gsub("Baie de ", "", site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon")))



## Here's an option to create a plot with Sneed & Folk original classes  
# triplot_SF <- ggplot()+ #Sneed and Folk classes
#   geom_polygon(aes(x = c(0, 1, .5, 0), y = c(0, 0, 1, 0)), fill = "grey92")+ #ggplot's defaut bg colour
#   geom_segment(aes(x = .35, y = .7, xend = .65, yend = .7), size = 1, colour = "white") +
#   geom_segment(aes(x = .25, y = .5, xend = .75, yend = .5), size = 1, colour = "white") +
#   geom_segment(aes(x = .15, y = .3, xend = .85, yend = .3), size = 1, colour = "white") +
#   geom_segment(aes(x = .33, y = 0, xend = .45, yend = .7), size = 1, colour = "white") +
#   geom_segment(aes(x = .33, y = 0, xend = .45, yend = .7), size = 1, colour = "white") +
#   geom_segment(aes(x = .67, y = 0, xend = .55, yend = .7), size = 1, colour = "white") +
#   xlim(-0.25, 1.25) +
#   theme(line = element_blank(), panel.background = element_rect(fill = NA))
  
triplot <- ggplot()+ #Here's the option used in figure 3, based on Bosence's Classes
  geom_polygon(aes(x = c(0, 1, .5, 0), y = c(0, 0, 1, 0)), fill = "grey92")+ #ggplot's defaut bg colour
  geom_segment(aes(x = .35, y = .7, xend = .65, yend = .7), size = 1, colour = "white") +
  geom_segment(aes(x = .25, y = .5, xend = .5, yend = .35), size = 1, colour = "white") +
  geom_segment(aes(x = .5, y = .35, xend = .75, yend = .5), size = 1, colour = "white") +
  geom_segment(aes(x = .5, y = 0, xend = .5, yend = .35), size = 1, colour = "white") +
  geom_segment(aes(x = .7, y = 0, xend = .85, yend = .3), size = 1, colour = "white") +
  geom_segment(aes(x = .15, y = 0.3, xend = .3, yend = 0), size = 1, colour = "white") +
  xlim(-0.25, 1.25) +
  theme(line = element_blank(), panel.background = element_rect(fill = NA))+
  coord_fixed(ratio = 1, clip = "off")

# create one plot for each site with a facet grid theme
plist <- list()
pal.tab <- data.frame(site = levels(triplot_pos$site), pal = pal)
triplot_pos <- triplot_pos %>% 
  left_join(pal.tab)
for(i in unique(triplot_pos$site)){
  plist[[i]] <- triplot + geom_point(data  = triplot_pos[triplot_pos$site == i, ], aes(x= x, y = y, col = site, shape = Point), size = 2.5)
  plist[[i]] <- plist[[i]] + facet_wrap(~site)
  plist[[i]] <- plist[[i]] + scale_colour_manual(values = pal.tab[pal.tab$site == i, "pal"])
  plist[[i]] <- plist[[i]] + scale_fill_manual(values = pal.tab[pal.tab$site == i, "pal"])
  plist[[i]] <- plist[[i]] + labs(x = "", y = "") 
  plist[[i]] <- plist[[i]] + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.ticks = element_blank(), axis.text = element_blank(), legend.position = "NULL", strip.text = element_text(size = 30, face = "bold"))
  plist[[i]] <- plist[[i]] + coord_fixed(ratio = 1, clip = "off")
  plist[[i]]
  }
### Get the means so we have the centroids
centroids <-  triplot_pos %>%
  group_by(site) %>%
  summarise_at(vars(c(x, y)),mean)  %>%
  ungroup() %>% 
  rename(x_cent = x, y_cent = y)
  
triplot_pos <-  triplot_pos %>% 
  mutate(Title_all = as.factor("All Sites")) 

classes <- data.frame(classes = c("SS", "SD", "SE"), x = c(.50, .35, .65), y = c(.55, .24, .24)) %>%
  mutate(Title_sneed = as.factor("Bosence's Classes"))

triplot_pos <- triplot_pos %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon")))
p0 <- triplot
p0 <- p0 + geom_text(data = classes, aes(x = x, y = y, label = classes), size = 18/.pt, fontface = "bold")
p0 <- p0 + labs(x = "L-I/L-S", y = "")
p0 <- p0 + annotate(x = .15, y = .55, geom = "text", label = "S/L", size = 20/.pt, angle = 60)
p0 <- p0 + annotate(x = .85, y = .55, geom = "text", label = "I/L", size = 20/.pt, angle = -60)
p0 <- p0 + annotate(x = -.1, y = -.05, geom = "text", label = "Discoidal", fontface="bold", size = 25/.pt)
p0 <- p0 + annotate(x = 1.1, y = -.05, geom = "text", label = "Ellipsoidal", fontface="bold", size = 25/.pt)
p0 <- p0 + annotate(x = .5, y = 1.05, geom = "text", label = "Spheroidal", fontface="bold", size = 25/.pt)
p0 <- p0 + facet_wrap(~Title_sneed)
p0 <- p0 + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.ticks = element_blank(), axis.text = element_blank(), legend.position = "NULL", axis.title.x = element_text(size = 20, vjust = -.05), strip.text = element_text(size = 30, face = "bold"))
p0 <- p0 + coord_fixed(ratio = 1, clip = "off")

p11 <- triplot + stat_ellipse(data  = triplot_pos, aes(x= x, y = y, colour = site, fill = site), alpha = 0.3, geom = "polygon", level = .75, linetype = 2)
  p11 <- p11 + geom_point(data = centroids, aes(x = x_cent, y = y_cent, fill = site), size = 3.5, shape = 23, alpha = .9, colour = "NA")
  p11 <- p11 + facet_wrap(~Title_all)
  p11 <- p11 + scale_colour_manual(values = pal)
  p11 <- p11 + scale_fill_manual(values = pal)
  #trick so that p11 and p0 have the same size
  p11 <- p11 + labs(x = " ", y = " ") 
  p11 <- p11 + labs(x = "L-I/L-S", y = "")
  p11 <- p11 + annotate(x = .15, y = .55, geom = "text", label = "S/L", size = 20/.pt, angle = 60, col = "NA")
  p11 <- p11 + annotate(x = .85, y = .55, geom = "text", label = "I/L", size = 20/.pt, angle = -60, col = "NA")
  p11 <- p11 + annotate(x = -.1, y = -.05, geom = "text", label = "Discoidal", fontface="bold", size = 25/.pt, col = "NA")
  p11 <- p11 + annotate(x = 1.1, y = -.05, geom = "text", label = "Ellipsoidal", fontface="bold", size = 25/.pt, col = "NA")
  p11 <- p11 + annotate(x = .5, y = 1.05, geom = "text", label = "Spheroidal", fontface="bold", size = 25/.pt, col =  "NA")
  #again here in theme we add colour = "NA"so that the text occupies the same space as in p0 but is transparent...
  p11 <- p11 + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.title.x = element_text(size = 20, vjust = -.05, colour = "NA"), axis.ticks = element_blank(), axis.text = element_blank(), legend.position = "NULL", strip.text = element_text(size = 30, face = "bold"))
  p11 <- p11 + coord_fixed(ratio = 1, clip = "off")


pind <- ggarrange(plist$`Saint-Brieuc`, plist$`Belle-ile`,plist$Camaret, plist$Glenan, plist$Meaban, plist$Molene, plist$Morlaix, plist$Keraliou, ncol = 2, nrow = 4)
ptry <- ggarrange(ggarrange(p11, p0, ncol = 1, nrow = 2), ggarrange(plist$Rozegat, plist$Trevignon, align = "hv"), ncol = 1, heights = c(3,1))
(pf <- ggarrange(pind, ptry , widths = c(1,1), heights = c(1,1), align = "hv"))  

# pdf("03_Figures/shapetriplots.pdf", height = 16, width = 20)
# pf
# dev.off()

Supp. material I: Complexity PERMANOVA

Here we investigate the intra and intersite differences and check for dispersion problems.

#---- Permanova with all variables between sites ----

compnum_sc <- as.data.frame(scale(compnum)) ## scale the transformed variables
comp_dis <- vegdist(compnum_sc, method = "eucl") ## create eucliden distance matrix
comp_bd <- betadisper(comp_dis,comp$site) ## test for homogeneity of multivariate dispersions

permutest(comp_bd)# Some sites are different from eachother (p < 0.001)
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##            Df  Sum Sq Mean Sq      F N.Perm Pr(>F)    
## Groups      9  28.349 3.14992 4.1325    999  0.001 ***
## Residuals 350 266.782 0.76223                         
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey <- TukeyHSD(comp_bd) 
tukey <- do.call(rbind.data.frame, tukey) 

tukey %>% 
  filter(`p adj` < 0.05) #Problematic sites are Molene Saint-Brieuc
##                                                           diff         lwr
## group.Camaret-Baie de Saint-Brieuc                  -0.7017937 -1.35706275
## group.Meaban-Baie de Saint-Brieuc                   -0.6868692 -1.34213823
## group.Rade de Brest - Keraliou-Baie de Saint-Brieuc -0.7432192 -1.39848821
## group.Molene-Camaret                                 0.7423504  0.08708139
## group.Molene-Meaban                                  0.7274259  0.07215688
## group.Rade de Brest - Keraliou-Molene               -0.7837759 -1.43904492
## group.Rade de Brest - Rozegat-Molene                -0.6703340 -1.32560305
##                                                             upr       p adj
## group.Camaret-Baie de Saint-Brieuc                  -0.04652468 0.024902963
## group.Meaban-Baie de Saint-Brieuc                   -0.03160017 0.031356498
## group.Rade de Brest - Keraliou-Baie de Saint-Brieuc -0.08795014 0.012716418
## group.Molene-Camaret                                 1.39761946 0.012903091
## group.Molene-Meaban                                  1.38269494 0.016521402
## group.Rade de Brest - Keraliou-Molene               -0.12850685 0.006300142
## group.Rade de Brest - Rozegat-Molene                -0.01506498 0.040174808
#
permcomp <- adonis2(formula= compnum_sc ~ comp$site/comp$point_name, method = "eucl") #fixed effects with points nested in sites
permcomp
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = compnum_sc ~ comp$site/comp$point_name, method = "eucl")
##                            Df SumOfSqs      R2       F Pr(>F)    
## comp$site                   9   1336.4 0.31021 18.7984  0.001 ***
## comp$site:comp$point_name  20    365.0 0.08473  2.3105  0.001 ***
## Residual                  330   2606.6 0.60507                   
## Total                     359   4308.0 1.00000                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
pairwiseAdonis::pairwise.adonis(comp_dis, comp$site, p.adjust.m = "holm") #all sites are significantly different.
##                                                  pairs Df SumsOfSqs   F.Model
## 1                                 Belle-ile vs Camaret  1  25.96485  3.648702
## 2                                  Belle-ile vs Glenan  1  64.86138  8.102045
## 3                                  Belle-ile vs Meaban  1  49.83689  7.015632
## 4                                  Belle-ile vs Molene  1 136.79582 14.666972
## 5                                 Belle-ile vs Morlaix  1 120.73959 13.784596
## 6                    Belle-ile vs Baie de Saint-Brieuc  1 122.23442 13.056065
## 7                 Belle-ile vs Rade de Brest - Rozegat  1 139.37988 19.001947
## 8                               Belle-ile vs Trevignon  1 232.54557 28.451559
## 9                Belle-ile vs Rade de Brest - Keraliou  1 129.21996 18.482724
## 10                                   Camaret vs Glenan  1  85.84033 11.160625
## 11                                   Camaret vs Meaban  1  33.46774  4.929345
## 12                                   Camaret vs Molene  1  90.44034 10.034886
## 13                                  Camaret vs Morlaix  1 115.43187 13.668953
## 14                     Camaret vs Baie de Saint-Brieuc  1 129.87993 14.354435
## 15                  Camaret vs Rade de Brest - Rozegat  1 101.51921 14.459715
## 16                                Camaret vs Trevignon  1 150.07670 19.095709
## 17                 Camaret vs Rade de Brest - Keraliou  1  74.05233 11.090342
## 18                                    Glenan vs Meaban  1  89.10332 11.603719
## 19                                    Glenan vs Molene  1 200.00736 20.198764
## 20                                   Glenan vs Morlaix  1  77.47589  8.300226
## 21                      Glenan vs Baie de Saint-Brieuc  1 194.29290 19.551607
## 22                   Glenan vs Rade de Brest - Rozegat  1 174.18725 22.020590
## 23                                 Glenan vs Trevignon  1 361.10910 41.276437
## 24                  Glenan vs Rade de Brest - Keraliou  1 219.98709 29.073598
## 25                                    Meaban vs Molene  1 123.36615 13.707204
## 26                                   Meaban vs Morlaix  1  66.85317  7.928201
## 27                      Meaban vs Baie de Saint-Brieuc  1 212.72471 23.543020
## 28                   Meaban vs Rade de Brest - Rozegat  1  34.66119  4.945710
## 29                                 Meaban vs Trevignon  1 216.47170 27.587650
## 30                  Meaban vs Rade de Brest - Keraliou  1  45.49254  6.825900
## 31                                   Molene vs Morlaix  1 167.84247 15.751829
## 32                      Molene vs Baie de Saint-Brieuc  1  58.87130  5.228972
## 33                   Molene vs Rade de Brest - Rozegat  1 227.92547 24.690142
## 34                                 Molene vs Trevignon  1 110.95128 11.018232
## 35                  Molene vs Rade de Brest - Keraliou  1 117.49553 13.219873
## 36                     Morlaix vs Baie de Saint-Brieuc  1 249.44107 23.332081
## 37                  Morlaix vs Rade de Brest - Rozegat  1  99.86030 11.526334
## 38                                Morlaix vs Trevignon  1 390.32145 41.077735
## 39                 Morlaix vs Rade de Brest - Keraliou  1 162.20250 19.495433
## 40     Baie de Saint-Brieuc vs Rade de Brest - Rozegat  1 383.88327 41.425145
## 41                   Baie de Saint-Brieuc vs Trevignon  1 197.75703 19.569696
## 42    Baie de Saint-Brieuc vs Rade de Brest - Keraliou  1 255.84852 28.672046
## 43                Rade de Brest - Rozegat vs Trevignon  1 276.37633 34.213338
## 44 Rade de Brest - Rozegat vs Rade de Brest - Keraliou  1  50.56353  7.332262
## 45               Trevignon vs Rade de Brest - Keraliou  1 114.51904 14.806476
##            R2 p.value p.adjusted sig
## 1  0.04954198   0.004      0.045   .
## 2  0.10373666   0.001      0.045   .
## 3  0.09109361   0.001      0.045   .
## 4  0.17323133   0.001      0.045   .
## 5  0.16452423   0.001      0.045   .
## 6  0.15719580   0.001      0.045   .
## 7  0.21350035   0.001      0.045   .
## 8  0.28899044   0.001      0.045   .
## 9  0.20888511   0.001      0.045   .
## 10 0.13751280   0.001      0.045   .
## 11 0.06578658   0.001      0.045   .
## 12 0.12538140   0.001      0.045   .
## 13 0.16336948   0.001      0.045   .
## 14 0.17016811   0.001      0.045   .
## 15 0.17120251   0.001      0.045   .
## 16 0.21432804   0.001      0.045   .
## 17 0.13676527   0.001      0.045   .
## 18 0.14219596   0.001      0.045   .
## 19 0.22393615   0.001      0.045   .
## 20 0.10600514   0.001      0.045   .
## 21 0.21832782   0.001      0.045   .
## 22 0.23930068   0.001      0.045   .
## 23 0.37093600   0.001      0.045   .
## 24 0.29345455   0.001      0.045   .
## 25 0.16375179   0.001      0.045   .
## 26 0.10173725   0.001      0.045   .
## 27 0.25168121   0.001      0.045   .
## 28 0.06599057   0.001      0.045   .
## 29 0.28269612   0.001      0.045   .
## 30 0.08884894   0.001      0.045   .
## 31 0.18369088   0.001      0.045   .
## 32 0.06950743   0.002      0.045   .
## 33 0.26074670   0.001      0.045   .
## 34 0.13599694   0.001      0.045   .
## 35 0.15885476   0.001      0.045   .
## 36 0.24998994   0.001      0.045   .
## 37 0.14138172   0.001      0.045   .
## 38 0.36981070   0.001      0.045   .
## 39 0.21783719   0.001      0.045   .
## 40 0.37177555   0.001      0.045   .
## 41 0.21848568   0.001      0.045   .
## 42 0.29057922   0.001      0.045   .
## 43 0.32830095   0.001      0.045   .
## 44 0.09481504   0.001      0.045   .
## 45 0.17459134   0.001      0.045   .
## Sites Saint-Brieuc and Molene are the ones that pose most of the problems

sansSB <- compnum_sc %>% 
  filter(!bccomp$site %in% c("Saint-Brieuc", "Molene"))
compsansSB <- bccomp %>% 
  filter(!site %in% c("Saint-Brieuc", "Molene"))
compsansSB <- droplevels(compsansSB)
sansSB_dis <- vegdist(sansSB, method = "eucl") ## create eucliden distance matrix
sansSB_bd <- betadisper(sansSB_dis, compsansSB$site) ## test for homogeneity of multivariate dispersions

permutest(sansSB_bd)# MET!
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##            Df  Sum Sq Mean Sq      F N.Perm Pr(>F)  
## Groups      7  10.093 1.44188 1.9586    999  0.058 .
## Residuals 280 206.131 0.73618                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#(tukeySB <- TukeyHSD(sansSB_bd)) 


permcompSB <- adonis2(formula= sansSB_dis ~ compsansSB$site/compsansSB$point_name, method = "eucl") #fixed effects with point nested in sites
permcompSB
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = sansSB_dis ~ compsansSB$site/compsansSB$point_name, method = "eucl")
##                                        Df SumOfSqs      R2       F Pr(>F)    
## compsansSB$site                         7   925.53 0.29769 18.3211  0.001 ***
## compsansSB$site:compsansSB$point_name  16   278.30 0.08951  2.4102  0.001 ***
## Residual                              264  1905.22 0.61280                   
## Total                                 287  3109.05 1.00000                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## almost nothing changes from the first result! we can proceed with the interpretation assuming the differences in dispersion are not interefering as much.

Granulometry

granulo <-  point_imp %>% 
  filter(site!= "Rhuys") %>%     #remove rows on Rhuys site, not analysed in this project, only spring data
  filter(annee %in% c(2007:2018)) %>% 
  mutate(point_name = gsub("Belle-Ile", "Belle-ile", point_name)) %>% 
  mutate(point_name = gsub("Rade de Brest - ", "", point_name)) %>%
  mutate(point_name = gsub("Rade de Brest-", "", point_name)) %>%
  mutate(point_name = gsub("è", "e", point_name)) %>% 
  mutate(point_name = gsub("é", "e", point_name)) %>% 
   mutate(site = gsub("Rade de Brest - ", "", .$site)) %>% 
  mutate(site = gsub("Baie de ", "", .$site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon"))) %>% 
  select(mini, everything()) %>%
  as.data.frame() %>%
  set_rownames(paste( .$mini, .$annee)) %>% 
  rename(OM = pourcentage_MO) %>% 
  mutate_if(is.character, as.factor)

granulo <- droplevels(granulo)

Mean values over the whole period

#let's get the mean over the last ~20 years for now

granulo_mean <- granulo %>% 
  select(Mean.fw.um:OM) %>% 
  aggregate(., by = list(granulo$mini, granulo$site, granulo$point_name), FUN = mean) %>% 
  rename(., mini = Group.1, site = Group.2, point_name = Group.3) %>% 
  set_rownames(paste( .$mini))

#let's get the sd over the last ~20 years for now
granulo_sd <- granulo %>% 
  select(Mean.fw.um:OM) %>% 
  aggregate(., by = list(granulo$mini, granulo$site, granulo$point_name), FUN = sd) 
colnames(granulo_sd) <- paste(colnames(granulo_sd), "sd", sep = "_")
granulo_sd <- granulo_sd %>% 
  rename(., mini = Group.1_sd, site = Group.2_sd, point_name = Group.3_sd) %>% 
  mutate_if(is.character, as.numeric)

Figure 6 - Granulometry Ternary Plot

label_pos <- granulo %>% 
  select(Gravel:mud) %>% 
  aggregate(., by = list(granulo$site), FUN = mean) %>% 
  rename(., site = Group.1) %>% 
  mutate(site = gsub("Rade de Brest - ", "", site)) %>% 
  mutate(site = gsub("Baie de ", "", site)) %>% 
  mutate(total = Sand + Gravel + mud) %>% 
  mutate_if(is.character, as.factor) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon")))
  
#all samples
p <- ggtern(data = granulo, mapping = aes(x = Sand, y= mud, z = Gravel))+
  geom_point(aes(colour = site))+
  stat_mean_ellipse(aes(colour = site, fill = site), geom = "polygon", alpha = 0.3)+
  geom_label_viewport(x = .75, y = .27, label = "Trevignon", fill = pal[10], fontface="bold", size = 20/.pt)+
  geom_label_viewport(x = .65, y = .22, label = "Rozegat", fill = pal[9], fontface="bold", size = 20/.pt)+
  geom_label_viewport(x = .62, y = .42, label = "Keraliou", fill = pal[8], fontface="bold", size = 20/.pt)+
  geom_label_viewport(x = .34, y = .19, label = "Camaret", fill = pal[3], fontface="bold", size = 20/.pt)+
  scale_fill_manual(values = pal) +
  scale_colour_manual(values = pal) +
  labs(x = "Sand", y = "Mud", z = "Gravel", )+
  theme(legend.position = "null", axis.title = element_text(face = "bold", size = 22), axis.text = element_text(size = 20))+
  theme_arrowlength()
  

#pdf(file = "03_Figures/triplot_granulo.pdf", width = 20)
p

#dev.off()

  
# Just an idea of what it would look like only with mean values

ggtern(data = granulo_mean, mapping = aes(x = Sand, y= mud, z = Gravel))+
  geom_point(aes(colour = site))+
  stat_mean_ellipse(aes(colour = site, fill = site), geom = "polygon", alpha = 0.3)+
  scale_fill_manual(values = pal) +
  scale_colour_manual(values = pal) +
  labs(x = "Sand", y = "Mud", z = "Gravel", )+
  theme_arrowlength()

Hydrology

hydro <- MA_hydro_int_six_month %>% 
  select(-c(theme, method_echant))%>% #remove useless info
  filter(site!= "Rhuys",saison == "Printemps") %>%   #remove rows on Rhuys site, not analysed in this project, only spring data
  filter(annee %in% c(2007:2018)) %>% 
  mutate(mini = recode(point_name, "Keraliou 1"= "NBK_1","Keraliou 2"= "NBK_2","Keraliou 3"= "NBK_3","Belle-Ile 1"= "MBE_1", "Belle-Ile 2"= "MBE_2", "Belle-Ile 3"= "MBE_3", "Camaret 1"= "MCM_1", "Camaret 2"= "MCM_2", "Camaret 3"= "MCM_3", "Glénan 1"= "MGL_1", "Glénan 2"= "MGL_2", "Glénan 3"= "MGL_3", "Meaban 1"= "MME_1", "Meaban 2"= "MME_2", "Meaban 3"= "MME_3", "Molène 1"= "MMO_1", "Molène 2"= "MMO_2", "Molène 3"= "MMO_3", "Morlaix 1"= "MMX_1", "Morlaix 2"= "MMX_2", "Morlaix 3"= "MMX_3", "Rade de Brest-Rozegat 1" = "MRZ_1", "Rade de Brest-Rozegat 2" = "MRZ_2", "Rade de Brest-Rozegat 3" = "MRZ_3", "Saint-Brieuc 1" = "MPP_1", "Saint-Brieuc 2" = "MPP_2", "Saint-Brieuc 3" = "MPP_3", "Trévignon 1" = "MTR_1", "Trévignon 2" = "MTR_2", "Trévignon 3" = "MTR_3" )) %>%
  mutate(point_name = gsub("Belle-Ile", "Belle-ile", point_name)) %>% 
  mutate(point_name = gsub("Rade de Brest - ", "", point_name)) %>%
  mutate(point_name = gsub("Rade de Brest-", "", point_name)) %>%
  mutate(point_name = gsub("è", "e", point_name)) %>% 
  mutate(point_name = gsub("é", "e", point_name)) %>% #remove special ch.
  mutate(site = gsub("Rade de Brest - ", "", .$site)) %>% 
  mutate(site = gsub("Baie de ", "", .$site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon"))) %>% 
  mutate(annee = as.numeric(levels(.$annee)[.$annee])) %>% 
  select(mini, everything()) %>%
  as.data.frame() %>%
  set_rownames(paste( .$mini, .$annee)) %>% 
  mutate_if(is.character, as.factor)

hydro <- droplevels(hydro)

# ggplot(data = hydro, aes(x = point_name, y = bottomT_mean, colour = site))+
#   geom_boxplot()+
#   scale_color_manual(values = pal)+
#   theme(axis.text.x = element_text(angle = 90))
# 
# ggplot(data = hydro, aes(x = point_name, y = current_mean, colour = site))+
#   geom_boxplot()+
#   scale_color_manual(values = pal)+
#   theme(axis.text.x = element_text(angle = 90))


#let's get the mean for now

hydro_mean <- hydro %>% 
  select(bottomT_min:current_sd) %>% 
  aggregate(., by = list(hydro$mini, hydro$site, hydro$point_name), FUN = median) %>% 
  rename(., mini = Group.1, site = Group.2, point_name = Group.3) %>% 
  set_rownames(paste( .$mini))

# ggplot(data = hydro_mean, aes(x = point_name, y = current_mean, colour = site))+
#   geom_point()+
#   scale_color_manual(values = pal)+
#   theme(axis.text.x = element_text(angle = 90))
# ggplot(data = hydro_mean, aes(x = point_name, y = bottomT_mean, colour = site))+
#   geom_point()+
#   scale_color_manual(values = pal)+
#   theme(axis.text.x = element_text(angle = 90))
# ggplot(data =hydro_mean, aes(x = current_max))+
#   stat_density(col = "red")

#let's get the sd 
hydro_sd <- hydro %>% 
  select(bottomT_min:current_sd) %>% 
  aggregate(., by = list(hydro$mini, hydro$site, hydro$point_name), FUN = sd) 
colnames(hydro_sd) <- paste(colnames(hydro_sd), "sd", sep = "_")
hydro_sd <- hydro_sd %>% 
  rename(., mini = Group.1_sd, site = Group.2_sd, point_name = Group.3_sd) %>% 
  mutate_if(is.character, as.numeric)

# ggplot(data = hydro_sd, aes(x = point_name, y = current_mean_sd, colour = site))+
#   geom_point()+
#   scale_color_manual(values = pal)+
#   theme(axis.text.x = element_text(angle = 90))
# ggplot(data = hydro_sd, aes(x = point_name, y = bottomT_mean_sd, colour = site))+
#   geom_point()+
#   scale_color_manual(values = pal)+
#   theme(axis.text.x = element_text(angle = 90))

Bathymetry

bathy <- depth_point_sub %>% 
  filter(theme == "Bancs de Maërl") %>% 
  select(-c(theme, method_echant))%>% #remove useless info
  filter(site!= "Rhuys") %>%   #remove rows on Rhuys site, not analysed in this project
  mutate(mini = recode(point_name, "Keraliou 1"= "NBK_1","Keraliou 2"= "NBK_2","Keraliou 3"= "NBK_3","Belle-Ile 1"= "MBE_1", "Belle-Ile 2"= "MBE_2", "Belle-Ile 3"= "MBE_3", "Camaret 1"= "MCM_1", "Camaret 2"= "MCM_2", "Camaret 3"= "MCM_3", "Glénan 1"= "MGL_1", "Glénan 2"= "MGL_2", "Glénan 3"= "MGL_3", "Meaban 1"= "MME_1", "Meaban 2"= "MME_2", "Meaban 3"= "MME_3", "Molène 1"= "MMO_1", "Molène 2"= "MMO_2", "Molène 3"= "MMO_3", "Morlaix 1"= "MMX_1", "Morlaix 2"= "MMX_2", "Morlaix 3"= "MMX_3", "Rade de Brest-Rozegat 1" = "MRZ_1", "Rade de Brest-Rozegat 2" = "MRZ_2", "Rade de Brest-Rozegat 3" = "MRZ_3", "Saint-Brieuc 1" = "MPP_1", "Saint-Brieuc 2" = "MPP_2", "Saint-Brieuc 3" = "MPP_3", "Trévignon 1" = "MTR_1", "Trévignon 2" = "MTR_2", "Trévignon 3" = "MTR_3" )) %>%
  mutate(point_name = gsub("Belle-Ile", "Belle-ile", point_name)) %>% 
  mutate(point_name = gsub("Rade de Brest - ", "", point_name)) %>%
  mutate(point_name = gsub("Rade de Brest-", "", point_name)) %>%
  mutate(point_name = gsub("è", "e", point_name)) %>% 
  mutate(point_name = gsub("é", "e", point_name)) %>% #remove special ch.
  mutate(site = gsub("Rade de Brest - ", "", .$site)) %>% 
  mutate(site = gsub("Baie de ", "", .$site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon"))) %>% 
  mutate(depth = -depth) %>% 
  select(mini, everything()) %>%
  as.data.frame() %>%
  set_rownames(paste( .$mini)) %>% 
  mutate_if(is.character, as.factor)

bathy <- droplevels(bathy)

# ggplot(data = bathy, aes(x = point_name, y = depth, colour = site))+
#   geom_point()+
#   scale_color_manual(values = pal)+
#   theme(axis.text.x = element_text(angle = 90))

Figure 1 - Study Area + Fetch

fetch <- fetch.dfDCE %>% 
  mutate(site = recode(site, "Trevignon " = "Trevignon")) %>%
  mutate(point_name = paste(site, point, sep = " ")) %>% 
  mutate(mini = recode(point_name, "Rade de Brest - Keraliou 1"= "NBK_1","Rade de Brest - Keraliou 2"= "NBK_2","Rade de Brest - Keraliou 3"= "NBK_3","Belle-ile 1"= "MBE_1", "Belle-ile 2"= "MBE_2", "Belle-ile 3"= "MBE_3", "Camaret 1"= "MCM_1", "Camaret 2"= "MCM_2", "Camaret 3"= "MCM_3", "Glenan 1"= "MGL_1", "Glenan 2"= "MGL_2", "Glenan 3"= "MGL_3", "Meaban 1"= "MME_1", "Meaban 2"= "MME_2", "Meaban 3"= "MME_3", "Molene 1"= "MMO_1", "Molene 2"= "MMO_2", "Molene 3"= "MMO_3", "Morlaix 1"= "MMX_1", "Morlaix 2"= "MMX_2", "Morlaix 3"= "MMX_3", "Rade de Brest - Rozegat 1" = "MRZ_1", "Rade de Brest - Rozegat 2" = "MRZ_2", "Rade de Brest - Rozegat 3" = "MRZ_3", "Baie de Saint-Brieuc 1" = "MPP_1", "Baie de Saint-Brieuc 2" = "MPP_2", "Baie de Saint-Brieuc 3" = "MPP_3", "Trevignon 1" = "MTR_1", "Trevignon 2" = "MTR_2", "Trevignon 3" = "MTR_3" )) %>%
  mutate(point_name = gsub("Rade de Brest - ", "", point_name)) %>%
  mutate(point_name = gsub("Rade de Brest-", "", point_name)) %>%
  mutate(point_name = gsub("Baie de ", "", point_name)) %>%
    mutate(site = gsub("Rade de Brest - ", "", site)) %>% 
  mutate(site = gsub("Baie de ", "", site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon"))) %>% 
  mutate(site = gsub("Rade de Brest - ", "", .$site)) %>% 
  mutate(site = gsub("Baie de ", "", .$site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon"))) %>% 
  select(mini, site, point_name, everything()) %>% 
  set_rownames(paste( .$mini)) %>% 
  mutate_if(is.character, as.factor)

fetch.melt <- melt(fetch.dfDCE,id.vars=c("site","point","longitude","latitude"))

# Retrieve a map layer for France
france_data <- map_data("france")
names(france_data) <- c("X","Y","PID","POS","region","subregion")

# Zoom on Brittany
xlim <- c(-7.5,-1.8)
ylim <- c(46,49)
francemap <- clipPolys(france_data, xlim=xlim,ylim=ylim, keepExtra=TRUE)


p <- ggplot(aes(x=longitude,y=latitude,size=value, col = site), data=fetch.melt, fill = "black") + coord_equal()
p <- p + geom_polygon(data=francemap,aes(X,Y,group=PID),fill="gray35",inherit.aes=F,show.legend=F)
p <- p + geom_point(aes(text=paste(site,point,value)), alpha=0.3)
p <- p + facet_wrap(~variable,ncol=3) 
p <- p + scale_fill_manual(values = pal)
p <- p + scale_colour_manual(values = pal)
p <- p + theme(legend.position="none",panel.background = element_rect(fill = "#b6ced6"), panel.grid = element_blank())
p <- p +  ylim(c(min(francemap$Y), max(francemap$Y)))
p <- p + ylim(c(min(francemap$Y), max(francemap$Y)))
p <- p + ylab("")+ xlab("")
p <- p +scale_y_continuous(breaks=c(46.5,47,47.5,48,48.5,49,49.5,50), labels = c("46.5°N","47ºN","47.5°N", "48ºN","48.5°N", "49ºN","49.5°N","50°N")) 
p <- p + scale_x_continuous(breaks=c(-6,-5,-4,-3,-2,-1,0), labels = c("6°W","5°W","4°W","3°W","2°W","1°W","0°")) 
p <- p + coord_cartesian(xlim = xlim, ylim = ylim, expand = FALSE)

p

# get the fetch max 
fetch_max <- fetch %>% 
  gather(North:West, key = "Direction", value = Fetch) %>% 
  group_by(mini, point_name, latitude, longitude) %>% 
  summarise(Fetch_max = max(Fetch)) %>% 
  left_join(fetch) %>% 
  select(mini, site, point_name, -point, latitude, longitude, North:Average, Fetch_max) %>% 
  set_rownames(paste(.$mini))

p <- ggplot() 
p <- p + geom_polygon(data=francemap,aes(X,Y,group=PID),fill="gray90",inherit.aes=F,show.legend=F)
p <- p + geom_point(data = fetch_max, aes(x=longitude,y=latitude,size=Fetch_max, fill=site), shape = 21, alpha  = 0.6) + coord_equal() + scale_size_continuous(range = c(2,15), name = "Fetch", breaks = c(50, 150, 300))
p <- p + scale_fill_manual(values = pal)
p <- p + guides(fill = FALSE, size = guide_legend(title.position = "top"))
p <- p + theme(legend.key = element_rect(fill = NA), legend.background = element_blank(), panel.background = element_rect(fill = "#b6ced6"), panel.grid = element_blank(), axis.text = element_text(size = 14))
p <- p + ylab("")+ xlab("")
p <- p +scale_y_continuous(breaks=c(46.5,47,47.5,48,48.5,49,49.5,50), labels = c("46.5°N","47ºN","47.5°N", "48ºN","48.5°N", "49ºN","49.5°N","50°N")) 
p <- p + scale_x_continuous(breaks=c(-7, -6,-5,-4,-3,-2,-1,0), labels = c( "7°W","6°W","5°W","4°W","3°W","2°W","1°W","0°")) 
p <- p + coord_cartesian(xlim = xlim, ylim = ylim, expand = FALSE)

p

# Color Brittany (Bretagne)
fill_bret <- rep("gray90",nrow(france_data))
fill_bret[france_data$region=="Finistere"] <- "gray35"
fill_bret[france_data$region=="Morbihan"] <- "gray35"
fill_bret[france_data$region=="Ille-et-Vilaine"] <- "gray35"
fill_bret[france_data$region=="Cotes-Darmor"] <- "gray35"


france_map <- ggplot() + coord_map()
france_map <- france_map + scale_x_continuous(expand=c(0,0))
france_map <- france_map + theme(axis.ticks=element_blank(), axis.title=element_blank(), axis.text=element_blank())
france_map <- france_map + geom_polygon(data=france_data, mapping=aes(x=X, y=Y,group=PID), fill=fill_bret,col=fill_bret) 
france_map <- france_map + theme_void() 

### world

world <- map_data("world")

# Color France
fill_world <- rep("gray90",nrow(world))
fill_world[world$region=="France"] <- "gray35"
col_world <- rep("gray75", nrow(world) )
col_world[world$region=="France"] <- "gray35"
worldmap <- ggplot(world, aes(x=long, y=lat, group=group)) 
worldmap <- worldmap + geom_path(size = .2)
worldmap <- worldmap + scale_y_continuous(breaks=(-2:2) * 30) 
worldmap <- worldmap + scale_x_continuous(breaks=(-4:4) * 45)+ theme(panel.grid = element_line(colour = "gray35", size = 0.2))
worldmap <- worldmap + coord_map("ortho", orientation=c(41, -5, 0)) + ylab("") + xlab("")
worldmap <- worldmap + geom_polygon(data=world, mapping=aes(x=long, y=lat,group=group), fill=fill_world,col=col_world,size = 0.2) 
worldmap <- worldmap+ theme(axis.text=element_blank(),axis.ticks=element_blank(),panel.border=element_blank(),panel.background = element_blank(), rect = element_blank())


fetch_max <- fetch_max %>%
  as.data.frame() %>% 
  mutate(rename(., long = longitude, lat = latitude))


(map_fetch <- p +  
    geom_rect(aes(xmin = -6.3, xmax = -4.56, ymin = 46.1, ymax = 47.5), fill = alpha("gray35", .15), color = "gray35", lwd = 0.75)+
    annotation_custom(grob = ggplotGrob(worldmap), xmin = -7.4, xmax = -6, ymin = 47.5, ymax = 48.7)+
    geom_rect(aes(xmin = -6.7, xmax = -6.52, ymin = 48.1, ymax = 48.25), fill = NA, color = "gray35", lwd = 0.75)+
    geom_line(aes(x = c(-6.3, -6.7), y = c(47.5, 48.25)), color = "gray35", lwd = 0.65, linetype = 2) +
    geom_line(aes(x = c(-6.52, -4.56), y = c(48.25, 47.5)), color = "gray35", lwd = 0.65, linetype = 2) +
    annotation_custom(grob = ggplotGrob(france_map), xmin = -6.3, xmax = -4.6, ymin = 46.1, ymax = 47.5 )+
    scalebar(data=fetch_max, dist=45, dist_unit="km",  height = 0.02, transform=TRUE, model="WGS84", box.fill = c("gray35", "white"), location = "bottomright", st.color = "gray35", st.size = 8,  anchor = c(x = -2.38, y =  46.1))+
  annotation_north_arrow(location = "br", which_north = "true", height = unit(1.5, "cm"), width = unit(1.5, "cm"), style = north_arrow_fancy_orienteering(fill = c("white", "gray35"), text_face = "bold", text_col = "gray35", text_size = 16, line_col = "gray35", line_width = 2))+
  geom_text(aes(label = "France", x = -5.42, y = 46.85), fontface = "bold", colour = "gray35", size = 12)+
  geom_text(aes(label = "Brittany", x = -2.9, y = 48.20), fontface = "bold", colour = "gray35", size = 16) +
  geom_text(aes(label = "Saint-Brieuc", x = -2.35, y = 48.65), fontface = "bold", colour = "gray35", size = 10)+
  geom_text(aes(label = "Rozegat", x = -4, y = 48.315), fontface = "bold", colour = "gray35", size = 10) +
  geom_text(aes(label = "Keraliou", x = -4.06, y = 48.415), fontface = "bold", colour = "gray35", size = 10)+
  geom_text(aes(label = "Morlaix", x = -3.5, y = 48.7), fontface = "bold", colour = "gray35", size = 10) +
  geom_text(aes(label = "Molène", x = -5.3, y = 48.4), fontface = "bold", colour = "gray35", size = 10) +
  geom_text(aes(label = "Camaret", x = -5.05, y = 48.25), fontface = "bold", colour = "gray35", size = 10) +
  geom_text(aes(label = "Trévignon", x = -3.35, y = 47.82), fontface = "bold", colour = "gray35", size = 10)+
  geom_text(aes(label = "Glénan", x = -4.4, y = 47.7), fontface = "bold", colour = "gray35", size = 10)+ 
  geom_text(aes(label = "Méaban", x = -2.5, y = 47.53), fontface = "bold", colour = "gray35", size = 10)+ 
  geom_text(aes(label = "Belle-île", x = -3.2, y = 47.22), fontface = "bold", colour = "gray35", size = 10)+
  theme(legend.position = c(.81, .1), legend.direction = "horizontal", legend.title = element_text(face = "bold", colour = "gray35", size = 22), legend.text = element_text(size = 20, colour = "gray35"), axis.text = element_text(size = 20))
  )

# pdf("03_Figures/fetch_map.pdf", width= 16, height=11.25)
# map_fetch
# dev.off()

Environmental table

env <- granulo %>% 
  left_join(hydro) %>% 
  left_join(bathy) %>% 
  left_join(fetch_max) %>% 
  mutate(site = gsub("Rade de Brest - ", "", site)) %>% 
  mutate(site = gsub("Baie de ", "", site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon"))) %>% 
  mutate(site = gsub("Rade de Brest - ", "", .$site)) %>% 
  mutate(site = gsub("Baie de ", "", .$site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon"))) %>% 
  rename("Grain size" = "Mean.fw.um", "Temperature" = "bottomT_mean", "Organic Matter" = "OM", "Current" = "current_mean", "Depth" = "depth", "Fetch" = "Fetch_max", "Trask" = "Trask(So)", "Mud" = "mud")

  
envnum <- env %>% 
  select(Temperature, Current, Trask, `Organic Matter`, Sand, Gravel, Mud, Fetch, Depth, `Grain size`)

Figure 5. Box-cox transformed environmental PCA

boxcoxenv <-   envnum %>% 
  select(-`Grain size`) %>% 
  mutate(Mud = boxcoxTransform(Mud, boxcox(.$Mud, optimize = TRUE )$lambda)) %>%
  mutate(Sand = boxcoxTransform(Sand, boxcox(.$Sand, optimize = TRUE )$lambda)) %>%
  mutate(Gravel = boxcoxTransform(Gravel, boxcox(.$Gravel, optimize = TRUE )$lambda)) %>%
  mutate(Current = boxcoxTransform(Current, boxcox(.$Current, optimize = TRUE )$lambda)) %>%
  mutate(Temperature = boxcoxTransform(Temperature, boxcox(.$Temperature, optimize = TRUE )$lambda)) %>%
  mutate(`Organic Matter` = boxcoxTransform(`Organic Matter`, boxcox(.$`Organic Matter`, optimize = TRUE )$lambda)) %>%
  mutate(Trask = boxcoxTransform(Trask, boxcox(.$Trask, optimize = TRUE )$lambda)) %>%
  mutate(Depth = boxcoxTransform(Depth, boxcox(.$Depth, optimize = TRUE )$lambda)) %>%
  mutate(Fetch = boxcoxTransform(Fetch, boxcox(.$Fetch, optimize = TRUE )$lambda))

bcenvpca <- rda(boxcoxenv, scale = TRUE)

#summary(bcenvpca)
screeplot(bcenvpca,bstick=TRUE) #only look at pc1 and pc2, maybe pc5

# pdf("03_Figures/pca_env_wb.pdf", width = 20, height = 8.75)

pca_victor(pca = bcenvpca, metadata = env, main.group = "site", scale.fill = pal, scale.colour = pal, scale.shape = c(15:17), nudge.x = c(-.11, .17, 0, -0.15, .08, -.08, 0.04, 0, 0, 0 ), nudge.y = c(-.05, .01, .065, .01, .065, .065, -.06, .065, -.05, -.05), stat1 = "ellipse", conf.level = .9, ysites = c(-0.65, 0.65), xsites = c(-0.65, 0.65), ysp = c(-2.3, 2.3), xsp = c(-2.3, 2.3), font.size = 20/.pt, axis.size = 22, axis.text = 20, c.size = 4, add.centroids = TRUE, goodness.thresh = 0)

# dev.off()

#let's check the axis 5 just in case
pca_victor(pca = bcenvpca, metadata = env, main.group = "site", scale.fill = pal, scale.colour = pal, scale.shape = c(15:17), stat1 = "ellipse", conf.level = .9, ysites = c(-0.65, 0.65), xsites = c(-0.65, 0.65), ysp = c(-1.8, 1.8), xsp = c(-1.8, 1.8), font.size = 20/.pt, axis.size = 22, axis.text = 20, c.size = 4, add.centroids = TRUE,axes = c(1,5))

Model table

modtab <- bccomp %>% 
  left_join(granulo_mean) %>% 
  left_join(granulo_sd) %>% 
  left_join(hydro_mean) %>% 
  left_join(hydro_sd) %>% 
  left_join(bathy) %>% 
  left_join(fetch_max) %>% 
  mutate(site = gsub("Rade de Brest - ", "", site)) %>% 
  mutate(site = gsub("Baie de ", "", site)) %>% 
  mutate(site = factor(site, levels = c("Saint-Brieuc", "Belle-ile", "Camaret", "Glenan", "Meaban", "Molene", "Morlaix", "Keraliou", "Rozegat", "Trevignon"))) %>% 
  set_rownames(paste(.$mini, .$Sample, sep = "_"))

GGally::ggpairs(modtab %>% select(bottomT_mean, bottomT_max, bottomT_sd)) #Max temperature and variation in temperature are very correlated, but not mean temperature

GGally::ggpairs(modtab %>% select(current_mean, current_sd, current_max)) # all very correlated

Figure 7 - RDA OF COMPLEXITY ~ ENVIRONMENT

Box-Cox transformed explanatory variables

comprda <- modtab %>% 
  select(Branching_density, D_bin, D_gray, L, Maerl_density, Sphericity) %>% 
  rename("Branching density" = "Branching_density", "Dbin" = "D_bin", "Dgray"="D_gray", "Diameter" = "L", "Maerl density" = "Maerl_density")

comprda <- as.data.frame(scale(comprda))
boxcoxenv <-   env %>% 
  mutate(`Grain size` = boxcoxTransform(`Grain size`, boxcox(.$`Grain size`, optimize = TRUE )$lambda)) %>%
  mutate(Mud = boxcoxTransform(Mud, boxcox(.$Mud, optimize = TRUE )$lambda)) %>%
  mutate(Sand = boxcoxTransform(Sand, boxcox(.$Sand, optimize = TRUE )$lambda)) %>%
  mutate(Gravel = boxcoxTransform(Gravel, boxcox(.$Gravel, optimize = TRUE )$lambda)) %>%
  mutate(Current = boxcoxTransform(Current, boxcox(.$Current, optimize = TRUE )$lambda)) %>%
  mutate(Temperature = boxcoxTransform(Temperature, boxcox(.$Temperature, optimize = TRUE )$lambda)) %>%
  mutate(`Organic Matter` = boxcoxTransform(`Organic Matter`, boxcox(.$`Organic Matter`, optimize = TRUE )$lambda)) %>%
  mutate(Trask = boxcoxTransform(Trask, boxcox(.$Trask, optimize = TRUE )$lambda)) %>%
  mutate(Depth = boxcoxTransform(Depth, boxcox(.$Depth, optimize = TRUE )$lambda)) %>%
  mutate(Fetch = boxcoxTransform(Fetch, boxcox(.$Fetch, optimize = TRUE )$lambda)) %>% 
  select(`Grain size`,Mud, Sand, Gravel, Trask, Current, Fetch, Temperature, `Organic Matter`, Depth) %>% 
  aggregate(., by = list(env$mini, env$site, env$point_name), FUN = mean) %>% 
  rename(., mini = Group.1, site = Group.2, point_name = Group.3) %>% 
  set_rownames(paste( .$mini))

#check relationships between variables
GGally::ggpairs(boxcoxenv[-c(1:3)])

boxcoxenvrda <- bccomp %>%
  left_join(boxcoxenv)

boxcoxenvrdaSEL <- bccomp %>%
  select(mini, site, point_name) %>% 
  left_join(boxcoxenv) %>% 
  select(-mini, -site, -point_name, -`Grain size`, -`Gravel`, -`Organic Matter`)

forward.sel(comprda, boxcoxenvrdaSEL)
## Testing variable 1
## Testing variable 2
## Testing variable 3
## Testing variable 4
## Testing variable 5
## Testing variable 6
## Testing variable 7
## Procedure stopped (R2more criteria): variable 7 explains only 0.000649 of the variance.
##   variables order          R2     R2Cum  AdjR2Cum         F pvalue
## 1     Depth     7 0.148970925 0.1489709 0.1465937 62.667179  0.001
## 2       Mud     1 0.092033786 0.2410047 0.2367526 43.288887  0.001
## 3      Sand     2 0.036555997 0.2775607 0.2714727 18.013880  0.001
## 4     Trask     3 0.032817143 0.3103779 0.3026075 16.893433  0.001
## 5     Fetch     5 0.010908572 0.3212864 0.3117001  5.689638  0.001
## 6   Current     4 0.005248026 0.3265344 0.3150874  2.750777  0.026
(bccompenvirdaT <- rda(comprda ~ Mud + Sand + Fetch + Depth + Current + Trask, data = boxcoxenvrdaSEL, scale = TRUE))
## Call: rda(formula = comprda ~ Mud + Sand + Fetch + Depth + Current +
## Trask, data = boxcoxenvrdaSEL, scale = TRUE)
## 
##               Inertia Proportion Rank
## Total          6.0000     1.0000     
## Constrained    1.9592     0.3265    6
## Unconstrained  4.0408     0.6735    6
## Inertia is correlations 
## 
## Eigenvalues for constrained axes:
##   RDA1   RDA2   RDA3   RDA4   RDA5   RDA6 
## 1.1359 0.5846 0.1868 0.0442 0.0070 0.0007 
## 
## Eigenvalues for unconstrained axes:
##    PC1    PC2    PC3    PC4    PC5    PC6 
## 1.4536 0.9245 0.6992 0.4683 0.3296 0.1655
vif.cca(bccompenvirdaT)
##      Mud     Sand    Fetch    Depth  Current    Trask 
## 8.681866 1.412688 3.747179 2.896175 2.740505 6.212990
anova(bccompenvirdaT,permutations = how(nperm = 9999)) # the model is significant
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 9999
## 
## Model: rda(formula = comprda ~ Mud + Sand + Fetch + Depth + Current + Trask, data = boxcoxenvrdaSEL, scale = TRUE)
##           Df Variance      F Pr(>F)    
## Model      6   1.9592 28.526  1e-04 ***
## Residual 353   4.0408                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(R2a.all <- RsquareAdj(bccompenvirdaT)$adj.r.squared) #adjusted r-squared
## [1] 0.3150874
# pdf(file = "03_Figures/rda.pdf", width = 12.39, height = 10.01)

autoplot.rda.victor(bccompenvirdaT, metadata = modtab, scale.fill = pal, scale.colour = pal, thresh = 0, stat = "ellipse", lvl = .9, legend.position = c(.5,.9), title.size = 22, font.size = 22/.pt, ylim = c(-2,2.5), xlim = c(-2,2.5))+
  theme(legend.title = element_text(face = "bold", colour = "gray35", size = 22), legend.text = element_text(size = 20, colour = "gray35"), legend.direction = "horizontal", legend.background = element_blank(), legend.spacing.x = unit(0.5, "cm"), legend.box.background = element_blank(), legend.key = element_blank(), axis.text = element_text(size = 20)) + guides(fill = guide_legend(title.position = "top"))

# dev.off()

Figure 8 - Venn’s Diagram Variation Partitioning

varparbc <- varpart(Y = comprda, X = ~ Mud + Trask + Sand, ~ Fetch + Current, ~ Depth,  data = boxcoxenvrda, permutations = 9999)

varparbc
## 
## Partition of variance in RDA 
## 
## Call: varpart(Y = comprda, X = ~Mud + Trask + Sand, ~Fetch + Current,
## ~Depth, data = boxcoxenvrda, permutations = 9999)
## 
## Explanatory tables:
## X1:  ~Mud + Trask + Sand
## X2:  ~Fetch + Current
## X3:  ~Depth 
## 
## No. of explanatory tables: 3 
## Total variation (SS): 2154 
##             Variance: 6 
## No. of observations: 360 
## 
## Partition table:
##                       Df R.square Adj.R.square Testable
## [a+d+f+g] = X1         3  0.17551      0.16856     TRUE
## [b+d+e+g] = X2         2  0.13622      0.13138     TRUE
## [c+e+f+g] = X3         1  0.14897      0.14659     TRUE
## [a+b+d+e+f+g] = X1+X2  5  0.26914      0.25881     TRUE
## [a+c+d+e+f+g] = X1+X3  4  0.31038      0.30261     TRUE
## [b+c+d+e+f+g] = X2+X3  3  0.19155      0.18474     TRUE
## [a+b+c+d+e+f+g] = All  6  0.32653      0.31509     TRUE
## Individual fractions                                   
## [a] = X1 | X2+X3       3               0.13035     TRUE
## [b] = X2 | X1+X3       2               0.01248     TRUE
## [c] = X3 | X1+X2       1               0.05627     TRUE
## [d]                    0               0.02567    FALSE
## [e]                    0               0.07777    FALSE
## [f]                    0              -0.00291    FALSE
## [g]                    0               0.01546    FALSE
## [h] = Residuals                        0.68491    FALSE
## Controlling 1 table X                                  
## [a+d] = X1 | X3        3               0.15601     TRUE
## [a+f] = X1 | X2        3               0.12744     TRUE
## [b+d] = X2 | X3        2               0.03815     TRUE
## [b+e] = X2 | X1        2               0.09025     TRUE
## [c+e] = X3 | X1        1               0.13405     TRUE
## [c+f] = X3 | X2        1               0.05336     TRUE
## ---
## Use function 'rda' to test significance of fractions of interest
# pdf(file = "03_Figures/varpar.pdf", width = 20, height = 12)
plot(varparbc, digits = 2, bg = c("#02998B","#380142", "#e8bb5a"), lwd = 1.5, cex = 2, cutoff = 0.001)

# dev.off()

Supplementary material II: Adding sites as a factor to the RDA

## Check it with sites
(bccompenvirdaS <- rda(comprda ~ Mud + Fetch + Sand + Depth + Current + Trask + site, data = boxcoxenvrda, scale = TRUE))
## Call: rda(formula = comprda ~ Mud + Fetch + Sand + Depth + Current +
## Trask + site, data = boxcoxenvrda, scale = TRUE)
## 
##               Inertia Proportion Rank
## Total          6.0000     1.0000     
## Constrained    2.6243     0.4374    6
## Unconstrained  3.3757     0.5626    5
## Inertia is correlations 
## 
## Eigenvalues for constrained axes:
##   RDA1   RDA2   RDA3   RDA4   RDA5   RDA6 
## 1.4305 0.7506 0.2506 0.1231 0.0483 0.0212 
## 
## Eigenvalues for unconstrained axes:
##    PC1    PC2    PC3    PC4    PC5 
## 1.2796 0.8982 0.6551 0.3522 0.1905
anova(bccompenvirdaS,permutations = how(nperm = 9999))
## Permutation test for rda under reduced model
## Permutation: free
## Number of permutations: 9999
## 
## Model: rda(formula = comprda ~ Mud + Fetch + Sand + Depth + Current + Trask + site, data = boxcoxenvrda, scale = TRUE)
##           Df Variance      F Pr(>F)    
## Model     15   2.6243 17.828  1e-04 ***
## Residual 344   3.3757                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(R2a.allS <- RsquareAdj(bccompenvirdaS)$adj.r.squared) #added 10% of explained variation in comparison to the model without sites, but could be biased due to influence of currents that are basically the same in points of each site and maerl densities which are at the site level.
## [1] 0.4128501
# pdf(file = "03_Figures/rda.pdf", width= 16, height=11.25)

autoplot.rda.victor(bccompenvirdaS, metadata = modtab, scale.fill = pal, scale.colour = pal, thresh = 0, stat = "ellipse", lvl = .9, legend.position = c(.4,.9), ylim = c(-2,2.5), xlim = c(-2,2.5))+
  theme(legend.title = element_text(face = "bold", colour = "gray35", size = 14), legend.text = element_text(size = 14, colour = "gray35"), legend.direction = "horizontal", legend.background = element_blank(), legend.box.background = element_blank(), legend.key = element_blank(), ) + guides(fill = guide_legend(title.position = "top"))

# dev.off()

(varparbcS <- varpart(Y = comprda, X = ~ Mud + Trask + Sand, ~ Fetch + Current, ~ Depth, ~site,  data = boxcoxenvrda, permutations = 9999))
## 
## Partition of variance in RDA 
## 
## Call: varpart(Y = comprda, X = ~Mud + Trask + Sand, ~Fetch + Current,
## ~Depth, ~site, data = boxcoxenvrda, permutations = 9999)
## 
## Explanatory tables:
## X1:  ~Mud + Trask + Sand
## X2:  ~Fetch + Current
## X3:  ~Depth
## X4:  ~site 
## 
## No. of explanatory tables: 4 
## Total variation (SS): 2154 
##             Variance: 6 
## No. of observations: 360 
## 
## Partition table:
##                             Df R.square Adj.R.square Testable
## [aeghklno] = X1              3  0.17551      0.16856     TRUE
## [befiklmo] = X2              2  0.13622      0.13138     TRUE
## [cfgjlmno] = X3              1  0.14897      0.14659     TRUE
## [dhijkmno] = X4              9  0.41594      0.40092     TRUE
## [abefghiklmno] = X1+X2       5  0.26914      0.25881     TRUE
## [acefghjklmno] = X1+X3       4  0.31038      0.30261     TRUE
## [adeghijklmno] = X1+X4      12  0.43019      0.41049     TRUE
## [bcefgijklmno] = X2+X3       3  0.19155      0.18474     TRUE
## [bdefhijklmno] = X2+X4      11  0.42098      0.40267     TRUE
## [cdfghijklmno] = X3+X4      10  0.41899      0.40234     TRUE
## [abcefghijklmno] = X1+X2+X3  6  0.32653      0.31509     TRUE
## [abdefghijklmno] = X1+X2+X4 14  0.43201      0.40896     TRUE
## [acdefghijklmno] = X1+X3+X4 13  0.43430      0.41305     TRUE
## [bcdefghijklmno] = X2+X3+X4 12  0.42376      0.40383     TRUE
## [abcdefghijklmno] = All     15  0.43738      0.41285     TRUE
## Individual fractions                                         
## [a] = X1 | X2+X3+X4          3               0.00902     TRUE
## [b] = X2 | X1+X3+X4          2              -0.00020     TRUE
## [c] = X3 | X1+X2+X4          1               0.00389     TRUE
## [d] = X4 | X1+X2+X3          9               0.09776     TRUE
## [e]                          0               0.00168    FALSE
## [f]                          0              -0.00133    FALSE
## [g]                          0              -0.00273    FALSE
## [h]                          0               0.12133    FALSE
## [i]                          0               0.01268    FALSE
## [j]                          0               0.05239    FALSE
## [k]                          0               0.02398    FALSE
## [l]                          0               0.00160    FALSE
## [m]                          0               0.07910    FALSE
## [n]                          0              -0.00018    FALSE
## [o]                          0               0.01386    FALSE
## [p] = Residuals              0               0.58715    FALSE
## Controlling 2 tables X                                       
## [ae] = X1 | X3+X4            3               0.01070     TRUE
## [ag] = X1 | X2+X4            3               0.00629     TRUE
## [ah] = X1 | X2+X3            3               0.13035     TRUE
## [be] = X2 | X3+X4            2               0.00149     TRUE
## [bf] = X2 | X1+X4            2              -0.00152     TRUE
## [bi] = X2 | X1+X3            2               0.01248     TRUE
## [cf] = X3 | X1+X4            1               0.00256     TRUE
## [cg] = X3 | X2+X4            1               0.00116     TRUE
## [cj] = X3 | X1+X2            1               0.05627     TRUE
## [dh] = X4 | X2+X3            9               0.21909     TRUE
## [di] = X4 | X1+X3            9               0.11044     TRUE
## [dj] = X4 | X1+X2            9               0.15015     TRUE
## Controlling 1 table X                                        
## [aghn] = X1 | X2             3               0.12744     TRUE
## [aehk] = X1 | X3             3               0.15601     TRUE
## [aegl] = X1 | X4             3               0.00957     TRUE
## [bfim] = X2 | X1             2               0.09025     TRUE
## [beik] = X2 | X3             2               0.03815     TRUE
## [befl] = X2 | X4             2               0.00175     TRUE
## [cfjm] = X3 | X1             1               0.13405     TRUE
## [cgjn] = X3 | X2             1               0.05336     TRUE
## [cfgl] = X3 | X4             1               0.00142     TRUE
## [dijm] = X4 | X1             9               0.24193     TRUE
## [dhjn] = X4 | X2             9               0.27130     TRUE
## [dhik] = X4 | X3             9               0.25575     TRUE
## ---
## Use function 'rda' to test significance of fractions of interest
#pdf(file = "03_Figures/varpar.pdf", width = 20)
plot(varparbcS, digits = 2, bg = c("#02998B","#380142", "#e8bb5a", "black"), cutoff = 0.001)

#dev.off()