diff --git a/inst/doc/ely_etal_ex1.pdf b/inst/doc/ely_etal_ex1.pdf index d3c08ab..f73a071 100644 Binary files a/inst/doc/ely_etal_ex1.pdf and b/inst/doc/ely_etal_ex1.pdf differ diff --git a/inst/doc/ely_etal_ex2.pdf b/inst/doc/ely_etal_ex2.pdf index e94a4a3..639808c 100644 Binary files a/inst/doc/ely_etal_ex2.pdf and b/inst/doc/ely_etal_ex2.pdf differ diff --git a/inst/doc/kit_sla_ex3.pdf b/inst/doc/kit_sla_ex3.pdf index 6042312..efbc5d4 100644 Binary files a/inst/doc/kit_sla_ex3.pdf and b/inst/doc/kit_sla_ex3.pdf differ diff --git a/inst/doc/neon_canopy_leafN_ex5.pdf b/inst/doc/neon_canopy_leafN_ex5.pdf index f36b77a..53483c0 100644 Binary files a/inst/doc/neon_canopy_leafN_ex5.pdf and b/inst/doc/neon_canopy_leafN_ex5.pdf differ diff --git a/inst/doc/neon_canopy_lma_ex10.pdf b/inst/doc/neon_canopy_lma_ex10.pdf index 4e3b23b..2c1fbc4 100644 Binary files a/inst/doc/neon_canopy_lma_ex10.pdf and b/inst/doc/neon_canopy_lma_ex10.pdf differ diff --git a/inst/doc/neon_lma_ex4.pdf b/inst/doc/neon_lma_ex4.pdf index a5b1963..3e9467f 100644 Binary files a/inst/doc/neon_lma_ex4.pdf and b/inst/doc/neon_lma_ex4.pdf differ diff --git a/inst/doc/reseco_leafN_ex6.pdf b/inst/doc/reseco_leafN_ex6.pdf index be1a1a6..2610c75 100644 Binary files a/inst/doc/reseco_leafN_ex6.pdf and b/inst/doc/reseco_leafN_ex6.pdf differ diff --git a/inst/doc/reseco_leafN_ex7.pdf b/inst/doc/reseco_leafN_ex7.pdf index febc267..88b5a7f 100644 Binary files a/inst/doc/reseco_leafN_ex7.pdf and b/inst/doc/reseco_leafN_ex7.pdf differ diff --git a/inst/doc/reseco_lma_ex8.pdf b/inst/doc/reseco_lma_ex8.pdf index 8bddec2..fd5abab 100644 Binary files a/inst/doc/reseco_lma_ex8.pdf and b/inst/doc/reseco_lma_ex8.pdf differ diff --git a/inst/scripts/simple_spectra-trait_plsr_example.R b/inst/scripts/simple_spectra-trait_plsr_example.R index 9bff25a..2702da2 100644 --- a/inst/scripts/simple_spectra-trait_plsr_example.R +++ b/inst/scripts/simple_spectra-trait_plsr_example.R @@ -191,7 +191,8 @@ cal.RMSEP <- round(sqrt(mean(plsr_data.output$PLSR_CV_Residuals^2)),2) rng_quant <- quantile(plsr_data.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(plsr_data.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -199,16 +200,16 @@ cal_scatter_plot <- ggplot(plsr_data.output, aes(x=PLSR_CV_Predicted, y=get(inVa theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(plsr_data.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, cal_resid_histogram, nrow=2, ncol=1) diff --git a/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_example.R b/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_example.R index 904c0cf..51daa15 100644 --- a/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_example.R +++ b/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_example.R @@ -91,14 +91,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -221,29 +223,32 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), - title=paste0("Calibration: ", paste0("Rsq = ", cal.R2), "; ", paste0("RMSEP = ", cal.RMSEP))) + + title=paste0("Calibration: ", paste0("Rsq = ", cal.R2), "; ", + paste0("RMSEP = ", cal.RMSEP))) + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -251,16 +256,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_grp_example.R b/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_grp_example.R index 0d545f8..13966f0 100644 --- a/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_grp_example.R +++ b/inst/scripts/spectra-trait_ely_leafN_plsr_bootstrap_grp_example.R @@ -92,14 +92,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -216,46 +218,50 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), - title=paste0("Calibration: ", paste0("Rsq = ", cal.R2), "; ", paste0("RMSEP = ", cal.RMSEP))) + + title=paste0("Calibration: ", paste0("Rsq = ", cal.R2), "; ", + paste0("RMSEP = ", cal.RMSEP))) + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), - title=paste0("Validation: ", paste0("Rsq = ", val.R2), "; ", paste0("RMSEP = ", val.RMSEP))) + + title=paste0("Validation: ", paste0("Rsq = ", val.R2), "; ", + paste0("RMSEP = ", val.RMSEP))) + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/inst/scripts/spectra-trait_kit_sla_plsr_example.R b/inst/scripts/spectra-trait_kit_sla_plsr_example.R index b757869..24d858d 100644 --- a/inst/scripts/spectra-trait_kit_sla_plsr_example.R +++ b/inst/scripts/spectra-trait_kit_sla_plsr_example.R @@ -123,12 +123,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"),alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"),alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, height = 12, units = "cm", @@ -252,7 +256,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -260,38 +265,40 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), - title=paste0("Validation: ", paste0("Rsq = ", val.R2), "; ", paste0("RMSEP = ", val.RMSEP))) + + title=paste0("Validation: ", paste0("Rsq = ", val.R2), "; ", + paste0("RMSEP = ", val.RMSEP))) + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/inst/scripts/spectra-trait_neon_leafN_canopy_plsr_example.R b/inst/scripts/spectra-trait_neon_leafN_canopy_plsr_example.R index b535277..23f4a0a 100644 --- a/inst/scripts/spectra-trait_neon_leafN_canopy_plsr_example.R +++ b/inst/scripts/spectra-trait_neon_leafN_canopy_plsr_example.R @@ -157,14 +157,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -288,8 +290,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -298,22 +300,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -322,16 +324,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/inst/scripts/spectra-trait_neon_lma_plsr_example.R b/inst/scripts/spectra-trait_neon_lma_plsr_example.R index ad432d1..201f6f6 100644 --- a/inst/scripts/spectra-trait_neon_lma_plsr_example.R +++ b/inst/scripts/spectra-trait_neon_lma_plsr_example.R @@ -121,14 +121,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -252,8 +254,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -262,22 +264,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -286,16 +288,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/inst/scripts/spectra-trait_reseco_leafN_plsr_bootstrap_example.R b/inst/scripts/spectra-trait_reseco_leafN_plsr_bootstrap_example.R index 6c94335..244d8bc 100644 --- a/inst/scripts/spectra-trait_reseco_leafN_plsr_bootstrap_example.R +++ b/inst/scripts/spectra-trait_reseco_leafN_plsr_bootstrap_example.R @@ -126,14 +126,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -254,7 +256,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -262,21 +265,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -284,16 +288,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/inst/scripts/spectra-trait_reseco_leafN_plsr_example.R b/inst/scripts/spectra-trait_reseco_leafN_plsr_example.R index b878342..eaee411 100644 --- a/inst/scripts/spectra-trait_reseco_leafN_plsr_example.R +++ b/inst/scripts/spectra-trait_reseco_leafN_plsr_example.R @@ -124,14 +124,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -255,8 +257,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -265,22 +267,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -289,16 +291,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/inst/scripts/spectra-trait_reseco_lma_plsr_example.R b/inst/scripts/spectra-trait_reseco_lma_plsr_example.R index a602af9..ce63c17 100644 --- a/inst/scripts/spectra-trait_reseco_lma_plsr_example.R +++ b/inst/scripts/spectra-trait_reseco_lma_plsr_example.R @@ -136,15 +136,17 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) text_loc <- c(max(hist(cal.plsr.data[,paste0(inVar)])$counts), max(hist(cal.plsr.data[,paste0(inVar)])$mids)) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Calibration Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) + - annotate("text", x=text_loc[2], y=text_loc[1], label= "1.",size=10) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Validation Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") + annotate("text", x=text_loc[2], y=text_loc[1], + label= "1.",size=10) +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, height = 12, units = "cm", dpi = 300) @@ -305,47 +307,51 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), - title=paste0("Calibration: ", paste0("Rsq = ", cal.R2), "; ", paste0("RMSEP = ", cal.RMSEP))) + + title=paste0("Calibration: ", paste0("Rsq = ", cal.R2), "; ", + paste0("RMSEP = ", cal.RMSEP))) + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) + annotate("text", x=rng_quant[1], y=rng_quant[2], label= "5.",size=10) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), - title=paste0("Validation: ", paste0("Rsq = ", val.R2), "; ", paste0("RMSEP = ", val.RMSEP))) + + title=paste0("Validation: ", paste0("Rsq = ", val.R2), "; ", + paste0("RMSEP = ", val.RMSEP))) + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/ely_etal_ex1.Rmd b/vignettes/ely_etal_ex1.Rmd index aaf6d01..6bd4ea4 100644 --- a/vignettes/ely_etal_ex1.Rmd +++ b/vignettes/ely_etal_ex1.Rmd @@ -3,11 +3,11 @@ title: Spectra-trait PLSR example using leaf-level spectra and leaf nitrogen con author: "Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson" date: "`r Sys.Date()`" output: - github_document: default + pdf_document: default html_document: df_print: paged keep_md: true - pdf_document: default + github_document: default html_notebook: default rmarkdown: html_vignette vignette: > @@ -101,14 +101,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, @@ -230,8 +232,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -240,22 +242,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -264,16 +266,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/ely_etal_ex1.md b/vignettes/ely_etal_ex1.md index 349d3d1..b0e4a02 100644 --- a/vignettes/ely_etal_ex1.md +++ b/vignettes/ely_etal_ex1.md @@ -3,7 +3,7 @@ content (Narea, g/m2) data from eight different crop species growing in a glasshouse at Brookhaven National Laboratory ================ Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson -2024-06-17 +2024-06-19 ### Overview @@ -109,7 +109,7 @@ inVar <- "N_g_m2" ### Set working directory (scratch space) - ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpJ3BBUV" + ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/Rtmpv2JzFM" ### Full PLSR dataset @@ -221,22 +221,16 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) ## [1] "Val observations: 54" ``` r -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -``` - - ## Warning: `qplot()` was deprecated in ggplot2 3.4.0. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ``` @@ -498,8 +492,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -508,36 +502,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) -``` + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) - ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. - ## ℹ Please use `linewidth` instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - - ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. - ## ℹ Please use the `linewidth` argument instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -546,16 +526,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, @@ -564,8 +544,7 @@ scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histo ## Warning: Removed 3 rows containing missing values or values outside the scale range ## (`geom_point()`). - - ## Warning: Removed 3 rows containing missing values or values outside the scale range + ## Removed 3 rows containing missing values or values outside the scale range ## (`geom_point()`). ## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. @@ -785,7 +764,7 @@ write.csv(out.jk.coefs,file=file.path(outdir,paste0(inVar, print(paste("Output directory: ", outdir)) ``` - ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//RtmpJ3BBUV" + ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//Rtmpv2JzFM" ``` r # Observed versus predicted diff --git a/vignettes/ely_etal_ex1.pdf b/vignettes/ely_etal_ex1.pdf index d3c08ab..f73a071 100644 Binary files a/vignettes/ely_etal_ex1.pdf and b/vignettes/ely_etal_ex1.pdf differ diff --git a/vignettes/ely_etal_ex1_files/figure-gfm/unnamed-chunk-6-1.png b/vignettes/ely_etal_ex1_files/figure-gfm/unnamed-chunk-6-1.png index e163fdb..18c6ecd 100644 Binary files a/vignettes/ely_etal_ex1_files/figure-gfm/unnamed-chunk-6-1.png and b/vignettes/ely_etal_ex1_files/figure-gfm/unnamed-chunk-6-1.png differ diff --git a/vignettes/ely_etal_ex2.Rmd b/vignettes/ely_etal_ex2.Rmd index 14a4b07..db7083c 100644 --- a/vignettes/ely_etal_ex2.Rmd +++ b/vignettes/ely_etal_ex2.Rmd @@ -101,14 +101,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, @@ -222,8 +224,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -232,22 +234,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -256,16 +258,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/ely_etal_ex2.md b/vignettes/ely_etal_ex2.md index 6f6bcc8..07f8755 100644 --- a/vignettes/ely_etal_ex2.md +++ b/vignettes/ely_etal_ex2.md @@ -4,7 +4,7 @@ a glasshouse at Brookhaven National Laboratory. This example illustrates running the PLSR permutation by group ================ Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson -2024-06-17 +2024-06-19 ### Overview @@ -110,7 +110,7 @@ inVar <- "N_g_m2" ### Set working directory (scratch space) - ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpXZoXO6" + ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpMXBwDv" ### Full PLSR dataset @@ -222,22 +222,16 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) ## [1] "Val observations: 54" ``` r -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -``` - - ## Warning: `qplot()` was deprecated in ggplot2 3.4.0. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ``` @@ -496,8 +490,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -506,36 +500,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) -``` - - ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. - ## ℹ Please use `linewidth` instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) - ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. - ## ℹ Please use the `linewidth` argument instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -544,16 +524,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, @@ -785,7 +765,7 @@ write.csv(out.jk.coefs,file=file.path(outdir,paste0(inVar, print(paste("Output directory: ", outdir)) ``` - ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//RtmpXZoXO6" + ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//RtmpMXBwDv" ``` r # Observed versus predicted diff --git a/vignettes/ely_etal_ex2.pdf b/vignettes/ely_etal_ex2.pdf index e94a4a3..639808c 100644 Binary files a/vignettes/ely_etal_ex2.pdf and b/vignettes/ely_etal_ex2.pdf differ diff --git a/vignettes/ely_etal_ex2_files/figure-gfm/unnamed-chunk-6-1.png b/vignettes/ely_etal_ex2_files/figure-gfm/unnamed-chunk-6-1.png index e163fdb..18c6ecd 100644 Binary files a/vignettes/ely_etal_ex2_files/figure-gfm/unnamed-chunk-6-1.png and b/vignettes/ely_etal_ex2_files/figure-gfm/unnamed-chunk-6-1.png differ diff --git a/vignettes/kit_sla_ex3.Rmd b/vignettes/kit_sla_ex3.Rmd index e78592c..cde6b0e 100644 --- a/vignettes/kit_sla_ex3.Rmd +++ b/vignettes/kit_sla_ex3.Rmd @@ -120,14 +120,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"), - col=I("black"),alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"), - col=I("black"),alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, height = 12, units = "cm", @@ -248,8 +250,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -258,22 +260,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -282,16 +284,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/kit_sla_ex3.md b/vignettes/kit_sla_ex3.md index 1a90446..8216cf0 100644 --- a/vignettes/kit_sla_ex3.md +++ b/vignettes/kit_sla_ex3.md @@ -3,7 +3,7 @@ area (SLA) data from more than 40 species grassland species comprising both herbs and graminoids ================ Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson -2024-06-17 +2024-06-19 ### Overview @@ -92,7 +92,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "Output directory: /private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/Rtmp5Imgt6" + ## [1] "Output directory: /private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpgYX4kg" ### Grab data from EcoSIS @@ -357,22 +357,16 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) ## [1] "Val observations: 124" ``` r -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"), - col=I("black"),alpha=I(.7)) -``` - - ## Warning: `qplot()` was deprecated in ggplot2 3.4.0. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"), - col=I("black"),alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ``` @@ -611,8 +605,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -621,36 +615,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) -``` - - ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. - ## ℹ Please use `linewidth` instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) - ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. - ## ℹ Please use the `linewidth` argument instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -659,16 +639,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/kit_sla_ex3.pdf b/vignettes/kit_sla_ex3.pdf index 6042312..efbc5d4 100644 Binary files a/vignettes/kit_sla_ex3.pdf and b/vignettes/kit_sla_ex3.pdf differ diff --git a/vignettes/kit_sla_ex3_files/figure-gfm/unnamed-chunk-7-1.png b/vignettes/kit_sla_ex3_files/figure-gfm/unnamed-chunk-7-1.png index 029ac8c..79acd21 100644 Binary files a/vignettes/kit_sla_ex3_files/figure-gfm/unnamed-chunk-7-1.png and b/vignettes/kit_sla_ex3_files/figure-gfm/unnamed-chunk-7-1.png differ diff --git a/vignettes/neon_canopy_leafN_ex5.Rmd b/vignettes/neon_canopy_leafN_ex5.Rmd index 6256ba3..7c376d3 100644 --- a/vignettes/neon_canopy_leafN_ex5.Rmd +++ b/vignettes/neon_canopy_leafN_ex5.Rmd @@ -156,14 +156,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -283,8 +285,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -293,22 +295,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -317,16 +319,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/neon_canopy_leafN_ex5.md b/vignettes/neon_canopy_leafN_ex5.md index f535378..532f7ac 100644 --- a/vignettes/neon_canopy_leafN_ex5.md +++ b/vignettes/neon_canopy_leafN_ex5.md @@ -2,7 +2,7 @@ Spectra-trait PLSR example using NEON AOP pixel spectra and field-sampled leaf nitrogen content from CONUS NEON sites ================ Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson -2024-06-17 +2024-06-19 ### Overview @@ -89,7 +89,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpPp6bS4" + ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpvL6UrD" ### Grab data from EcoSIS @@ -311,22 +311,16 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) ## [1] "Val observations: 130" ``` r -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -``` - - ## Warning: `qplot()` was deprecated in ggplot2 3.4.0. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ``` @@ -586,8 +580,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -596,36 +590,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) -``` - - ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. - ## ℹ Please use `linewidth` instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) - ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. - ## ℹ Please use the `linewidth` argument instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -634,16 +614,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/neon_canopy_leafN_ex5.pdf b/vignettes/neon_canopy_leafN_ex5.pdf index f36b77a..53483c0 100644 Binary files a/vignettes/neon_canopy_leafN_ex5.pdf and b/vignettes/neon_canopy_leafN_ex5.pdf differ diff --git a/vignettes/neon_canopy_leafN_ex5_files/figure-gfm/unnamed-chunk-7-1.png b/vignettes/neon_canopy_leafN_ex5_files/figure-gfm/unnamed-chunk-7-1.png index a9bab5f..8675f1b 100644 Binary files a/vignettes/neon_canopy_leafN_ex5_files/figure-gfm/unnamed-chunk-7-1.png and b/vignettes/neon_canopy_leafN_ex5_files/figure-gfm/unnamed-chunk-7-1.png differ diff --git a/vignettes/neon_canopy_lma_ex10.Rmd b/vignettes/neon_canopy_lma_ex10.Rmd index 6dcba25..4159c5b 100644 --- a/vignettes/neon_canopy_lma_ex10.Rmd +++ b/vignettes/neon_canopy_lma_ex10.Rmd @@ -156,15 +156,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count", - fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -284,8 +285,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -294,22 +295,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -318,7 +319,7 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + diff --git a/vignettes/neon_canopy_lma_ex10.md b/vignettes/neon_canopy_lma_ex10.md index 64b56a4..b06139f 100644 --- a/vignettes/neon_canopy_lma_ex10.md +++ b/vignettes/neon_canopy_lma_ex10.md @@ -2,7 +2,7 @@ Spectra-trait PLSR example using NEON AOP pixel spectra and field-sampled leaf nitrogen content from CONUS NEON sites ================ Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson -2024-06-17 +2024-06-19 ### Overview @@ -89,7 +89,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpQQQH6k" + ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/Rtmprf8pzl" ### Grab data from EcoSIS @@ -311,23 +311,16 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) ## [1] "Val observations: 129" ``` r -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count", - fill=I("grey50"),col=I("black"), - alpha=I(.7)) -``` - - ## Warning: `qplot()` was deprecated in ggplot2 3.4.0. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ``` @@ -587,8 +580,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -597,36 +590,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) -``` - - ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. - ## ℹ Please use `linewidth` instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) - ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. - ## ℹ Please use the `linewidth` argument instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -635,7 +614,7 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + @@ -645,7 +624,21 @@ val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) +``` + ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. + ## ℹ Please use `linewidth` instead. + ## This warning is displayed once every 8 hours. + ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was + ## generated. + + ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. + ## ℹ Please use the `linewidth` argument instead. + ## This warning is displayed once every 8 hours. + ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was + ## generated. + +``` r # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, val_resid_histogram, nrow=2,ncol=2) diff --git a/vignettes/neon_canopy_lma_ex10.pdf b/vignettes/neon_canopy_lma_ex10.pdf index 4e3b23b..2c1fbc4 100644 Binary files a/vignettes/neon_canopy_lma_ex10.pdf and b/vignettes/neon_canopy_lma_ex10.pdf differ diff --git a/vignettes/neon_canopy_lma_ex10_files/figure-gfm/unnamed-chunk-7-1.png b/vignettes/neon_canopy_lma_ex10_files/figure-gfm/unnamed-chunk-7-1.png index 7225470..aec8adc 100644 Binary files a/vignettes/neon_canopy_lma_ex10_files/figure-gfm/unnamed-chunk-7-1.png and b/vignettes/neon_canopy_lma_ex10_files/figure-gfm/unnamed-chunk-7-1.png differ diff --git a/vignettes/neon_lma_ex4.Rmd b/vignettes/neon_lma_ex4.Rmd index a236d54..c58cda4 100644 --- a/vignettes/neon_lma_ex4.Rmd +++ b/vignettes/neon_lma_ex4.Rmd @@ -116,14 +116,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"), - col=I("black"),alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"), - col=I("black"),alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, height = 12, units = "cm", @@ -250,7 +252,7 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", linetype="dashed", - size=1.5) + + linewidth=1.5) + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), @@ -262,18 +264,18 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), panel.border = element_rect(linetype = "solid", - fill = NA, size=1.5)) + fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), panel.border = element_rect(linetype = "solid", - fill = NA, size=1.5)) + fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -281,7 +283,7 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + + linetype="dashed", linewidth=1.5) + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), @@ -293,17 +295,17 @@ val_scatter_plot <- ggplot(val.plsr.output, axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), panel.border = element_rect(linetype = "solid", fill = NA, - size=1.5)) + linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), panel.border = element_rect(linetype = "solid", fill = NA, - size=1.5)) + linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/neon_lma_ex4.md b/vignettes/neon_lma_ex4.md index 184a918..b456095 100644 --- a/vignettes/neon_lma_ex4.md +++ b/vignettes/neon_lma_ex4.md @@ -2,7 +2,7 @@ Spectra-trait PLSR example using leaf-level spectra and leaf mass per area (LMA) data from CONUS NEON sites ================ Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson -2024-06-17 +2024-06-19 ### Overview @@ -87,7 +87,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpOGEASM" + ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpueELda" ### Grab data from EcoSIS @@ -272,22 +272,16 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) ## [1] "Val observations: 1390" ``` r -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"), - col=I("black"),alpha=I(.7)) -``` - - ## Warning: `qplot()` was deprecated in ggplot2 3.4.0. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"), - col=I("black"),alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ``` @@ -546,7 +540,7 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", linetype="dashed", - size=1.5) + + linewidth=1.5) + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), @@ -558,32 +552,18 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), panel.border = element_rect(linetype = "solid", - fill = NA, size=1.5)) -``` - - ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. - ## ℹ Please use `linewidth` instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. + fill = NA, linewidth=1.5)) - ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. - ## ℹ Please use the `linewidth` argument instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), panel.border = element_rect(linetype = "solid", - fill = NA, size=1.5)) + fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) @@ -591,7 +571,7 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + + linetype="dashed", linewidth=1.5) + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), @@ -603,17 +583,17 @@ val_scatter_plot <- ggplot(val.plsr.output, axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), panel.border = element_rect(linetype = "solid", fill = NA, - size=1.5)) + linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), panel.border = element_rect(linetype = "solid", fill = NA, - size=1.5)) + linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/neon_lma_ex4.pdf b/vignettes/neon_lma_ex4.pdf index a5b1963..3e9467f 100644 Binary files a/vignettes/neon_lma_ex4.pdf and b/vignettes/neon_lma_ex4.pdf differ diff --git a/vignettes/neon_lma_ex4_files/figure-gfm/unnamed-chunk-6-1.png b/vignettes/neon_lma_ex4_files/figure-gfm/unnamed-chunk-6-1.png index ea561ee..08bf04c 100644 Binary files a/vignettes/neon_lma_ex4_files/figure-gfm/unnamed-chunk-6-1.png and b/vignettes/neon_lma_ex4_files/figure-gfm/unnamed-chunk-6-1.png differ diff --git a/vignettes/reseco_leafN_ex6.Rmd b/vignettes/reseco_leafN_ex6.Rmd index 0d4719a..3512720 100644 --- a/vignettes/reseco_leafN_ex6.Rmd +++ b/vignettes/reseco_leafN_ex6.Rmd @@ -3,13 +3,13 @@ title: Spectra-trait PLSR example using leaf-level spectra and leaf nitrogen con author: "Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson" date: "`r Sys.Date()`" output: - pdf_document: default + github_document: default html_notebook: default html_document: df_print: paged keep_md: true rmarkdown: html_vignette - github_document: default + pdf_document: default vignette: > %\VignetteIndexEntry{Spectra-trait PLSR example using leaf-level spectra and leaf nitrogen content (Narea, g/m2) data from 36 species growing in Rosa rugosa invaded coastal grassland communities in Belgium} %\usepackage[utf8]{inputenc} @@ -126,14 +126,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -255,8 +257,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -265,22 +267,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -289,16 +291,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/reseco_leafN_ex6.md b/vignettes/reseco_leafN_ex6.md index 6f5d63c..bde2af0 100644 --- a/vignettes/reseco_leafN_ex6.md +++ b/vignettes/reseco_leafN_ex6.md @@ -3,7 +3,7 @@ content (Narea, g/m2) data from 36 species growing in Rosa rugosa invaded coastal grassland communities in Belgium ================ Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson -2024-06-17 +2024-06-19 ### Overview @@ -88,7 +88,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpjBm0Ly" + ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpP2TT60" ### Grab data from EcoSIS @@ -318,22 +318,16 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) ## [1] "Val observations: 73" ``` r -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -``` - - ## Warning: `qplot()` was deprecated in ggplot2 3.4.0. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ``` @@ -590,8 +584,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -600,36 +594,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) -``` + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) - ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. - ## ℹ Please use `linewidth` instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - - ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. - ## ℹ Please use the `linewidth` argument instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -638,16 +618,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, @@ -656,8 +636,7 @@ scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histo ## Warning: Removed 2 rows containing missing values or values outside the scale range ## (`geom_point()`). - - ## Warning: Removed 2 rows containing missing values or values outside the scale range + ## Removed 2 rows containing missing values or values outside the scale range ## (`geom_point()`). ## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. @@ -877,7 +856,7 @@ write.csv(out.jk.coefs,file=file.path(outdir, print(paste("Output directory: ", outdir)) ``` - ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//RtmpjBm0Ly" + ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//RtmpP2TT60" ``` r # Observed versus predicted diff --git a/vignettes/reseco_leafN_ex6.pdf b/vignettes/reseco_leafN_ex6.pdf index be1a1a6..2610c75 100644 Binary files a/vignettes/reseco_leafN_ex6.pdf and b/vignettes/reseco_leafN_ex6.pdf differ diff --git a/vignettes/reseco_leafN_ex6_files/figure-gfm/unnamed-chunk-7-1.png b/vignettes/reseco_leafN_ex6_files/figure-gfm/unnamed-chunk-7-1.png index 1dbeb2d..4da3b9e 100644 Binary files a/vignettes/reseco_leafN_ex6_files/figure-gfm/unnamed-chunk-7-1.png and b/vignettes/reseco_leafN_ex6_files/figure-gfm/unnamed-chunk-7-1.png differ diff --git a/vignettes/reseco_leafN_ex7.Rmd b/vignettes/reseco_leafN_ex7.Rmd index 4ec8ca3..ad0f74d 100644 --- a/vignettes/reseco_leafN_ex7.Rmd +++ b/vignettes/reseco_leafN_ex7.Rmd @@ -127,14 +127,16 @@ rm(split_data) print(paste("Cal observations: ",dim(cal.plsr.data)[1],sep="")) print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ggsave(filename = file.path(outdir,paste0(inVar,"_Cal_Val_Histograms.png")), plot = histograms, device="png", width = 30, @@ -256,8 +258,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -266,22 +268,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -290,16 +292,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/reseco_leafN_ex7.md b/vignettes/reseco_leafN_ex7.md index 38b9931..1e970ab 100644 --- a/vignettes/reseco_leafN_ex7.md +++ b/vignettes/reseco_leafN_ex7.md @@ -4,7 +4,7 @@ invaded coastal grassland communities in Belgium. Bootstrap validation example ================ Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson -2024-06-17 +2024-06-19 ### Overview @@ -89,7 +89,7 @@ output_dir <- "tempdir" ### Set working directory (scratch space) - ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpPpsuZX" + ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpYHbpdv" ### Grab data from EcoSIS @@ -320,22 +320,16 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) ## [1] "Val observations: 73" ``` r -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Cal. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) -``` - - ## Warning: `qplot()` was deprecated in ggplot2 3.4.0. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Val. Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ``` @@ -592,8 +586,8 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -602,36 +596,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) -``` + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) - ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. - ## ℹ Please use `linewidth` instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - - ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. - ## ℹ Please use the `linewidth` argument instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + xlim(rng_quant[1], - rng_quant[2]) + + linetype="dashed", linewidth=1.5) + + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), y=paste0("Observed ", paste(inVar), " (units)"), @@ -640,16 +620,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, @@ -658,8 +638,7 @@ scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histo ## Warning: Removed 2 rows containing missing values or values outside the scale range ## (`geom_point()`). - - ## Warning: Removed 2 rows containing missing values or values outside the scale range + ## Removed 2 rows containing missing values or values outside the scale range ## (`geom_point()`). ## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. @@ -879,7 +858,7 @@ write.csv(out.jk.coefs,file=file.path(outdir,paste0(inVar, print(paste("Output directory: ", outdir)) ``` - ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//RtmpPpsuZX" + ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//RtmpYHbpdv" ``` r # Observed versus predicted diff --git a/vignettes/reseco_leafN_ex7.pdf b/vignettes/reseco_leafN_ex7.pdf index febc267..88b5a7f 100644 Binary files a/vignettes/reseco_leafN_ex7.pdf and b/vignettes/reseco_leafN_ex7.pdf differ diff --git a/vignettes/reseco_leafN_ex7_files/figure-gfm/unnamed-chunk-7-1.png b/vignettes/reseco_leafN_ex7_files/figure-gfm/unnamed-chunk-7-1.png index 1dbeb2d..4da3b9e 100644 Binary files a/vignettes/reseco_leafN_ex7_files/figure-gfm/unnamed-chunk-7-1.png and b/vignettes/reseco_leafN_ex7_files/figure-gfm/unnamed-chunk-7-1.png differ diff --git a/vignettes/reseco_lma_ex8.Rmd b/vignettes/reseco_lma_ex8.Rmd index 5a85fdd..85ddcb1 100644 --- a/vignettes/reseco_lma_ex8.Rmd +++ b/vignettes/reseco_lma_ex8.Rmd @@ -127,15 +127,17 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) text_loc <- c(max(hist(cal.plsr.data[,paste0(inVar)], plot=FALSE)$counts), max(hist(cal.plsr.data[,paste0(inVar)], plot=FALSE)$mids)) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Calibration Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) + - annotate("text", x=text_loc[2], y=text_loc[1], label= "1.",size=10) -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Validation Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") + annotate("text", x=text_loc[2], y=text_loc[1], + label= "1.",size=10) +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) # Figure S1. The resulting leaf mass area (LMA, g/m2) distribution (histogram) for the @@ -290,7 +292,7 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + + linetype="dashed", linewidth=1.5) + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), @@ -300,22 +302,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) + annotate("text", x=rng_quant[1], y=rng_quant[2], label= "5.",size=10) cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + + linetype="dashed", linewidth=1.5) + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), @@ -325,16 +327,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, diff --git a/vignettes/reseco_lma_ex8.md b/vignettes/reseco_lma_ex8.md index c179d3c..be6297d 100644 --- a/vignettes/reseco_lma_ex8.md +++ b/vignettes/reseco_lma_ex8.md @@ -3,7 +3,7 @@ area (LMA) data from 36 species growing in Rosa rugosa invaded coastal grassland communities in Belgium ================ Shawn P. Serbin, Julien Lamour, & Jeremiah Anderson -2024-06-17 +2024-06-19 ### Overview @@ -88,7 +88,7 @@ output_dir <- "tempdir" ### Step 3. Set working directory (scratch space) - ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpWk8TOy" + ## [1] "/private/var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T/RtmpSWYu5C" ### Step 4. Pull example dataset from EcoSIS (ecosis.org) @@ -319,23 +319,17 @@ print(paste("Val observations: ",dim(val.plsr.data)[1],sep="")) ``` r text_loc <- c(max(hist(cal.plsr.data[,paste0(inVar)], plot=FALSE)$counts), max(hist(cal.plsr.data[,paste0(inVar)], plot=FALSE)$mids)) -cal_hist_plot <- qplot(cal.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Calibration Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) + - annotate("text", x=text_loc[2], y=text_loc[1], label= "1.",size=10) -``` - - ## Warning: `qplot()` was deprecated in ggplot2 3.4.0. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r -val_hist_plot <- qplot(val.plsr.data[,paste0(inVar)],geom="histogram", - main = paste0("Validation Histogram for ",inVar), - xlab = paste0(inVar),ylab = "Count",fill=I("grey50"),col=I("black"), - alpha=I(.7)) +cal_hist_plot <- ggplot(data = cal.plsr.data, + aes(x = cal.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Calibration Histogram for ",inVar), x = paste0(inVar), + y = "Count") + annotate("text", x=text_loc[2], y=text_loc[1], + label= "1.",size=10) +val_hist_plot <- ggplot(data = val.plsr.data, + aes(x = val.plsr.data[,paste0(inVar)])) + + geom_histogram(fill=I("grey50"),col=I("black"),alpha=I(.7)) + + labs(title=paste0("Validation Histogram for ",inVar), x = paste0(inVar), + y = "Count") histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) ``` @@ -631,7 +625,7 @@ val.RMSEP <- round(sqrt(mean(val.plsr.output$PLSR_Residuals^2)),2) rng_quant <- quantile(cal.plsr.output[,inVar], probs = c(0.001, 0.999)) cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + + linetype="dashed", linewidth=1.5) + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), @@ -641,36 +635,22 @@ cal_scatter_plot <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Predicted, y=get(inVar theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) + annotate("text", x=rng_quant[1], y=rng_quant[2], label= "5.",size=10) -``` - - ## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. - ## ℹ Please use `linewidth` instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - ## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. - ## ℹ Please use the `linewidth` argument instead. - ## This warning is displayed once every 8 hours. - ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was - ## generated. - -``` r cal_resid_histogram <- ggplot(cal.plsr.output, aes(x=PLSR_CV_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) rng_quant <- quantile(val.plsr.output[,inVar], probs = c(0.001, 0.999)) val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) + theme_bw() + geom_point() + geom_abline(intercept = 0, slope = 1, color="dark grey", - linetype="dashed", size=1.5) + + linetype="dashed", linewidth=1.5) + xlim(rng_quant[1], rng_quant[2]) + ylim(rng_quant[1], rng_quant[2]) + labs(x=paste0("Predicted ", paste(inVar), " (units)"), @@ -680,16 +660,16 @@ val_scatter_plot <- ggplot(val.plsr.output, aes(x=PLSR_Predicted, y=get(inVar))) theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) val_resid_histogram <- ggplot(val.plsr.output, aes(x=PLSR_Residuals)) + geom_histogram(alpha=.5, position="identity") + geom_vline(xintercept = 0, color="black", - linetype="dashed", size=1) + theme_bw() + + linetype="dashed", linewidth=1) + theme_bw() + theme(axis.text=element_text(size=18), legend.position="none", axis.title=element_text(size=20, face="bold"), axis.text.x = element_text(angle = 0,vjust = 0.5), - panel.border = element_rect(linetype = "solid", fill = NA, size=1.5)) + panel.border = element_rect(linetype = "solid", fill = NA, linewidth=1.5)) # plot cal/val side-by-side scatterplots <- grid.arrange(cal_scatter_plot, val_scatter_plot, cal_resid_histogram, @@ -911,7 +891,7 @@ write.csv(out.jk.coefs,file=file.path(outdir, print(paste("Output directory: ", outdir)) ``` - ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//RtmpWk8TOy" + ## [1] "Output directory: /var/folders/th/fpt_z3417gn8xgply92pvy6r0000gq/T//RtmpSWYu5C" ``` r # Observed versus predicted diff --git a/vignettes/reseco_lma_ex8.pdf b/vignettes/reseco_lma_ex8.pdf index 8bddec2..fd5abab 100644 Binary files a/vignettes/reseco_lma_ex8.pdf and b/vignettes/reseco_lma_ex8.pdf differ