1 Set up

1.1 1) Load packages

1.2 2) Import data

#import data
soilhealth <- read_excel("7-30-21 part 11 nrcs soil health final data.xlsx")

soilhealth$bdepth=as.numeric(soilhealth$bdepth)

1.3 3) Data Wrangling

#change column names
soilhealth1 <- soilhealth %>% 
  clean_names()
#str(soilhealth)
#View(soilhealth)
#names(soilhealth1)

soilhealth1 <- as.data.frame(soilhealth1)

# keeps aggregate data
agg <- soilhealth1 %>%
  dplyr::select(location, treatment, bdepth, horizon, blk, replication, x20wsa2000, x20wsa250, x20wsa53, x20wsa20, x20mwd, x5wsa2000, x5wsa250, x5wsa53, x5wsa20, x5mwd, nagg)

soils <- agg %>%
    filter(location!="Ottawa", treatment!="IR")


agg$location_f =factor(agg$location, levels=c('Tribune', 'Hays', 'Manhattan'))
#str(agg)
#View(agg)

agg1 <- agg%>%
  filter(horizon=="1", location!="Ottawa", treatment!="IR")

agg2 <- agg%>%
  filter(horizon=="2", location!="Ottawa", treatment!="IR")

agg3 <- agg%>%
  filter(horizon=="3", location!="Ottawa", treatment!="IR")

agg4 <- agg%>%
  filter(horizon=="4", location!="Ottawa", treatment!="IR")

aggmwd <- agg %>%
  filter(location!="Ottawa", treatment!="IR") %>%
  na.omit()

agg1$location_f =factor(agg1$location, levels=c('Tribune', 'Hays', 'Manhattan'))

1.4 4) Theme James Bar

theme_James <- function(base_size=14, base_family="TT Times New Roman") {
  (theme_foundation(base_size=base_size, base_family=base_family)+
      theme_bw()+ 
      theme(panel.background = element_rect(colour = NA),
            plot.background = element_rect(colour = NA),
            axis.title = element_text(color="black",size=rel(1.2)),
            axis.text = element_text(color="black", size = 12),
            legend.key = element_rect(colour = NA),
            legend.spacing = unit(0, "cm"),
            legend.text = element_text(size=12),
            legend.title = element_blank(),
            panel.grid = element_blank(),
            plot.title = element_text(color="Black",size = rel(1.5),face = "bold",hjust = 0.5),
            strip.text = element_text(color="Black",size = rel(1),face="bold")
      ))
}

1.5 5) Theme James Correlation

theme_James2 <- function(base_size=14, base_family="TT Times New Roman") {
  (theme_foundation(base_size=base_size, base_family=base_family)+
      theme_bw()+ 
      theme(panel.background = element_rect(colour = NA),
            plot.background = element_rect(colour = NA),
            axis.title = element_text(color="black",size=rel(1.2)),
            axis.text = element_text(color="black", size = 12),
            legend.key = element_rect(colour = NA),
            legend.spacing = unit(0, "cm"),
            legend.text = element_text(size=12),
            panel.grid = element_blank(),
            plot.title = element_text(color="Black",size = rel(1.5),face = "bold",hjust = 0.5),
            strip.text = element_text(color="Black",size = rel(1),face="bold")
      ))
}

2 Correlation Matrix

names(agg)
##  [1] "location"    "treatment"   "bdepth"      "horizon"     "blk"        
##  [6] "replication" "x20wsa2000"  "x20wsa250"   "x20wsa53"    "x20wsa20"   
## [11] "x20mwd"      "x5wsa2000"   "x5wsa250"    "x5wsa53"     "x5wsa20"    
## [16] "x5mwd"       "nagg"        "location_f"
aggmatrix <- agg %>%
  filter(location!="Ottawa", treatment!="IR") %>% 
  dplyr::select(-location, -treatment, -bdepth, -horizon, -blk, -replication) %>%
  dplyr::select(where(is.numeric)) %>% drop_na()

aggmatrix <- na.omit(aggmatrix)



aggmatrix1 <- aggmatrix[, c(5,1,2,3,4,10,6,7,8,9,11)]

#aggmatrix1

aggmat <- cor(aggmatrix1, method = "spearman")
#aggmat

#library("writexl")
#aggmatdf <- as.data.frame(aggmat)
#write_xlsx(aggmatdf,"aggmatdf.xlsx")

library("PerformanceAnalytics")

chart.Correlation(aggmatrix1, histogram = TRUE, pch = 19, method="spearman")

# use exact=FALSE

chart.Correlation(aggmatrix1, histogram = TRUE, pch = 19, method="spearman", exact=FALSE)

colnames(aggmat) <- c( "20 min MWD","20 min 2 mm", "20 min 0.250 mm", "20 min 0.053 mm", "20 min 0.020 mm", "5 min MWD", "5 min 2 mm", "5 min 0.25 mm", "5 min 0.053 mm", "5 min 0.020 mm", "NRCS")

