About

A team of scientists have been sampling stream chemistry in the Santa Barbara Coastal drainage area since 2000. Stream chemistry is important to monitor as streams reach the ocean and can transport chemicals like nitrate, ammonium, and reactive phosphorous. Below is a dendogram using agglomerative hierarchical clustering of each stream site.

# Read in data
stream_data <- read_csv(here("data", "sbc_lter_registered_stream_chemistry.csv"))

# Convert to NAs
stream_data[stream_data == -999.0] <- NA

# Find means for all variables for each site
stream_means <- stream_data %>% 
  group_by(site_code) %>% 
  summarize(across(nh4_uM:spec_cond_uSpercm, mean, na.rm = TRUE))
# Explore the data

# exploratory plot # 1 - total dissolved N vs total dissolved P
ggplot(stream_means) +
  geom_point(aes(x = tdn_uM,
                 y = tdp_uM,
                 color = site_code, 
                 alpha = 0.7)) +
  labs(title = "Total dissolved N vs total dissolved P")
# No definitive clusters
 ## ---------------------------------------------------------------------------

# exploratory plot # 2 - total particulate C vs total particulate N
ggplot(stream_means) +
  geom_point(aes(x = tpc_uM,
                 y = tpn_uM,
                 color = site_code, 
                 alpha = 0.7)) +
  labs(title = "Total particulate C vs total particulate N")
# potentially 3 clusters, but not definitive
 ## ---------------------------------------------------------------------------

# exploratory plot # 3 - total dissolved N (or P) vs total suspended solids
ggplot(stream_means) +
  geom_point(aes(x = tdp_uM,
                 y = tss_mgperLiter,
                 color = site_code, 
                 alpha = 0.7)) +
  labs(title = "Total dissolved N vs total suspended solids")
# No definitive clusters

Dendrogram

# Scale the data
stream_means_scaled <- stream_means %>% 
  select(2:11) %>% 
  scale()

# assign the site_code back into the data
rownames(stream_means_scaled) <- stream_means$site_code

# Calculate the Euclidean distance
euc_distance <- dist(stream_means_scaled, method = "euclidean")
# view(euc_distance)

# Hierarchical clustering with complete linkage
hc_complete <- hclust(euc_distance, method = "complete")

# plot
# plot(hc_complete, cex = 0.6, hang = -1)

# Make the dendogram using ggdendrogram
ggdendrogram(hc_complete,
             rotate = TRUE) +
  theme_minimal() + 
  labs(x = "Stream Site",
       y = "")
**Figure 1.** A hierarchical dendrogram of sampled stream sites in the Santa Barbara Coustal Drainage Area. Measurements include various forms of dissolved N; soluble reactive P; and particulates of C, N, and P; suspended sediments; and conductivity.

Figure 1. A hierarchical dendrogram of sampled stream sites in the Santa Barbara Coustal Drainage Area. Measurements include various forms of dissolved N; soluble reactive P; and particulates of C, N, and P; suspended sediments; and conductivity.

Data Citation: Santa Barbara Coastal LTER and J. Melack. 2019. SBC LTER: Land: Stream chemistry in the Santa Barbara Coastal drainage area, ongoing since 2000 ver 16. Environmental Data Initiative.