From f414052def5b4e1addaa3bdd5c0ce099f79f4ff2 Mon Sep 17 00:00:00 2001 From: janlisec Date: Thu, 13 Jun 2024 09:29:18 +0200 Subject: [PATCH] Improved annotation of Fig.V2. --- R/fnc_prepFigV2.R | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/R/fnc_prepFigV2.R b/R/fnc_prepFigV2.R index a0b3ffd..66513e4 100644 --- a/R/fnc_prepFigV2.R +++ b/R/fnc_prepFigV2.R @@ -41,8 +41,8 @@ prepFigV2 <- function(tab = NULL, a = NULL, alpha = 0.05, k = 3, flt_outliers = # quadratic model: m = 2 # fitted data plot - graphics::par(mar=c(5,4,3,2)+0.1) - plot(x = conc, y = Area_norm, xlab = "Concentration", ylab = "Area/Area_IS", main = a) + graphics::par(mar=c(5,ifelse(m==1, 4, 3),3,ifelse(m==1, 0, 1))+0.1) + plot(x = conc, y = Area_norm, xlab = "Concentration", ylab = ifelse(m==1, "Area/Area_IS", ""), main = ifelse(m==1, a, "")) if (m==1) { df <- dfl e <- e.l @@ -57,6 +57,7 @@ prepFigV2 <- function(tab = NULL, a = NULL, alpha = 0.05, k = 3, flt_outliers = new_conc <- seq(min(c(0, min(conc))), max(conc), length.out=100) area_predicted <- stats::predict(object = qm, list(Conc = new_conc, Conc2 = new_conc^2)) graphics::lines(x = new_conc, y = area_predicted, col = 3) + graphics::mtext(text = "(quadratic model)", side = 3, line = 1, cex = cex) graphics::mtext(text = expression(y==b[0]+b[1]*x+b[2]*x^2), side = 3, line = -1.3, at = 0, adj = 0, cex = cex) graphics::mtext(text = bquote(b[0]==.(round(stats::coef(qm)[1], 4))), side = 3, line = -2.5, at = 0, adj = 0, cex = cex) graphics::mtext(text = bquote(b[1]==.(round(stats::coef(qm)[2], 4))), side = 3, line = -3.7, at = 0, adj = 0, cex = cex) @@ -66,23 +67,32 @@ prepFigV2 <- function(tab = NULL, a = NULL, alpha = 0.05, k = 3, flt_outliers = graphics::points(df, pch=4, col=2, cex=2) # barplot of residuals - graphics::par(mar=c(3,4,0,2)+0.1) + graphics::par(mar=c(3,ifelse(m==1, 4, 3),0,ifelse(m==1, 0, 1))+0.1) barplot.x <- graphics::barplot(unname(e), ylim = res_rng, ann=F) flt <- e>=0 graphics::text(x = barplot.x[flt], y = 0, labels = paste(names(e)[flt], " "), srt=90, adj = 1, cex = 1/cex) graphics::text(x = barplot.x[!flt], y = 0, labels = paste(" ", names(e)[!flt]), srt=90, adj = 0, cex = 1/cex) - graphics::mtext(text = "Residuals", side = 2, line = 3, cex = cex) + graphics::mtext(text = ifelse(m==1, "Residuals", ""), side = 2, line = 3, cex = cex) # zoomed plot - graphics::par(mar=c(5,4,0,2)+0.1) + graphics::par(mar=c(5,ifelse(m==1, 4, 3),0,ifelse(m==1, 0, 1))+0.1) if (all(df[,1] > vals[,"LOQ"])) { plot(1,1,ann=FALSE,axes=F,type="n") graphics::text(x = 1, y = 1, labels = expression(LOQ