CI file and PseudoRepFile added PLAscraper updated
This commit is contained in:
@@ -11,7 +11,7 @@ library(pdftools)
|
||||
library(stringr)
|
||||
library(openxlsx)
|
||||
library(evd)
|
||||
# library(fitdistrplus)
|
||||
library(fitdistrplus)
|
||||
|
||||
RestrMF <- function(data, M) {
|
||||
all_l <- melt(data, id.vars="uniDoses", variable.name="replname", value.name="readout")
|
||||
@@ -152,7 +152,7 @@ server <- function(input, output, session) {
|
||||
filenames <- Dat$FNames
|
||||
POTlist <- FINALresponses <- SampleNamesL <- list()
|
||||
DilSerVec <- vector()
|
||||
hide_spinner()
|
||||
#hide_spinner()
|
||||
for (Nfile in 1:length(PDFs)) {
|
||||
tt = PDFs[[Nfile]]
|
||||
PageI <- strg <- POT <- vector(); resIND <- matrix(NA, ncol=2,nrow=3)
|
||||
@@ -160,6 +160,7 @@ server <- function(input, output, session) {
|
||||
|
||||
for (Seite in 1:length(tt)) {
|
||||
Zeilen <- strsplit(tt[Seite], "\n")
|
||||
#Zeilen <- Zeilen[Zeilen != ""]
|
||||
REGEXloc <- grep(pattern='Dose .alue', Zeilen[[1]])
|
||||
if (length(REGEXloc)>0) {
|
||||
#### get Standard ----
|
||||
@@ -227,16 +228,27 @@ server <- function(input, output, session) {
|
||||
for (x in ProdsinPDF) {
|
||||
ZeilenR <- strsplit(tt[resIND[x,1]], "\n")[[1]]
|
||||
ZeilenREF <- ZeilenR[resIND[x,2]:length(ZeilenR)]
|
||||
#ZeilenREF <- ZeilenREF[ZeilenREF != ""]
|
||||
grepDoses <- grep("Dose .alue", ZeilenREF)
|
||||
Doses <- unlist(regmatches(c(ZeilenREF[grepDoses[1]], ZeilenREF[grepDoses[2]]),
|
||||
gregexpr("([0-9]+)\\.?([0-9]+)",
|
||||
c(ZeilenREF[grepDoses[1]], ZeilenREF[grepDoses[2]]))))
|
||||
uniDoses <- as.numeric(unique(Doses))
|
||||
Ndoses <- length(uniDoses)
|
||||
|
||||
grepResponses <- grep(".esponse", ZeilenREF)
|
||||
grepMean <- grep(".ean", ZeilenREF)
|
||||
NoResp <- grepMean[1]-grepResponses[1]
|
||||
|
||||
# test for cancelled outlier
|
||||
grepAUSS <- grep("T",ZeilenREF[grepMean[1]:grepResponses[1]])
|
||||
if (length(grepAUSS)>0) {
|
||||
AnzResp <- grepMean-grepResponses
|
||||
AnzResp <- AnzResp[AnzResp > 0]
|
||||
AnzResp2 <- c(AnzResp, DilSerVec)
|
||||
AnzResp3 <- sort(table(AnzResp2),decreasing = T)[1]
|
||||
NoResp <- as.numeric(names(AnzResp3))
|
||||
}
|
||||
|
||||
IND <- c(grepDoses)
|
||||
StepIX <- IND+1
|
||||
INDresp1 <- grepResponses
|
||||
@@ -250,7 +262,7 @@ server <- function(input, output, session) {
|
||||
}
|
||||
Step <- unlist(regmatches(ZeilenREF[StepIX[1]], gregexpr("([0-9]+)", ZeilenREF[StepIX[1]])))
|
||||
maxStep <- max(as.numeric(Step))
|
||||
|
||||
browser()
|
||||
resStep <- Ndoses-maxStep
|
||||
if (maxStep== (Ndoses-1)) {
|
||||
ref_data <- data.frame(c(Responses[[1]][1:maxStep], Responses[[2]][1]),
|
||||
@@ -269,7 +281,7 @@ server <- function(input, output, session) {
|
||||
if (x==1) colnames(ref_data) <- c(paste0(REF, "_1"), paste0(REF, "_2"), paste0(REF, "_3"))
|
||||
if (x==2) colnames(ref_data) <- c(paste0(TEST1, "_1"), paste0(TEST1, "_2"), paste0(TEST1, "_3"))
|
||||
if (x==3) colnames(ref_data) <- c(paste0(TEST2, "_1"), paste0(TEST2, "_2"), paste0(TEST2, "_3"))
|
||||
|
||||
|
||||
if (!exists("ALLE3")) {
|
||||
ALLE3 <- ref_data
|
||||
} else { ALLE3 <- cbind(ALLE3, ref_data) }
|
||||
@@ -326,7 +338,7 @@ server <- function(input, output, session) {
|
||||
|
||||
PotM1_ <- as.matrix(PotM1)
|
||||
colnames(PotM1_) <- names(PotM1)
|
||||
PotM1 <- cbind(rep(filenames[pdfInd], nrow(PotM1_)), PotM1_)
|
||||
PotM1_ <- cbind(rep(filenames[pdfInd], nrow(PotM1_)), PotM1_)
|
||||
CalcPot[[pdfInd]] <- PotM1_
|
||||
if (!exists("CalcPotDF")) CalcPotDF <- PotM1_ else CalcPotDF <- rbind(CalcPotDF, PotM1_)
|
||||
|
||||
@@ -367,7 +379,7 @@ server <- function(input, output, session) {
|
||||
if (!exists("SIGtestDF")) {
|
||||
if (exists("dfPlotsigTest2")) SIGtestDF <- rbind(dfPlotsigTest1, dfPlotsigTest2) else SIGtestDF <- dfPlotsigTest1
|
||||
} else {
|
||||
if (exists("dfPlotsigTest2")) SIGtestDF <- rbind(SIGtestDF,dfPlotsigTest1, dfPlotsigTest2) else SIGtestDF <- rbind(dfPlotsigTest1, dfPlotsigTest2)
|
||||
if (exists("dfPlotsigTest2")) SIGtestDF <- rbind(SIGtestDF,dfPlotsigTest1, dfPlotsigTest2) else SIGtestDF <- rbind(SIGtestDF, dfPlotsigTest1)
|
||||
}
|
||||
} # pdfInd
|
||||
|
||||
@@ -391,7 +403,7 @@ server <- function(input, output, session) {
|
||||
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))) +
|
||||
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) +
|
||||
@@ -406,7 +418,7 @@ server <- function(input, output, session) {
|
||||
|
||||
PLOTS$sigPlotREF <- p1
|
||||
|
||||
p2 <- ggplot(SIGtestDF, aes(x_X, y=sigTest, col=as.factor(Prod))) +
|
||||
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) +
|
||||
@@ -438,7 +450,7 @@ server <- function(input, output, session) {
|
||||
|
||||
#### Calculated Potencies table ----
|
||||
|
||||
colnames(CalcPotDF) <- c("pdf","rel. potency","lowerCI","upperCI","lower CI puerErr","upper CI pureErr")
|
||||
colnames(CalcPotDF) <- c("pdf","rel. potency","lowerCI","upperCI","lowerCI pureErr","upperCI pureErr")
|
||||
SampleNamesL <- Dat$SampleNamesL
|
||||
SampleNames <- unlist(SampleNamesL)
|
||||
if (length(SampleNames)/length(SampleNamesL) == 3) {
|
||||
@@ -459,14 +471,14 @@ server <- function(input, output, session) {
|
||||
output$CalcPotDF <- renderTable({ CalcPotDF2 })
|
||||
#### CI plots ----
|
||||
CalcPotDF_ <- CalcPotDF[,c(1,7,8)]
|
||||
all_lPot <- melt(as.data.frame(CalcPotDF_, id.vars="pdf",variable.name="var", value.name="Climit"))
|
||||
all_lPot <- melt(as.data.frame(CalcPotDF_), id.vars="pdf",variable.name="var", value.name="Climit")
|
||||
all_lPot[,3] <- as.numeric(all_lPot[,3])
|
||||
all_lPot[,3][all_lPot[,3] > 5] <- NA
|
||||
all_lPot[,3][all_lPot[,3] < 0.1] <- NA
|
||||
|
||||
P_histCI <- ggplot(all_lPot, aes(x=Climit, fill=var)) +
|
||||
geom_histogram(color="#e9ecef", alpha=0.6, position = "identity") +
|
||||
scale-fill-manual(values=c("darkgreen","darkblue","salmon2","tomato3")) +
|
||||
scale_fill_manual(values=c("darkgreen","darkblue","salmon2","tomato3")) +
|
||||
ggtitle("Histogram of relative potencies, standard RMSEs") +
|
||||
scale_x_continuous(
|
||||
breaks=seq(trunc(min(all_lPot$Climit, na.rm=T)*10)/10, max(all_lPot$Climit, na.rm=T)*1.1, by=0.2),
|
||||
@@ -480,14 +492,14 @@ server <- function(input, output, session) {
|
||||
|
||||
|
||||
CalcPotDF_Pure <- CalcPotDF[,c(1,9,10)]
|
||||
all_lPotPure <- melt(as.data.frame(CalcPotDF_Pure, id.vars="pdf",variable.name="var", value.name="Climit"))
|
||||
all_lPotPure <- melt(as.data.frame(CalcPotDF_Pure), id.vars="pdf",variable.name="var", value.name="Climit")
|
||||
all_lPotPure[,3][all_lPotPure[,3] == 0] <- NA
|
||||
all_lPotPure[,3][all_lPotPure[,3] > 5] <- NA
|
||||
all_lPotPure[,3][all_lPotPure[,3] < 0.1] <- NA
|
||||
|
||||
P_histCIPure <- ggplot(all_lPotPure, aes(x=Climit, fill=var)) +
|
||||
geom_histogram(color="#e9ecef", alpha=0.6, position = "identity") +
|
||||
scale-fill-manual(values=c("darkgreen","darkblue","salmon2","tomato3")) +
|
||||
scale_fill_manual(values=c("darkgreen","darkblue","salmon2","tomato3")) +
|
||||
ggtitle("Histogram of relative potencies, pure error") +
|
||||
scale_x_continuous(
|
||||
breaks=seq(trunc(min(all_lPotPure$Climit, na.rm=T)*10)/10, max(all_lPotPure$Climit, na.rm=T)*1.1, by=0.2),
|
||||
@@ -514,23 +526,33 @@ server <- function(input, output, session) {
|
||||
if (inherits(r, "try-error")) return(NA)
|
||||
return(r)
|
||||
}
|
||||
uCIGumbel <- fitdistr(logCPDF_[,3], dg,start=list(loc=1,scale=1))
|
||||
lCIGumbel <- fitdistr(logCPDF_[,2], dg,start=list(loc=1,scale=1))
|
||||
Gumbel <- c(rev(dgumbel(seq(0,0.5,0.01), loc=uCIGumbel$extimate[1], scale=uCIGumbel$extimate[2])), dgumbel(seq(0,0.5,0.01), loc=uCIGumbel$extimate[1], scale=uCIGumbel$extimate[2]))
|
||||
|
||||
GumbelDF <- as.data.frame(cbind(X=seq(-0.5,0.5,0.01), Gumbel))
|
||||
all_lPotPure <- melt(as.data.frame(logCPDF_), id.vars="pdf",variable.name = "var",value.name="Climit")
|
||||
all_lPotPure[,3][all_lPotPure[,3] == 0] <- NA
|
||||
|
||||
uEAC099 <- exp(qgumbel(0.99, uCIGumbel$estimate[1],uCIGumbel$estimate[2]))*100
|
||||
lEAC001 <- exp(-qgumbel(0.99, uCIGumbel$estimate[1],uCIGumbel$estimate[2]))*100
|
||||
uEAC095 <- exp(qgumbel(0.95, uCIGumbel$estimate[1],uCIGumbel$estimate[2]))*100
|
||||
lEAC005 <- exp(-qgumbel(0.95, uCIGumbel$estimate[1],uCIGumbel$estimate[2]))*100
|
||||
|
||||
uCIGumbel <- tryCatch({MASS::fitdistr(logCPDF_[,3], dg,start=list(loc=1,scale=1)) },
|
||||
error = function(msg) {
|
||||
return(-1)
|
||||
})
|
||||
if (length(uCIGumbel)>1) {
|
||||
#lCIGumbel <- fitdistr(logCPDF_[,2], dg,start=list(loc=1,scale=1))
|
||||
Gumbel <- c(rev(dgumbel(seq(0,0.5,0.01), loc=uCIGumbel$extimate[1], scale=uCIGumbel$extimate[2])), dgumbel(seq(0,0.5,0.01), loc=uCIGumbel$extimate[1], scale=uCIGumbel$extimate[2]))
|
||||
|
||||
GumbelDF <- as.data.frame(cbind(X=seq(-0.5,0.5,0.01), Gumbel))
|
||||
all_lPotPure <- melt(as.data.frame(logCPDF_), id.vars="pdf",variable.name = "var",value.name="Climit")
|
||||
all_lPotPure[,3][all_lPotPure[,3] == 0] <- NA
|
||||
|
||||
uEAC099 <- exp(qgumbel(0.99, uCIGumbel$estimate[1],uCIGumbel$estimate[2]))*100
|
||||
lEAC001 <- exp(-qgumbel(0.99, uCIGumbel$estimate[1],uCIGumbel$estimate[2]))*100
|
||||
uEAC095 <- exp(qgumbel(0.95, uCIGumbel$estimate[1],uCIGumbel$estimate[2]))*100
|
||||
lEAC005 <- exp(-qgumbel(0.95, uCIGumbel$estimate[1],uCIGumbel$estimate[2]))*100
|
||||
} else {
|
||||
uEAC099 <- exp(quantile(0.99, logCPDF_[,3]))*100
|
||||
lEAC001 <- exp(-quantile(0.99, logCPDF_[,3]))*100
|
||||
uEAC095 <- exp(quantile(0.95, logCPDF_[,3]))*100
|
||||
uEAC099 <- exp(-quantile(0.99, logCPDF_[,3]))*100
|
||||
}
|
||||
output$GumbelPlot <- renderPlot({
|
||||
hist(all_lPotPure$Climit, breaks = 50, xlab="log(relative CLs)",
|
||||
main=paste("calculated EACs 99%:",round(lEAC001,0)), "-", round(uEAC099,0), " 95%", round(lEAC005,0), "-",round(uEAC095,0))
|
||||
lines(GumbelDF$X, GumbelDF$Gumbel)
|
||||
if (length(uCIGumbel)>1) { lines(GumbelDF$X, GumbelDF$Gumbel) }
|
||||
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user