cleanup and bugfix; linearity report made work

This commit is contained in:
2026-05-15 22:11:20 +02:00
parent 9422490f25
commit ec13d95387
4 changed files with 249 additions and 379 deletions
+59 -37
View File
@@ -15,19 +15,20 @@ header_includes:
-\rhead{\includegraphics[width=.15\textwidth]{`r getwd()`/logo.png}}
params:
FileName: NA
newTitle: NA
author: NA
NoP: NA
Assay: NA
REP: NA
coeffs: NA
author: "Author: `r params$author`"
title: |
| ![](logo.png){width=1in}
| ![](logo.png){width=2in}
| 4PL bioassay evaluation
subtitle: |
`r params$FileName`
<left> Unique time: </left> <right> `r Sys.time()`</right>
date: "`r paste(params$Subway, params$Version)`"
date: "`r paste(params$NoP, params$Assay)`"
---
@@ -55,17 +56,17 @@ DiagnTable <- REP$DiagnTable
UnRPLAausw <- REP$UnRPLAausw
UnRPLBend <- REP$UnRPLBend
PLAausw <- REP$PLAausw
PLBend <- REP$PLBend
PLbend <- REP$PLBend
pottab4plXL <- REP$pottab4plXL
Lim <- REP$Lim
XLdat2 <- REP$XLdat2
PureErr <- REP$PureErr
CIplot <- REP$CIplot
testsTab <- REP$testsTab
relpotTestPlot <- REP$relpotTestPlot
#browser()
```
@@ -103,7 +104,7 @@ colFmt <- function() {
if(AnalysisFlag) {
text <- paste("\\textcolor{red}{Analysis failed}",sep="")
} else {
text <- paste("\\textcolor{black}{Analysis succeeded}>",sep="")
text <- paste("\\textcolor{black}{Analysis succeeded}",sep="")
}
return(text)
}
@@ -116,12 +117,14 @@ colFmt <- function() {
## 4pl-regression
Relative potency (absolute and relative confidence limits) are shown in Table 2:
Relative potency (absolute and relative confidence limits) are shown in Table 2. `r if(PureErr) {"Pure Error is used for calculations."}`
`r if (!PureErr) {"RMSE of restricted model is used for confidence limit calculation."}`
```{r Pot_tab4pl, echo=FALSE, comment=NA, warning=NA, message=NA}
#browser()
if (pottab4plXL["test_result"][[1]][1]==1) { cat(paste("FAILED: relative potency CL result of restricted model outside limits: ", Lim[[9]], "and" ,Lim[[10]] ))}
if (pottab4plXL["test_result"][[1]][1]==1) { cat(paste("FAILED: relative potency CL result of restricted model outside limits: ", Lim[[9]], "to" ,Lim[[10]] ))}
if (pottab4plXL["test_result"][[1]][1]==0) { cat(paste("PASSED: relative potency CL result of restricted model within limits: ", Lim[[9]], "to" ,Lim[[10]] ))}
kable(pottab4plXL, format = "markdown", caption= "Relative potency with absolute and relative CLs ", digits=3, row.names = F) %>%
kable_styling(latex_options = "hold_position")
@@ -129,9 +132,10 @@ kable(pottab4plXL, format = "markdown", caption= "Relative potency with absolute
```
## Plot of the data and models
The following plots show the restricted and unrestricted model, respectively.
Plots in Figure 1 show the restricted and unrestricted model, respectively.
```{r XLplot, echo=FALSE, warning=FALSE, fig.height=4, fig.width=6, fig.cap="Plot of models", fig.align='left', comment=F, message=F, results='asis', fig.pos='H'}
@@ -147,24 +151,24 @@ plot_grid(XLplot4pl)
## ANOVA table
The ANOVA of the unconstrained model is listed in table 2:
The ANOVA of the unconstrained model is listed in table 3. Bates and Watts proposed a test on parallelism which compares the residual sum of squares of the restricted model (ResRSSE) with the residual sum of squares of the unrestricted model (UnresRSSE). If the UnresRSSE is significantly smaller than the ResRSSE, the p-value of "Non-parallelism" is smaller than 0.05 (line 4 in table 3). This test is for information only as it may be overly sensitive in case of small overall variability of the data.
```{r anovaxls, echo=FALSE, warning=FALSE, results='asis'}
kable(ANOVAXLS, format = "markdown", caption= "ANOVA table unrestricted", digits=3) %>%
kable(ANOVAXLS, format = "markdown", caption= "Analysis of variance", digits=3) %>%
kable_styling(latex_options = "hold_position")
```
## Analysis suitability tests
## Assay suitability tests
The following table lists the chosen suitabilit test results with confidence limits, where applicable:
Table 4 lists the chosen suitability test results with confidence limits, where applicable. F-tests should be read with caution, if the overall variability is small, as the test gets overly sensitive.
```{r SST_ergebn, echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, tidy=TRUE}
kable(testsTab, row.names = F, format = "markdown", caption="SST results")
kable(testsTab, row.names = F, format = "markdown", caption="Assay suitability results", digits=4)
```
@@ -196,9 +200,9 @@ colFmt2 <- function() {
outputFormat <- knitr::opts_knit$get("rmarkdown.pandoc.to")
if(TestsTabFlag) {
text <- paste("\\textcolor{red}{Analysis suitability tests failed}",sep="")
text <- paste("\\textcolor{red}{Assay suitability tests failed}",sep="")
} else {
text <- paste("\\textcolor{black}{Analysis suitability tests succeeded}",sep="")
text <- paste("\\textcolor{black}{Assay suitability tests succeeded}",sep="")
}
return(text)
}
@@ -212,33 +216,33 @@ colFmt2 <- function() {
## Fitting results of the 4 models with bend points
## Fitting results with curve points
The results of the non-linear fitting procedure for the restricted model (5 parameters) is listed in table 4:
The results of the non-linear fitting procedure for the restricted model (5 parameters) is listed in table 5:
```{r PLAausw, echo=FALSE, warning=FALSE, results='asis'}
kable(PLAausw, format = "markdown", caption= "Restricted 4PL evaluation", digits=3, row.names = F)
kable(PLAausw, format = "markdown", caption= "Restricted 4PL model", digits=3, row.names = F)
```
A depiction of the CI and corresponding limits of relative potency is shown here:
<!-- A depiction of the CI and corresponding limits of relative potency is shown here: -->
```{r, label='relpotPlot', echo=FALSE, warning=FALSE, fig.height=2, fig.width=3.5, fig.cap="Rel potency with CIs and limits", fig.align='left', results='asis'}
<!-- ```{r, label='relpotPlot', echo=FALSE, warning=FALSE, fig.height=2, fig.width=3.5, fig.cap="Rel potency with CIs and limits", fig.align='left', results='asis'} -->
print(relpotTestPlot)
<!-- print(relpotTestPlot) -->
```
<!-- ``` -->
The bend points for test and reference sample are in table 5:
Sebaugh et al proposed bend points for test and reference samples, that define the points with highest turning behavior. Table 6 lists these bendpoints as well as asymptote points ~ twice as far from the center as the bendpoints.
```{r PLBend, echo=FALSE, warning=FALSE, results='asis'}
kable(PLBend, format = "markdown", caption= "Bendpoints (Sebaugh) of restricted 4PL", digits=3)
kable(PLbend, format = "markdown", caption= "Bendpoints and asymptote points of restricted 4PL model", digits=3)
```
@@ -247,17 +251,17 @@ The results of the non-linear fitting procedure for the unrestricted model (8 pa
```{r UnRPLAausw, echo=FALSE, warning=FALSE, results='asis'}
kable(UnRPLAausw, format = "markdown", caption= "UNrestricted 4PL evaluation", digits=3, row.names = F)
kable(UnRPLAausw, format = "markdown", caption= "Unrestricted 4PL model", digits=3, row.names = F)
```
```{r UnRPLBend, echo=FALSE, warning=FALSE, results='asis'}
<!-- ```{r UnRPLBend, echo=FALSE, warning=FALSE, results='asis'} -->
kable(UnRPLBend, format = "markdown", caption= "Bend points of 4PL unrestricted", digits=3, row.names = F)
<!-- kable(UnRPLBend, format = "markdown", caption= "Bend points of 4PL unrestricted", digits=3, row.names = F) -->
```
<!-- ``` -->
@@ -269,13 +273,6 @@ $$
Y = D + \frac{A-D} {1+(\frac{C} {x})^B } + \epsilon
$$
## log-logistic 4P regression
$$
Y = D + \frac{A-D} {1+e^{(B*(C - log(x))) }} + \epsilon
$$
where: x ... concentration of the analyte
A: upper asymptote
@@ -286,6 +283,29 @@ D: lower asymptote
C ... EC50
## log-logistic 4P regression
$$
Y = D + \frac{A-D} {1+e^{(B*(C - log(x))) }} + \epsilon
$$
## Intercept for slope at EC50
$$
I = A+\frac{D-A}{2}-B_{true}*EC50
$$
## Slope at EC50
$$
B_{true}=B*\frac{D-A}{4}
$$
# Literature
Finney, D.J.: (1978) Statistical Method in Biological Assay, London: Charles Griffin House, 3rd edition (pp. 80-82)
@@ -294,6 +314,8 @@ Franz, V.H.: Ratios: A short guide to confidence limits and proper use. arXiv:07
VerHoef, J.M.: Who invented the Delta Method? The American Statistician, 2012, 66:2, 124-127 DOI: 10.1080/00031305.2012.687494
Bates, D.M., Watts, D.G. (1988). Comparing models. In: Nonlinear Regression Analysis and Its Applications. New York: Wiley, pp 103-108