rownames(aggmat) <- c( "20 min MWD","20 min 2 mm", "20 min 0.250 mm", "20 min 0.053 mm", "20 min 0.020 mm", "5 min MWD", "5 min 2 mm", "5 min 0.25 mm", "5 min 0.053 mm", "5 min 0.020 mm", "NRCS")

corrplot(aggmat, method = "square", tl.col = "black", type = "lower", tl.srt = 45, tl.cex = 0.7)

#corrplot.mixed(aggmat, lower.col = "black", number.cex = .7)

#corrplot(aggmat, type = "lower")

corrplot(aggmat, method = "pie",type = "lower", tl.srt = 20, tl.col="black")

#head(p.matr[,])
# cl.* is for color legend, and tl.* if for text legend.

res1<- cor.mtest(aggmat, conf.level=0.95)

#Significance level
fcor <- corrplot(aggmat, method = "pie",type = "upper", tl.srt = 20, tl.col="black", p.mat=res1$p, sig.level = 0.05, title = "Spearman Correlation Matrix p > 0.05")

corrplot(aggmat, method = "number",type = "upper", tl.srt = 20, tl.col="black", p.mat=res1$p, sig.level = 0.05, title = "Spearman Correlation Matrix p > 0.05")

3 Methods Comparison

3.1 Data Manipulation

#remove Ottawa and irrigation dataset since 5MWD isnt available
# data frame for (20 minutes vs 5 minutes) & (5 minutes vs NRCS)- only has 4 horizons
soils <- agg %>%
  filter(location!="Ottawa", treatment!="IR") %>%
  na.omit()

soils$location_a =factor(soils$location, levels=c('Tribune', 'Hays', 'Manhattan'))

soils$horizon_a =factor(soils$horizon, levels=c('1', '2', '3', '4'))


# data frame for 20 minutes vs NRCS- has all horizons
soils_b <- agg %>%
  dplyr::select(-x5mwd, -x5wsa2000, -x5wsa250, -x5wsa53, -x5wsa20) %>%
  dplyr::filter(location!="Ottawa", treatment!="IR") %>%
  na.omit()

soils_b$location_b =factor(soils_b$location, levels=c('Tribune', 'Hays', 'Manhattan'))

soils_b$horizon_b =factor(soils_b$horizon, levels=c('1', '2', '3', '4', '5', '6', '7'))

3.2 20mwd and 5mwd Correlation graphs

use soils data frame and location_a and horizon_a

#20 minute Mean Weight Diameter vs 5 minute Method

ggplot(soils, aes(x=x20mwd, y= x5mwd))+
  geom_point(size=.5)+
  labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD") +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  theme_James() +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.1, label.y=3.4,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=3)

#cor(soils$x20mwd, soils$x5mwd, method="spearman", use="complete.obs")

#One graph by location

soils %>%
ggplot(aes(x=x20mwd, y= x5mwd, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
  theme_James() +
   stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)

#group by location

soils %>%
ggplot(aes(x=x20mwd, y= x5mwd))+
  facet_wrap(~location_a)+
  labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD by Location") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
  theme_James() +
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)

# just to find p value for tribune 

soils %>%
ggplot(aes(x=x20mwd, y= x5mwd))+
  facet_wrap(~location_a)+
  labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD by Location") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
  theme_James() +
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  show.legend = F)+
  stat_regline_equation(label.x=.5, show.legend = F)

3.2.1 Correlation plots for group depths

#20 minute Mean Weight Diameter vs 5 minute Method
#group by location



soils %>%
ggplot(aes(x=x20mwd, y= x5mwd, color=treatment))+
  facet_wrap(~location_a)+
  labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
