report generation after new setup of repo; linearity XL report improved
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
---
|
||||
output:
|
||||
pdf_document:
|
||||
extra_dependencies: ["float"]
|
||||
number_sections: true
|
||||
toc: true
|
||||
toc_depth: 3
|
||||
header_includes:
|
||||
-\usepackage{fancyheadr}
|
||||
-\setlength{\headheight}{22pt}%
|
||||
-\usepackage{lastpage}
|
||||
-\pagestyle{fancy}
|
||||
-\usepackage{pdflscape}
|
||||
-\usepackage{longtable}
|
||||
-\rhead{\includegraphics[width=.15\textwidth]{`r getwd()`/logo.png}}
|
||||
params:
|
||||
FileName: NA
|
||||
newTitle: NA
|
||||
author: NA
|
||||
REP: NA
|
||||
REPlin: NA
|
||||
coeffsLin: NA
|
||||
NoP: NA
|
||||
Assay: NA
|
||||
author: "Author: `r params$author`"
|
||||
title: |
|
||||
| {width=1in}
|
||||
| Linear bioassay evaluation
|
||||
subtitle: |
|
||||
`r params$FileName`
|
||||
|
||||
<left> Unique time: </left> <right> `r Sys.time()`</right>
|
||||
date: "`r paste(params$NoP, params$Assay)`"
|
||||
|
||||
---
|
||||
|
||||
<!-- \fancyfoot[C]{\thepage\ of \pageref{LastPage}} -->
|
||||
<!-- \newpage -->
|
||||
|
||||
<!-- \newpage -->
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
|
||||
knitr::opts_chunk$set(echo = TRUE)
|
||||
|
||||
library(knitr)
|
||||
library(DT)
|
||||
|
||||
REP <- params$REP
|
||||
REPlin <- params$REPlin
|
||||
author <- params$author
|
||||
coeffsLin <- params$coeffsLin
|
||||
|
||||
all_l <- REP$all_l
|
||||
circles <- REPlin$circles
|
||||
#ANOVAXLS <- REP$ANOVAXLS
|
||||
SuModAB <- REPlin$SuModAB
|
||||
SuModABu <- REPlin$SuModABu
|
||||
LinTests <- REPlin$LinTests
|
||||
XLplotLin <- REPlin$pLin
|
||||
LinPotTab <- REPlin$LinPotTab
|
||||
|
||||
XLdat2 <- REP$XLdat2
|
||||
|
||||
LinTests1 <- LinTests[,1:3]
|
||||
ANOVAlin <- LinTests[,4:ncol(LinTests)]
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
# Introduction
|
||||
|
||||
Bioassay potency estimation uses statistical methods to quantify the strength of a biological product or drug by comparing its response to that of a reference standard. Biological responses are inherently variable, affected by assay conditions, cell systems or organisms, and measurement noise. To control this variability, a linear regression approach is used to obtain reliable potency values. Three consecutive dilution steps showing the steepest slope are used for linear fitting.
|
||||
USP<1034> recommends calculation of standard errors of ratios of the parameters using Fieller's theorem [Finney D.J. 1978] or using the "delta" method (for a discussion about the "delta" method see [Ver Hoef 2012]). The present analysis calculated the relative potency with the "delta" method. The formula of the relative potency is in the Appendix.
|
||||
|
||||
# Raw data
|
||||
|
||||
All data used for evaluation is shown in table 1.
|
||||
|
||||
```{r Alll, echo=FALSE, warning=FALSE, results='asis'}
|
||||
|
||||
kable(XLdat2, format = "markdown", caption= "Uploaded data (test and reference) ", digits=3)
|
||||
|
||||
```
|
||||
|
||||
The linerar regression is calculated on the readout listed in table 2.
|
||||
|
||||
```{r Circles, echo=FALSE, warning=FALSE, results='asis'}
|
||||
|
||||
kable(circles, format = "markdown", caption= "Concentrations and readout used for linear regression", digits=3, row.names = F)
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
# Results
|
||||
|
||||
## Overall result
|
||||
|
||||
```{r Over_all, echo=FALSE, comment=NA, warning=NA, message=NA}
|
||||
|
||||
#browser()
|
||||
potFlag <- 0
|
||||
if (LinPotTab[1,"test_result"]==1) potFlag <- 1
|
||||
AnalysisFlag <- FALSE
|
||||
if (potFlag==1 | sum(LinTests$test_results)>0) AnalysisFlag <- TRUE
|
||||
|
||||
colFmt <- function() {
|
||||
|
||||
outputFormat <- knitr::opts_knit$get("rmarkdown.pandoc.to")
|
||||
if(AnalysisFlag) {
|
||||
text <- paste("\\textcolor{red}{Analysis failed}",sep="")
|
||||
} else {
|
||||
text <- paste("\\textcolor{black}{Analysis succeeded}",sep="")
|
||||
}
|
||||
return(text)
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
`r colFmt()`
|
||||
|
||||
|
||||
## Plots and ANOVA
|
||||
|
||||
Plots in Figure 1 show the restricted and unrestricted model, respectively.
|
||||
|
||||
```{r LinPlot, echo=FALSE, warning=FALSE, fig.height=4, fig.width=6, fig.cap="Plot of models", fig.align='left'}
|
||||
|
||||
library(cowplot)
|
||||
|
||||
|
||||
plot_grid(XLplotLin)
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
The relative potency can be read from tbale 3.
|
||||
|
||||
```{r LinPotTab, echo=FALSE, warning=FALSE, results='asis'}
|
||||
|
||||
kable(LinPotTab, format = "markdown", caption= "Potency table", digits=3)
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
The ANOVA of the unconstrained model is listed in table 4.
|
||||
|
||||
```{r anovaxls, echo=FALSE, warning=FALSE, results='asis'}
|
||||
|
||||
kable(ANOVAlin, format = "markdown", caption= "ANOVA table unrestricted", digits=3)
|
||||
|
||||
RMSE <- sqrt(ANOVAlin[5,4])
|
||||
|
||||
```
|
||||
|
||||
The standard deviation of the model is `r RMSE`.
|
||||
|
||||
The assay suitability tests are shown in table 5.
|
||||
|
||||
|
||||
```{r SST_ergebn, echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, tidy=TRUE}
|
||||
|
||||
kable(LinTests1, row.names = F, format = "markdown", caption="Assay suitability test results", digits=3)
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
The estimate is the p-value of the test.
|
||||
F-tests on regression, significance of slopes, and preparation need to have a p-value <0.05 to pass.
|
||||
All other tests pass if p-value > 0.05.
|
||||
|
||||
0 ... test passed;
|
||||
|
||||
1 ... test failed);
|
||||
|
||||
(NOTE: F-tests are sensitive, when the residual variability of the method is small. On the other hand effects may not be detected if residual variability is high.)
|
||||
|
||||
## Fitting results
|
||||
|
||||
The results of the linear fitting procedure for the restricted model is listed in table 6:
|
||||
|
||||
```{r SumCSSI, echo=FALSE, warning=FALSE, results='asis'}
|
||||
|
||||
kable(SuModAB, format = "markdown", caption= "Restricted linear regression (CSSI)", digits=3, row.names = F)
|
||||
|
||||
|
||||
```
|
||||
|
||||
CSSI: common slope, separate intercept
|
||||
|
||||
The results of the linear fitting procedure for the unrestricted model is listed in table 7.
|
||||
|
||||
|
||||
```{r SumSSSI, echo=FALSE, warning=FALSE, results='asis'}
|
||||
|
||||
kable(SuModABu, format = "markdown", caption= "Restricted linear regression (SSSI)", digits=3, row.names = F)
|
||||
|
||||
|
||||
```
|
||||
|
||||
SSSI: separate slope, separate intercept
|
||||
|
||||
|
||||
|
||||
|
||||
# Appendix: Formulas
|
||||
|
||||
## Potency of linear PLA
|
||||
|
||||
$$
|
||||
rel Potency = \frac{I_{ref} - I_{test}}{k}
|
||||
$$
|
||||
where: I... intercept of reference or test
|
||||
k ... common slope
|
||||
|
||||
|
||||
|
||||
# Literature
|
||||
|
||||
Finney, D.J.: (1978) Statistical Method in Biological Assay, London: Charles Griffin House, 3rd edition (pp. 80-82)
|
||||
|
||||
Franz, V.H.: Ratios: A short guide to confidence limits and proper use. arXiv:0710.2024v1, 10 Oct 2007
|
||||
|
||||
VerHoef, J.M.: Who invented the Delta Method? The American Statistician, 2012, 66:2, 124-127 DOI: 10.1080/00031305.2012.687494
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
---
|
||||
output:
|
||||
pdf_document:
|
||||
extra_dependencies: ["float"]
|
||||
number_sections: true
|
||||
toc: true
|
||||
toc_depth: 3
|
||||
header_includes:
|
||||
-\usepackage{fancyheadr}
|
||||
-\setlength{\headheight}{22pt}%
|
||||
-\usepackage{lastpage}
|
||||
-\pagestyle{fancy}
|
||||
-\usepackage{pdflscape}
|
||||
-\usepackage{longtable}
|
||||
-\rhead{\includegraphics[width=.15\textwidth]{`r getwd()`/logo.png}}
|
||||
params:
|
||||
FileName: NA
|
||||
author: NA
|
||||
NoP: NA
|
||||
Assay: NA
|
||||
REP: NA
|
||||
coeffs: NA
|
||||
author: "Author: `r params$author`"
|
||||
title: |
|
||||
| {width=2in}
|
||||
| 4PL bioassay evaluation
|
||||
subtitle: |
|
||||
`r params$FileName`
|
||||
|
||||
<left> Unique time: </left> <right> `r Sys.time()`</right>
|
||||
date: "`r paste(params$NoP, params$Assay)`"
|
||||
|
||||
---
|
||||
|
||||
<!-- \fancyfoot[C]{\thepage\ of \pageref{LastPage}} -->
|
||||
<!-- \newpage -->
|
||||
|
||||
<!-- \newpage -->
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
|
||||
knitr::opts_chunk$set(echo = TRUE)
|
||||
|
||||
library(knitr)
|
||||
library(DT)
|
||||
library(kableExtra)
|
||||
|
||||
REP <- params$REP
|
||||
author <- params$author
|
||||
coeffs <- params$coeffs
|
||||
|
||||
all_l <- REP$all_l
|
||||
ANOVAXLS <- REP$ANOVAXLS
|
||||
XLplot4pl <- REP$XLplot4pl
|
||||
DiagnTable <- REP$DiagnTable
|
||||
UnRPLAausw <- REP$UnRPLAausw
|
||||
UnRPLBend <- REP$UnRPLBend
|
||||
PLAausw <- REP$PLAausw
|
||||
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()
|
||||
|
||||
```
|
||||
|
||||
|
||||
# Introduction
|
||||
|
||||
Bioassay potency estimation uses statistical methods to quantify the strength of a biological product or drug by comparing its response to that of a reference standard. Because biological responses are inherently variable, affected by assay conditions, cell systems or organisms, and measurement noise, the 4-parametric logistic regression is used to obtain reliable potency values.
|
||||
USP<1034> recommends calculation of standard errors of ratios of the parameters using Fieller's theorem [Finney DJ 1978] or using the "delta" method (for a discussion about the "delta" method see [Ver Hoef 2012]). However, the presented gradient approach using the differences on the log-scale is mathematically more stable und thus preferable compared to a ratio approach ([Franz VH 2007]).
|
||||
|
||||
# Raw data
|
||||
|
||||
All data used for the 4PL evaluation is shown in table 1:
|
||||
|
||||
```{r alll, echo=FALSE, warning=FALSE, results='asis'}
|
||||
|
||||
kable(XLdat2, format = "markdown", caption= "Uploaded data (test and reference) ", digits=3)
|
||||
|
||||
```
|
||||
|
||||
|
||||
# Results
|
||||
|
||||
## Overall result
|
||||
|
||||
```{r Over_all, echo=FALSE, comment=NA, warning=NA, message=NA}
|
||||
|
||||
# browser()
|
||||
potFlag <- 0
|
||||
if (pottab4plXL["test_result"][[1]][1]==1) potFlag <- 1
|
||||
AnalysisFlag <- FALSE
|
||||
if (potFlag==1 | sum(testsTab$test_results)>0) AnalysisFlag <- TRUE
|
||||
|
||||
colFmt <- function() {
|
||||
|
||||
outputFormat <- knitr::opts_knit$get("rmarkdown.pandoc.to")
|
||||
if(AnalysisFlag) {
|
||||
text <- paste("\\textcolor{red}{Analysis failed}",sep="")
|
||||
} else {
|
||||
text <- paste("\\textcolor{black}{Analysis succeeded}",sep="")
|
||||
}
|
||||
return(text)
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
`r colFmt()`
|
||||
|
||||
|
||||
## 4pl-regression
|
||||
|
||||
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]], "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")
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Plot of the data and models
|
||||
|
||||
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'}
|
||||
|
||||
library(cowplot)
|
||||
|
||||
|
||||
plot_grid(XLplot4pl)
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
## ANOVA table
|
||||
|
||||
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= "Analysis of variance", digits=3) %>%
|
||||
kable_styling(latex_options = "hold_position")
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Assay suitability tests
|
||||
|
||||
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="Assay suitability results", digits=4)
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
\footnotesize
|
||||
|
||||
```{r Fussnote, echo=F, comment=NA}
|
||||
|
||||
cat("*...The estimate for F-test on regression and on non-linearity is the p-value")
|
||||
cat( "F-test on regression passes if F-value > F-crit and thus p < 0.05")
|
||||
cat( "F-test on non-linearity passes if F-value < F-crit and thus p > 0.05")
|
||||
cat( "Test results outcome:")
|
||||
cat(" 0 ... test passed (for EQ tests: CL within limits);")
|
||||
cat(" 1 ... test failed (for EQ tests: CL not within limits);")
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
\normalsize
|
||||
|
||||
|
||||
```{r AST_Ergebn, echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE, tidy=TRUE}
|
||||
|
||||
TestsTabFlag <- FALSE
|
||||
if (sum(testsTab$test_results)>0) TestsTabFlag <- TRUE
|
||||
colFmt2 <- function() {
|
||||
|
||||
outputFormat <- knitr::opts_knit$get("rmarkdown.pandoc.to")
|
||||
if(TestsTabFlag) {
|
||||
text <- paste("\\textcolor{red}{Assay suitability tests failed}",sep="")
|
||||
} else {
|
||||
text <- paste("\\textcolor{black}{Assay suitability tests succeeded}",sep="")
|
||||
}
|
||||
return(text)
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
`r colFmt2()`
|
||||
|
||||
|
||||
|
||||
|
||||
## Fitting results with curve points
|
||||
|
||||
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 model", digits=3, row.names = F)
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
<!-- 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'} -->
|
||||
|
||||
<!-- print(relpotTestPlot) -->
|
||||
|
||||
|
||||
<!-- ``` -->
|
||||
|
||||
|
||||
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 and asymptote points of restricted 4PL model", digits=3)
|
||||
|
||||
|
||||
```
|
||||
|
||||
The results of the non-linear fitting procedure for the unrestricted model (8 parameters) is listed in table 6:
|
||||
|
||||
```{r UnRPLAausw, echo=FALSE, warning=FALSE, results='asis'}
|
||||
|
||||
kable(UnRPLAausw, format = "markdown", caption= "Unrestricted 4PL model", digits=3, row.names = F)
|
||||
|
||||
```
|
||||
|
||||
|
||||
<!-- ```{r UnRPLBend, echo=FALSE, warning=FALSE, results='asis'} -->
|
||||
|
||||
<!-- kable(UnRPLBend, format = "markdown", caption= "Bend points of 4PL unrestricted", digits=3, row.names = F) -->
|
||||
|
||||
|
||||
<!-- ``` -->
|
||||
|
||||
|
||||
|
||||
# Appendix: Formulas
|
||||
|
||||
## 4PL regression
|
||||
|
||||
$$
|
||||
Y = D + \frac{A-D} {1+(\frac{C} {x})^B } + \epsilon
|
||||
$$
|
||||
|
||||
where: x ... concentration of the analyte
|
||||
|
||||
A: upper asymptote
|
||||
|
||||
B: slope
|
||||
|
||||
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)
|
||||
|
||||
Franz, V.H.: Ratios: A short guide to confidence limits and proper use. arXiv:0710.2024v1, 10 Oct 2007
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -548,6 +548,8 @@ server <- function(input, output, session) {
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
#### UI wizard ----
|
||||
output$wizard <- renderUI({
|
||||
navbarPage(
|
||||
title = "Dilution setting",
|
||||
@@ -557,14 +559,12 @@ server <- function(input, output, session) {
|
||||
sidebarPanel(
|
||||
width = 3,
|
||||
fluidRow(
|
||||
column(
|
||||
6,
|
||||
numericInput(
|
||||
"Limits", p("limit to be >", bsButton("q4", label = "", icon = icon("info"), style = "primary", size = "extra-small")),
|
||||
bsPopover(id = "q4", title = "", content = "The calculated limits ...")
|
||||
column(6,
|
||||
box(title = "Upload multiple worksheets", status = "warning", solidHeader = T, width = 12, "Please upload your EXCEL file here",
|
||||
fileInput("MiFile", "", accept = ".xlsx"))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
),
|
||||
mainPanel(
|
||||
tabsetPanel(
|
||||
@@ -575,8 +575,7 @@ server <- function(input, output, session) {
|
||||
title = "ANOVA table", status = "primary", solidHeader = T, width = 12,
|
||||
tableOutput("Anovatab")
|
||||
),
|
||||
column(
|
||||
4,
|
||||
column(4,
|
||||
h3("Confidence intervals"),
|
||||
tableOutput("CIs"),
|
||||
"The confidence interval table is interaactive for changes in: variability slider (%SD), potency of test-slider,
|
||||
@@ -584,8 +583,7 @@ server <- function(input, output, session) {
|
||||
tableOutput("optimalDils"),
|
||||
selectInput(inputId = "scenario", label = "Select an 'optimal' scenario:", choices = c("scenario 2", "scenario 3", "scenario 6", "steep slope"))
|
||||
),
|
||||
column(
|
||||
5,
|
||||
column(5,
|
||||
plotOutput("plotfordilutions"),
|
||||
h4("in grey: most extreme bend point lines of theoretical samples with 50% and 200% potency"),
|
||||
sliderInput("dilslider", "Adjust the dilutions(+-change in %)", min = -100, max = 100, value = 0, step = 1, round = 0),
|
||||
@@ -595,8 +593,7 @@ server <- function(input, output, session) {
|
||||
"Short guidance: wider dilution ranges increase the CIs of rel. potency, and decrease the CIs of upper and lower asymptote ratios, as well as Hill's slope ratios", br(),
|
||||
"Narrower dilution ranges decrease the CIs of rel. potency, and increase the CIs of upper and lower asymptote ratios, ands Hill's slope ratios",
|
||||
),
|
||||
column(
|
||||
3,
|
||||
column(3,
|
||||
h3("Bend points"),
|
||||
tableOutput("bps"),
|
||||
tableOutput("extremebps"),
|
||||
@@ -670,6 +667,22 @@ server <- function(input, output, session) {
|
||||
})
|
||||
|
||||
|
||||
observe({
|
||||
if (!is.null(input$MiFile)) {
|
||||
MinFile <- input$MiFile
|
||||
ext <- tools::file_ext(MinFile$name)
|
||||
file.rename(MinFile$datapath, paste(MinFile$datapath, ".xlsx", sep = ""))
|
||||
t.filelocation <- gsub("\\\\", "/", paste(MinFile$datapath, ext, sep = "."))
|
||||
sheets <- openxlsx::getSheetNames(t.filelocation)
|
||||
dat <- lapply(sheets, openxlsx::read.xlsx, xlsxFile = t.filelocation)
|
||||
names(dat) <- sheets
|
||||
Dat$Mws <- dat
|
||||
names(Dat$Mws) <- sheets
|
||||
Dat$Msheets <- sheets
|
||||
Dat$MFileName <- input$MiFile[["name"]]
|
||||
}
|
||||
})
|
||||
|
||||
#### process XLSX file ----
|
||||
observe({
|
||||
if (!is.null(input$iFile)) {
|
||||
@@ -1339,7 +1352,7 @@ server <- function(input, output, session) {
|
||||
if (is.null(input$PureErr)) {
|
||||
return(NULL)
|
||||
}
|
||||
if (!is.null(Dat$FITsFlag)) {
|
||||
if (Dat$FITsFlag) {
|
||||
return(NULL)
|
||||
}
|
||||
|
||||
@@ -1974,10 +1987,12 @@ server <- function(input, output, session) {
|
||||
|
||||
#### 4pl potency table XL ----
|
||||
observe({
|
||||
|
||||
|
||||
if (is.null(Dat$EXCEL)) {
|
||||
return(NULL)
|
||||
}
|
||||
if (!is.null(Dat$FITsFlag)) {
|
||||
if (Dat$FITsFlag) {
|
||||
return(NULL)
|
||||
}
|
||||
ro_new <- Dat$EXCEL
|
||||
@@ -2025,7 +2040,7 @@ server <- function(input, output, session) {
|
||||
colnames(pottab4_) <- c("model", "potency", "lower95%CI", "upper95%CI", "relative_lower95%CI", "relative_upper95%CI", "test_result")
|
||||
row.names(pottab4_) <- NULL
|
||||
REP$pottab4plXL <- pottab4_[1:2, ]
|
||||
|
||||
#browser()
|
||||
output$pottab4plXL <- DT::renderDataTable({
|
||||
dat <- datatable(pottab4_[1:2, ],
|
||||
rownames = F,
|
||||
@@ -2055,8 +2070,101 @@ server <- function(input, output, session) {
|
||||
|
||||
#### Dilutions Simulator ----
|
||||
output$plotfordilutions <- renderPlot({
|
||||
tab <- sim2()
|
||||
tab <- as.data.frame(tab)
|
||||
if (!is.null(Dat$Mws))
|
||||
AllXL <- Dat$Mws
|
||||
AllSheets <- Dat$Msheets
|
||||
|
||||
|
||||
for (N_WS in 1:length(AllXL)) {
|
||||
|
||||
datWS <- as.data.frame(AllXL[[N_WS]])
|
||||
|
||||
cn <- colnames(datWS)
|
||||
logI <- grep("log|ln", cn)
|
||||
logDoseI <- grep("log_dose", cn)
|
||||
if (length(logI) > 0 & length(logDoseI) == 0) {
|
||||
datWS$log_dose <- datWS[, logI]
|
||||
datWS2 <- datWS[, -logI]
|
||||
CORro <- cor(datWS$log_dose, datWS[, 3])
|
||||
} else if (length(logI) == 0 & length(logDoseI) == 0) {
|
||||
Ind <- grep(".ilution|.ose|.onc", cn)
|
||||
datWS$log_dose <- log(datWS[, Ind])
|
||||
CORro <- cor(datWS[, Ind], datWS[, 3])
|
||||
datWS2 <- datWS[, -Ind]
|
||||
} else if (length(logI) > 0 & length(logDoseI) > 0) {
|
||||
datWS2 <- datWS
|
||||
CORro <- cor(datWS[, logI], datWS[, 3])
|
||||
}
|
||||
Dat$datWS2 <- datWS2
|
||||
|
||||
FITs <- Fitting_FUNC(datWS2, TransFlag = F)
|
||||
|
||||
pot_est <- FITs[[3]]
|
||||
potU_est <- FITs[[4]]
|
||||
# unrestricted
|
||||
SU_mu <- FITs[[2]]
|
||||
URMcoeffs <- SU_mu$coefficients
|
||||
|
||||
X <- seq(min(log(datWS23$log_dose)), max(log(datWS2$log_dose)), 0.1)
|
||||
sigRef <- URMcoefs[1,1] + (URMcoefs1[4,1]-URMcoefs[1,1])/(1+exp(URMcoefs[2,1]*(URMcoefs[3,1]-X)))
|
||||
sigTest1 <- URMcoefs[5,1] + (URMcoefs[8,1]-URMcoefs[5,1])/(1+exp(URMcoefs[6,1]*(URMcoefs[7,1]-X)))
|
||||
|
||||
dfPlotsigRef <- data.frame(X=X, sigRef = sigRef, Prod = pdfInd)
|
||||
dfPlotsigTest <- data.frame(X=X, sigTest = sigTest1, Prod = AllSheets[[N_WS]])
|
||||
|
||||
if (!exists("SIGrefDF")) SIGrefDF <- dfPlotsigRef else SIGrefDF <- rbind(SIGrefDF, dfPlotsigRef)
|
||||
if (!exists("SIGtestDF")) SIGtestDF <- dfPlotsigTest else SIGtestDF <- rbind(SIGtestDF,dfPlotsigTest)
|
||||
|
||||
EC50TEST <- as.numeric(c(URMcoefsDF[,8]))
|
||||
# EC50TEST <- EC50TEST[!EC50TEST %in% boxplot.stats(EC50TEST)$out]
|
||||
EC50REF <- as.numeric(URMcoefsDF[,4])
|
||||
# EC50REF <- EC50REF[!EC50REF %in% boxplot.stats(EC50REF)$out]
|
||||
UasREF <- as.numeric(URMcoefsDF[,5])
|
||||
# UasREF <- UasREF[!UasREF %in% boxplot.stats(UasREF)$out]
|
||||
LasREF <- as.numeric(URMcoefsDF[,2])
|
||||
# LasREF <- LasREF[!LasREF %in% boxplot.stats(LasREF)$out]
|
||||
#
|
||||
# Dat$URMcoefsDF <- URMcoefsDF
|
||||
# Dat$RestrM <- RestrM
|
||||
# Dat$CalcPot <- CalcPot
|
||||
#
|
||||
#### sigmoid plots ----
|
||||
Slope <- as.numeric(URMcoefsDF[1,3])
|
||||
# if (Slope > 0) {
|
||||
# x_UA <- max(X); x_LA <- min(X)
|
||||
# } else { x_UA <- min(X); x_LA <- max(X) }
|
||||
#
|
||||
# p1 <- ggplot(SIGrefDF, aes(x_X, y=sigRef, col=as.factor(Prod))) +
|
||||
# geom_line() +
|
||||
# annotate("text", label="x", x=x_UA, y=UasREF, alpha=0.2) +
|
||||
# annotate("text", label="o", x=x_LA, y=LasREF, alpha=0.2) +
|
||||
# geom_vline(xintercept = EC50REF, alpha = 0.2) +
|
||||
# xlab("dilutions") +
|
||||
# ggtitle("Plot of all calculated reference fits (unrestricted model, in gray vertical lines: EC50)") +
|
||||
# theme_bw() +
|
||||
# theme(axis.text = element_text(face = "bold", size = 15),
|
||||
# plot.title = element_text(size = 15, face = "bold"))
|
||||
#
|
||||
# output$sigPlotREF <- renderPlot({ p1 })
|
||||
#
|
||||
# PLOTS$sigPlotREF <- p1
|
||||
#
|
||||
# p2 <- ggplot(SIGtestDF, aes(x_X, y=sigTest, col=as.factor(Prod))) +
|
||||
# geom_line() +
|
||||
# #annotate("text", label="x", x=x_UA, y=UasREF, alpha=0.2) +
|
||||
# #annotate("text", label="o", x=x_LA, y=LasREF, alpha=0.2) +
|
||||
# geom_vline(xintercept = EC50TEST, alpha = 0.2) +
|
||||
# xlab("dilutions") +
|
||||
# ggtitle("Plot of all calculated reference fits (unrestricted model, in gray vertical lines: EC50)") +
|
||||
# theme_bw() +
|
||||
# theme(axis.text = element_text(face = "bold", size = 15),
|
||||
# plot.title = element_text(size = 15, face = "bold"))
|
||||
#
|
||||
# output$sigPlotREF <- renderPlot({ p2 })
|
||||
#
|
||||
# PLOTS$sigPlotTEST <- p2
|
||||
|
||||
|
||||
dils <- tab$log_dose
|
||||
min_y <- min(tab[, 1:3])
|
||||
max_y <- max(tab[, 1:3])
|
||||
@@ -2077,7 +2185,10 @@ server <- function(input, output, session) {
|
||||
dils2 <- dils_avsc + av
|
||||
dilfactors <- 1 / exp(dils2 - lag(dils2))
|
||||
}
|
||||
|
||||
} #for N_WS
|
||||
|
||||
|
||||
|
||||
Dat$newDils <- dils2
|
||||
|
||||
sigmoid <- sigmoid()
|
||||
@@ -2538,6 +2649,8 @@ server <- function(input, output, session) {
|
||||
params = list(
|
||||
FileName = Dat$FileName,
|
||||
author = Dat$Author,
|
||||
NoP = Dat$NoP,
|
||||
Assay = Dat$Assay,
|
||||
REP = REP,
|
||||
REPlin = REPlin,
|
||||
coeffsLin = Dat$coeffs_UN
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Reference in New Issue
Block a user