2 Breakpoint Analysis

This is a breakpoint analysis in R for metal(loid) data obtained from individual coring sites. I used data containing more than 20 metals, and their concentrations at each depth of the impacted core.

My data files can be found in the Github repo, called FileS7_Metalloids_CSM-IMP.csv and FileS8_Metalloids_CSM-REF.csv. Access the files here.

2.1 Getting Started

Begin by installing all the required packages using install/packages() if you haven’t already.

Once installed, load the packages in R

#load the tidy libraries

library(tidyverse)
library(tidypaleo)
library(vegan)

2.2 Load and prepare the data

Load your data for impact and reference sites into R

metals_IMP <- read.csv("Data/FileS6_Metalloids_CSM-IMP.csv")
metals_REF <- read.csv("Data/FileS7_Metalloids_CSM-REF.csv")

Transform the data into long format

metals_long_IMP <- metals_IMP %>%
  pivot_longer(!depth, names_to = "metals", values_to = "concentration")

Make sure depth column is numeric

metals_long_IMP$depth <- as.numeric(metals_long_IMP$depth)

2.3 Plot the data

2.3.1 Plot CONISSS

Run the stratigraphically constrained cluster analysis on your data (CONISS)

nested_coniss_IMP <- metals_long_IMP %>%
  nested_data(depth, metals, concentration) %>%
  nested_chclust_coniss()

Plot the cluster analysis results

plot(nested_coniss_IMP)

2.3.2 Plot a broken stick diagram

broken_stick_plot <- nested_coniss_IMP %>%
  select(broken_stick) %>%
  unnest(broken_stick) %>%
  tidyr::gather(type, value, broken_stick_dispersion, dispersion) %>%
  ggplot(aes(x = n_groups, y = value, col = type)) +
  geom_line() +
  geom_point()

2.4 Final Figure

[Bosch et al. 2024]: Dendrogram (LEFT) showing the distinct breakpoints in the metal(loid)s data across the core depth (cm) of CSM-IMP-2, and a line plot (RIGHT) showing the broken stick dispersion plot for the breakpoint analysis, where value is a measure of the magnitude of the variable being analyzed. Created using the tidyverse and tidypaleo packages available in R (v.4.2.1) software.

Figure 2.1: [Bosch et al. 2024]: Dendrogram (LEFT) showing the distinct breakpoints in the metal(loid)s data across the core depth (cm) of CSM-IMP-2, and a line plot (RIGHT) showing the broken stick dispersion plot for the breakpoint analysis, where value is a measure of the magnitude of the variable being analyzed. Created using the tidyverse and tidypaleo packages available in R (v.4.2.1) software.