soils %>%
ggplot(aes(x=x20mwd, y= x5mwd, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
    stat_regline_equation(label.x=1.3, show.legend = F)

   #ggsave("20min5mincor.png",  height=6, width=9)



#Has correlation by treatment by location and has eclipses

soils %>%
ggplot(aes(x=x20mwd, y= x5mwd, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
geom_mark_ellipse(expand=0, aes(fill=treatment), show.legend = F)

## 8-2 mm 20 and 5 Correlation graphs use soils data frame and location_a and horizon_a

#20 minute  vs 5 minute Method 8-2 mm

ggplot(soils, aes(x=x20wsa2000, y= x5wsa2000))+
  geom_point(size=.5)+
  labs(x="20 Minute Method (%)", 
       y="5 Minute Method (%)",
       title="Correlation between 20 vs 5 minute 8-2 mm") +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  theme_James() +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.1, label.y=50,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=45)

#cor(soils$x20wsa2000, soils$x5wsa2000, method="spearman", use="complete.obs")

#One graph by location

soils %>%
ggplot(aes(x=x20wsa2000, y= x5wsa2000, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(x="20 Minute Method (%)", 
       y="5 Minute Method (%)",
       title="Correlation between 20 vs 5 minute 8-2 mm ") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
  theme_James() +
   stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=9, show.legend = F)

#group by location

soils %>%
ggplot(aes(x=x20wsa2000, y= x5wsa2000))+
  facet_wrap(~location_a)+
  labs(x="20 Minute Method (%)", 
       y="5 Minute Method (%)",
       title="Correlation between 20 vs 5 minute 8-2 mm by Location") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
  theme_James() +
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)

# just to find p value for tribune 

soils %>%
ggplot(aes(x=x20wsa2000, y= x5wsa2000))+
  facet_wrap(~location_a)+
  labs(x="20 Minute Method (%)", 
       y="5 Minute Method (%)",
       title="Correlation between 20 vs 5 minute 8-2 mm by Location") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
  theme_James() +
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  show.legend = F)+
  stat_regline_equation(label.x=.5, show.legend = F)

## 2-0.25 mm 20 and 5 Correlation graphs use soils data frame and location_a and horizon_a

#20 minute  vs 5 minute Method 8-2 mm

ggplot(soils, aes(x=x20wsa250, y= x5wsa250))+
  geom_point(size=.5)+
  labs(x="20 Minute Method (%)", 
       y="5 Minute Method (%)",
       title="Correlation between 20 vs 5 minute 2-0.25 mm") +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  theme_James() +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.1, label.y=70,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=65)

#cor(soils$x20wsa2000, soils$x5wsa2000, method="spearman", use="complete.obs")

#One graph by location

soils %>%
ggplot(aes(x=x20wsa250, y= x5wsa250, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(x="20 Minute Method (%)", 
       y="5 Minute Method (%)",
       title="Correlation between 20 vs 5 minute 2-0.25 mm ") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
  theme_James() +
   stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=14, show.legend = F)

#group by location

soils %>%
ggplot(aes(x=x20wsa250, y= x5wsa250))+
  facet_wrap(~location_a)+
  labs(x="20 Minute Method (%)", 
       y="5 Minute Method (%)",
       title="Correlation between 20 vs 5 minute 2-0.25 mm by Location") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
  theme_James() +
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)

# just to find p value for tribune 

soils %>%
ggplot(aes(x=x20wsa250, y= x5wsa250))+
  facet_wrap(~location_a)+
  labs(x="20 Minute Method (%)", 
       y="5 Minute Method (%)",
       title="Correlation between 20 vs 5 minute 2-0.25 mm by Location") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
  theme_James() +
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  show.legend = F)+
  stat_regline_equation(label.x=.5, show.legend = F)

3.2.2 end of 8-2 mm

3.3 20mwd and NRCS Correlation graphs

use soils_b data frame and location_b and horizon_b

#20 minute Mean Weight Diameter vs NRCS Hand Method

soils_b %>%
ggplot(aes(x=x20mwd, y= nagg))+
  geom_point(size=.5)+
  labs(x="20 minute method (mm)", 
       y="NRCS Hand Method (%)",
       title="Correlation between 20 Minute MWD vs NRCS") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE) +
  theme_James() +
  stat_cor(aes(label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.1, label.y=85,  p.accuracy = 0.001) +
    stat_regline_equation(label.y=75)

#One graph by location

soils_b %>%
ggplot(aes(x=x20mwd, y= nagg, color=location_b, shape=location_b))+
  geom_point(size=1)+
  labs(x="20 minute method (mm)", 
       y="NRCS Hand Method (%)",
       title="Correlation between 20 Minute MWD vs NRCS") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE) +
  theme_James() +
   stat_cor(aes(color=location_b, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
    stat_regline_equation(label.x=.5, show.legend = F)

#group by location

soils_b %>%
ggplot(aes(x=x20mwd, y= nagg))+
  facet_wrap(~location_b)+
  labs(x="20 Minute Method (mm)", 
       y="NRCS Hand Method (%)",
       title="Correlation between 20 Minute MWD vs NRCS by Location") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5) +
  theme_James() +
     stat_cor(aes(color=location_b, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
    stat_regline_equation(label.x=.5, show.legend = F)

3.3.1 Correlation plots for group depths

#20 minute Mean Weight Diameter vs NRCS
#group by location



soils_b %>%
ggplot(aes(x=x20mwd, y= nagg, color=treatment))+
  facet_wrap(~location_b)+
  labs(x="20 Minute Method (mm)", 
       y="NRCS Hand Method (%)",
       title="Correlation between 20 Minute MWD vs NRCS by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,100)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
soils_b %>%
ggplot(aes(x=x20mwd, y= nagg, color=treatment))+
  facet_wrap(~location_b)+
     stat_cor(aes(label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ labs(x="20 Minute Method (mm)", 
       y="NRCS Hand Method (%)",
       title="Correlation between 20 Minute MWD vs NRCS by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,100)) +
  theme_classic()+
  geom_point(size=2, aes(shape=horizon_b))+
      scale_shape_manual(values=c(19, 17, 15, 3, 7, 8, 10)) +
  theme_James2() +
      stat_regline_equation(label.x=1.3, show.legend = F)

   ggsave("20minNRCScor.png",  height=6, width=9)



#Has correlation by treatment by location and has eclipses

soils_b %>%
ggplot(aes(x=x20mwd, y= nagg, color=treatment))+
  facet_wrap(~location_b)+
     stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ labs(x="20 Minute Method (mm)", 
       y="NRCS Hand Method (%)",
       title="Correlation between 20 Minute MWD vs NRCS by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,100)) +
  theme_classic()+
  geom_point(size=2, aes(shape=horizon_b), na.rm = T)+
    scale_shape_manual(values=c(19, 17, 15, 3, 7, 8, 10)) +
  theme_James2() +
geom_mark_ellipse(expand=0, aes(fill=treatment), show.legend = F)

3.4 NRCS and 5mwd Correlation graphs

use soils data frame and location_a and horizon_a

#NRCS vs 5 minute Method

soils %>%
ggplot(aes(x=nagg, y= x5mwd))+
  geom_point(size=.5)+
  labs(x="NRCS Hand Method (%)",
       y="5 Minute Method (mm)",
       title="Correlation between NRCS vs 5 minute MWD") +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  theme_James() +
  stat_cor(aes(label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=1, label.y=3.4,  p.accuracy = 0.001, show.legend = F) +
    stat_regline_equation(label.y=3)

#One graph by location

soils %>%
ggplot(aes(x=nagg, y= x5mwd, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(x="NRCS Hand Method (%)", 
       y="5 Minute Method (mm)",
       title="Correlation between NRCS vs 5 minute MWD") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
  theme_James() +
   stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
    stat_regline_equation(label.x=15, show.legend = F)

#group by location

soils %>%
ggplot(aes(x=nagg, y= x5mwd))+
  facet_wrap(~location_a)+
  labs(x="NRCS Hand Method (%)", 
       y="5 Minute Method (mm)",
       title="Correlation between NRCS vs 5 minute MWD by Location") +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
  theme_James() +
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
    stat_regline_equation(label.x=.5, show.legend = F)

3.4.1 Correlation plots for group depths

#NRCS vs 5 minute Method
#group by location



soils %>%
ggplot(aes(x=nagg, y= x5mwd, color=treatment))+
  facet_wrap(~location_a)+
  labs(x="NRCS Hand Method (%)", 
       y="5 Minute Method (mm)",
       title="Correlation between NRCS vs 5 minute MWD by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
soils %>%
ggplot(aes(x=nagg, y= x5mwd, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ labs(x="NRCS Hand Method (%)", 
       y="5 Minute Method (mm)",
       title="Correlation between NRCS vs 5 minute MWD by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
    stat_regline_equation(label.x=30, show.legend = F) 

   ggsave("NRCS5mincor.png",  height=6, width=9)



#Has correlation by treatment by location and has eclipses

soils %>%
ggplot(aes(x=nagg, y= x5mwd, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ labs(x="NRCS Hand Method (%)", 
       y="5 Minute Method (mm)",
       title="Correlation between NRCS vs 5 minute MWD by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
geom_mark_ellipse(expand=0, aes(fill=treatment), show.legend = F)

3.5 MWD Bland-Altman plots

library(BlandAltmanLeh)

nrcs <-as.numeric(soils$nagg, na.rm=FALSE)
n20mwd <- as.numeric(soils$x20mwd, na.rm=FALSE)
n5mwd <- as.numeric(soils$x5mwd, na.rm=FALSE)

#Bland-Altman Plots for 20 minute Mean Weight Diameter vs NRCS Hand Method

soils %>%
ggplot(aes(x=((x20mwd+nagg)/2), y= (x20mwd-nagg)))+
  geom_point(size=.5)+
  labs(x="20 minute method", 
       y="NRCS hand method",
       title="Bland-Altman Plots for 20 minute Mean Weight Diameter vs NRCS Hand Method") +
  theme_classic()

bland.altman.plot(n20mwd, nrcs, xlab="Means", ylab="Differences", na.rm=FALSE)

## NULL
#Bland-Altman Plots for 20 minute Mean Weight Diameter vs 5 minute Method

soils %>%
ggplot(aes(x=((x20mwd+x5mwd)/2), y= (x5mwd-x20mwd)))+
  geom_point(size=.5)+
  labs(x="Means", 
       y="Differences",
       title="Bland-Altman Plots for 20 minute Mean Weight Diameter vs 5 minute Method") +
  theme_classic()

bland.altman.plot(n5mwd, n20mwd, xlab="Means", ylab="Differences")

## NULL
modmwd <- lm(x5mwd ~ x20mwd, data=soils)
summary(modmwd)
## 
## Call:
## lm(formula = x5mwd ~ x20mwd, data = soils)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.80351 -0.29802 -0.05178  0.24953  1.69249 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.47932    0.08718   5.498  1.8e-07 ***
## x20mwd       0.77334    0.07969   9.704  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5395 on 138 degrees of freedom
## Multiple R-squared:  0.4056, Adjusted R-squared:  0.4013 
## F-statistic: 94.17 on 1 and 138 DF,  p-value: < 2.2e-16

3.5.1 Correlation plots for group depths

#20 minute Mean Weight Diameter vs 5 minute Method
#group by location



soils %>%
ggplot(aes(x=x20mwd, y= x5mwd, color=treatment))+
  facet_wrap(~location_a)+
  labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
soils %>%
ggplot(aes(x=x20mwd, y= x5mwd, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2()

#Has correlation by treatment by location and has eclipses

soils %>%
ggplot(aes(x=x20mwd, y= x5mwd, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ labs(x="20 Minute Method (mm)", 
       y="5 Minute Method (mm)",
       title="Correlation between 20 vs 5 minute MWD by Location", shape="Horizon", color="Treatment") +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
geom_mark_ellipse(expand=0, aes(fill=treatment), show.legend = F)

4 Regression

5 Data wrangling

reg <- soilhealth1 %>%
  dplyr::filter(location!="Ottawa", treatment!="IR", bdepth<=15) %>%
  dplyr::select(location, treatment, bdepth, horizon, blk, replication, x20wsa2000, x20wsa250, x20wsa53, x20wsa20, x20mwd, x5wsa2000, x5wsa250, x5wsa53, x5wsa20, x5mwd, nagg, amf,fungi, mb)

 reg$location_a =factor(reg$location, levels=c('Tribune', 'Hays', 'Manhattan'))

reg$horizon_a =factor(reg$horizon, levels=c('1', '2', '3'))

5.1 20mwd and AMF Correlation graphs

ggplot(reg, aes(y=x20mwd, x= amf))+
  geom_point(size=.5)+
  labs(y="Mean Weight Diameter (mm)",
       title="Correlation between AMF and MWD") +
    xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.3, label.y=3,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=2.5, label.x=.3) +
 theme_James() 

#cor(soils$x20mwd, soils$x5mwd, method="spearman", use="complete.obs")

#One graph by location

ggplot(reg, aes(y=x20mwd, x= amf, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(y="Mean Weight Diameter (mm)", 
       title="Correlation between AMF and MWD") +
      xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
   stat_cor(aes(color=location_a, label = paste(..r.label..,..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=5, show.legend = F) +
  theme_James() 

   ggsave("mwd_amf1.png",  height=5, width=9)

#group by location

reg %>%
ggplot(aes(y=x20mwd, x= amf))+
  facet_wrap(~location_a)+
  labs(y="Mean Weight Diameter (mm)", 
       title="Correlation between AMF and MWD") +
        xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)+
 theme_James() 

5.1.1 MWD vs AMF Correlation plots for group depths

#20 minute Mean Weight Diameter vs 5 minute Method
#group by location



reg %>%
ggplot(aes(x=amf, y= x20mwd, color=treatment))+
  facet_wrap(~location_a)+
  labs(y="Mean Weight Diameter (mm)",
       title="Correlation between AMF and MWD by Location", shape="Horizon", color="Treatment") +
    xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
reg %>%
ggplot(aes(y=x20mwd, x= amf, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..r.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ 
  labs(y="Mean Weight Diameter (mm)",
       title="Correlation between AMF and MWD", shape="Horizon", color="Treatment") +
      xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
    stat_regline_equation(label.x=8, show.legend = F)

   ggsave("mwd_amfcor.png",  height=5, width=9)

5.2 20mwd and MB Correlation graphs

ggplot(reg, aes(y=x20mwd, x= mb))+
  geom_point(size=.5)+
  labs(y="Mean Weight Diameter (mm)",
       title="Correlation between Microbial Biomass and MWD") +
    xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.3, label.y=3,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=2.5, label.x=.3) +
 theme_James() 

#One graph by location

ggplot(reg, aes(y=x20mwd, x= mb, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(y="Mean Weight Diameter (mm)", 
       title="Correlation between Microbial Biomass and MWD") +
      xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
   stat_cor(aes(color=location_a, label = paste(..r.label..,..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=50, show.legend = F) +
  theme_James() 

   ggsave("mwd_mb1.png",  height=5, width=9)


#group by location

reg %>%
ggplot(aes(y=x20mwd, x= mb))+
  facet_wrap(~location_a)+
  labs(y="Mean Weight Diameter (mm)", 
       title="Correlation between Microbial Biomass and MWD") +
        xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)+
 theme_James() 

5.2.1 MWD vs MB Correlation plots for group depths

reg %>%
ggplot(aes(x=mb, y= x20mwd, color=treatment))+
  facet_wrap(~location_a)+
  labs(y="Mean Weight Diameter (mm)",
       title="Correlation between Microbial Biomass and MWD", shape="Horizon", color="Treatment") +
    xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
reg %>%
ggplot(aes(y=x20mwd, x= mb, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..r.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ 
  labs(y="Mean Weight Diameter (mm)",
       title="Correlation between Microbial Biomass and MWD", shape="Horizon", color="Treatment") +
      xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,5)) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
    stat_regline_equation(label.x=50, show.legend = F)

   ggsave("mwd_mbcor.png",  height=5, width=9)

5.3 20mwd and Fungi Correlation graphs

#20 minute Mean Weight Diameter vs 5 minute Method

ggplot(reg, aes(x=x20mwd, y= fungi))+
  geom_point(size=.5)+
  labs(x="Mean Weight Diameter (mm)",
       title="Correlation between MWD and Fungi") +
  ylab(expression(~Saprophytic ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.3, label.y=3,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=4, label.x=.3) +
 theme_James() 

#cor(soils$x20mwd, soils$x5mwd, method="spearman", use="complete.obs")

#One graph by location

ggplot(reg, aes(x=x20mwd, y= fungi, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(x="Mean Weight Diameter (mm)", 
       title="Correlation between MWD and Fungi") +
  ylab(expression(~Saprophytic ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
   stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F) +
  theme_James() 

#group by location

reg %>%
ggplot(aes(x=x20mwd, y= fungi))+
  facet_wrap(~location_a)+
  labs(x="Mean Weight Diameter (mm)", 
       title="Correlation between MWD vs Fungi") +
  ylab(expression(~Saprophytic ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)+
 theme_James() 

5.4 8-2 mm and AMF Correlation graphs

#20 minute Mean Weight Diameter vs 5 minute Method

ggplot(reg, aes(y=x20wsa2000, x= amf))+
  geom_point(size=.5)+
  labs(y="Percent  8-2 mm Aggregate fraction(%)",
       title="Correlation between 8-2 mm fraction and AMF") +
    xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.3, label.y=35,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=30, label.x=.3) +
 theme_James() 

#cor(soils$x20mwd, soils$x5mwd, method="spearman", use="complete.obs")

#One graph by location

ggplot(reg, aes(y=x20wsa2000, x= amf, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(y="Percent  8-2 mm Aggregate fraction (%)",
       title="Correlation between AMF and 8-2 mm fraction ") +
    xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
   stat_cor(aes(color=location_a, label = paste(..r.label..,..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=10, show.legend = F) +
  theme_James() 

   ggsave("x8_2mm_amf1.png",  height=5, width=9)

#group by location

reg %>%
ggplot(aes(y=x20wsa2000, x= amf))+
  facet_wrap(~location_a)+
  labs(y="Percent 8-2 mm Aggregate fraction(%)",
       title="Correlation between AMF and 8-2 mm fraction ") +
    xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)+
 theme_James() 

5.4.1 8-2 mm vs AMF Correlation plots for group depths

reg %>%
ggplot(aes(x=amf, y= x20wsa2000, color=treatment))+
  facet_wrap(~location_a)+
  labs(y="Percent 8-2 mm Aggregate fraction(%)",
       title="Correlation between AMF and 8-2 mm fraction ", shape="Horizon", color="Treatment") +
    xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,60)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
reg %>%
ggplot(aes(y=x20wsa2000, x= amf, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..r.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ 
  labs(y="Percent 8-2 mm Aggregate fraction (%)",
       title="Correlation between AMF and 8-2 mm fraction ", shape="Horizon", color="Treatment") +
    xlab(expression(~Arbuscular ~Mycorrhizal ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,60)) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
    stat_regline_equation(label.x=9, show.legend = F)

   ggsave("x8_2mm_amfcor.png",  height=5, width=9)

5.5 8-2 mm and MB Correlation graphs

ggplot(reg, aes(y=x20wsa2000, x= mb))+
  geom_point(size=.5)+
  labs(y="Percent 8-2 mm Aggregate fraction (%)",
       title="Correlation between Microbial Biomass and 8-2 mm fraction") +
    xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.3, label.y=35,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=40, label.x=.3) +
 theme_James() 

#One graph by location

ggplot(reg, aes(y=x20wsa2000, x= mb, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(y="Percent 8-2 mm Aggregate fraction (%)", 
       title="Correlation between Microbial Biomass and 8-2 mm fraction") +
      xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
   stat_cor(aes(color=location_a, label = paste(..r.label..,..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=50, show.legend = F) +
  theme_James() 

   ggsave("x8_2mm_mb1.png",  height=5, width=9)

#group by location

reg %>%
ggplot(aes(y=x20wsa2000, x= mb))+
  facet_wrap(~location_a)+
  labs(y="Percent 8-2 mm Aggregate fraction (%)", 
       title="Correlation between Microbial Biomass and 8-2 mm fraction") +
        xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)+
 theme_James() 

5.5.1 8-2 mm vs MB Correlation plots for group depths

reg %>%
ggplot(aes(x=mb, y= x20wsa2000, color=treatment))+
  facet_wrap(~location_a)+
  labs(y="Percent 8-2 mm Aggregate fraction (%)",
       title="Correlation between Microbial Biomass and 8-2 mm fraction", shape="Horizon", color="Treatment") +
    xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,50)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
reg %>%
ggplot(aes(y=x20wsa2000, x= mb, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..r.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ 
  labs(y="Percent 8-2 mm Aggregate fraction (%)",
       title="Correlation between Microbial Biomass and 8-2 mm fraction", shape="Horizon", color="Treatment") +
      xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,50)) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
    stat_regline_equation(label.x=50, show.legend = F)

   ggsave("8_2mm_mbcor.png",  height=5, width=9)

5.6 8-2 mm and fungi Correlation graphs

#20 minute Mean Weight Diameter vs 5 minute Method

ggplot(reg, aes(x=x20wsa2000, y= fungi))+
  geom_point(size=.5)+
  labs(x="Percent  8-2 mm Aggregate fraction (%)",
       title="Correlation between 8-2 mm fraction and Fungi") +
  ylab(expression(~Saprophytic ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.3, label.y=5,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=4, label.x=.3) +
 theme_James() 

#cor(soils$x20mwd, soils$x5mwd, method="spearman", use="complete.obs")

#One graph by location

ggplot(reg, aes(x=x20wsa2000, y= fungi, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(x="Percent  8-2 mm Aggregate fraction (%)",
       title="Correlation between 8-2 mm fraction and Fungi") +
  ylab(expression(~Saprophytic ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
   stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=10, show.legend = F) +
  theme_James() 

#group by location

reg %>%
ggplot(aes(x=x20wsa2000, y= fungi))+
  facet_wrap(~location_a)+
  labs(x="Percent  8-2 mm Aggregate fraction (%)",
       title="Correlation between 8-2 mm fraction and Fungi") +
  ylab(expression(~Saprophytic ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=3,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)+
 theme_James() 

5.7 2-0.25 and AMF Correlation graphs

#20 minute Mean Weight Diameter vs 5 minute Method

ggplot(reg, aes(x=x20wsa250, y= amf))+
  geom_point(size=.5)+
 labs(x="Percent  2-0.25 mm Aggregate fraction (%)",
       title="Correlation between 2-0.25 mm fraction and AMF") +
  ylab(expression(~AMF ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.3, label.y=15,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=14, label.x=.3) +
 theme_James() 

#cor(soils$x20mwd, soils$x5mwd, method="spearman", use="complete.obs")

#One graph by location

ggplot(reg, aes(y=x20wsa250, x= amf, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(y="Percent  2-0.25 mm Aggregate fraction (%)",
       title="Correlation between AMF and 2-0.25 mm fraction ") +
  xlab(expression(~AMF ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
   stat_cor(aes(color=location_a, label = paste(..r.label..,..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=10, show.legend = F) +
  theme_James() 

   ggsave("x2_025mm_amf1.png",  height=5, width=9)

#group by location

reg %>%
ggplot(aes(x=x20wsa250, y= amf))+
  facet_wrap(~location_a)+
  labs(x="Percent  2-0.25 mm Aggregate fraction (%)",
       title="Correlation between 2-0.25 mm fraction and AMF") +
  ylab(expression(~AMF ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)+
 theme_James() 

5.7.1 2-0.25 mm vs AMF Correlation plots for group depths

reg %>%
ggplot(aes(x=amf, y= x20wsa250, color=treatment))+
  facet_wrap(~location_a)+
  labs(y="Percent 2-0.25 mm Aggregate fraction (%)",
       title="Correlation between AMF and 2-0.25 mm fraction ", shape="Horizon", color="Treatment") +
    xlab(expression(~AMF ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,60)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
reg %>%
ggplot(aes(y=x20wsa250, x= amf, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..r.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ 
  labs(y="Percent 2-0.25 mm Aggregate fraction (%)",
       title="Correlation between AMF and 2-0.25 mm fraction ", shape="Horizon", color="Treatment") +
    xlab(expression(~AMF ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,60)) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
    stat_regline_equation(label.x=8, show.legend = F)

   ggsave("x2_025mm_amfcor.png",  height=5, width=9)

5.8 2-0.25 and MB Correlation graphs

#20 minute Mean Weight Diameter vs 5 minute Method

ggplot(reg, aes(y=x20wsa250, x= mb))+
  geom_point(size=.5)+
 labs(y="Percent 2-0.25 mm Aggregate fraction (%)",
       title="Correlation between 2-0.25 mm fraction and Microbial Biomass") +
  xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.3, label.y=100,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=85, label.x=.3) +
 theme_James() 

#cor(soils$x20mwd, soils$x5mwd, method="spearman", use="complete.obs")

#One graph by location

ggplot(reg, aes(y=x20wsa250, x= mb, color=location_a, shape=location_a))+
  geom_point(size=1)+
  labs(y="Percent 2-0.25 mm Aggregate fraction (%)",
       title="Correlation between Microbial Biomass and 2-0.25 mm fraction ") +
  xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
   stat_cor(aes(color=location_a, label = paste(..r.label..,..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=50, show.legend = F) +
  theme_James() 

   ggsave("x2_025mm_mb1.png",  height=5, width=9)


#group by location

reg %>%
ggplot(aes(y=x20wsa250, x= mb))+
  facet_wrap(~location_a)+
  labs(y="Percent 2-0.25 mm Aggregate fraction (%)",
       title="Correlation between 2-0.25 mm fraction and Microbial Biomass") +
  xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)+
 theme_James() 

5.8.1 2-0.25 mm vs MB Correlation plots for group depths

reg %>%
ggplot(aes(x=mb, y= x20wsa250, color=treatment))+
  facet_wrap(~location_a)+
  labs(y="Percent 2-0.25 mm Aggregate fraction (%)",
       title="Correlation between Microbial Biomass and 2-0.25 mm fraction ", shape="Horizon", color="Treatment") +
    xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,60)) +
  theme_classic()+
 geom_point(size=2)+
  theme_James2()+ 
    stat_cor(aes(label = paste(..r.label..,..rr.label.., ..p.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)

#Has correlation by treatment by location
reg %>%
ggplot(aes(y=x20wsa250, x= mb, color=treatment))+
  facet_wrap(~location_a)+
     stat_cor(aes(label = paste(..r.label.., sep = "~`,`~")), method="spearman", na.rm=F,  p.accuracy = 0.001, show.legend = F)+ 
  labs(y="Percent 2-0.25 mm Aggregate fraction (%)",
       title="Correlation between Microbial Biomass and 2-0.25 mm fraction ", shape="Horizon", color="Treatment") +
    xlab(expression(~Microbial ~Biomass ~(nmol ~PLFA ~g^{-1} ~soil))) +
   scale_y_continuous(limits=c(0,60)) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
  geom_point(size=2, aes(shape=horizon_a))+
  theme_James2() +
    stat_regline_equation(label.x=60, show.legend = F)

   ggsave("x2_025mm_mbcor.png",  height=5, width=9)

5.9 2-0.25 mm and Fungi Correlation graphs

#20 minute Mean Weight Diameter vs 5 minute Method

ggplot(reg, aes(y=x20wsa250, x= fungi))+
  geom_point(size=.5)+
  labs(y="Percent  2-0.25 mm Aggregate fraction (%)",
       title="Correlation between 2-0.25 mm fraction and Fungi") +
  xlab(expression(~Saprophytic ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_bw(base_size=12, base_family='TT Times New Roman')+
  geom_smooth(method="lm", se=FALSE)+
   theme(panel.grid.major = element_blank(),
         panel.grid.minor = element_blank()) +
  stat_cor(aes(label = paste(..rr.label..,  sep = "~`,`~")), method="spearman", na.rm=F, label.x=.3, label.y=5,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.y=4, label.x=.3) +
 theme_James() 

#cor(soils$x20mwd, soils$x5mwd, method="spearman", use="complete.obs")

#One graph by location

ggplot(reg, aes(y=x20wsa250, x= fungi, color=location_a, shape=location_a))+
  geom_point(size=1)+
   labs(y="Percent  2-0.25 mm Aggregate fraction (%)",
       title="Correlation between 2-0.25 mm fraction and Fungi") +
  xlab(expression(~Saprophytic ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE)+
   stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.x=.01,  p.accuracy = 0.001, show.legend = F) +
  stat_regline_equation(label.x=13, show.legend = F) +
  theme_James() 

#group by location

reg %>%
ggplot(aes(y=x20wsa250, x= fungi))+
  facet_wrap(~location_a)+
   labs(y="Percent  2-0.25 mm Aggregate fraction (%)",
       title="Correlation between 2-0.25 mm fraction and Fungi") +
  xlab(expression(~Saprophytic ~Fungi ~(nmol ~PLFA ~g^{-1} ~soil))) +
  theme_classic()+
  geom_smooth(method="lm", se=FALSE, color= "black") +
 geom_point(size=.5)+
     stat_cor(aes(color=location_a, label = paste(..rr.label.., sep = "~`,`~")), method="spearman", na.rm=F, label.y=.01,  p.accuracy = 0.001,  show.legend = F) +
  stat_regline_equation(label.x=.5, show.legend = F)+
 theme_James() 

6 end