IMPORTANT added linting configuration
linting can be started by clicking Addins in RStudio, then "Lint current file". This commit also contains quick fixes for common linter messages like changing F to FALSE and T to TRUE.
This commit is contained in:
+42
-42
@@ -45,7 +45,7 @@ library(scales)
|
||||
#' Dat <- list()
|
||||
#' te <- Fitting_FUNC(dat, TransF)
|
||||
#' print(te)
|
||||
Fitting_FUNC <- function(ro_new, TransFlag = F) {
|
||||
Fitting_FUNC <- function(ro_new, TransFlag = FALSE) {
|
||||
CORro <- cor(ro_new[, 1], ro_new[, ncol(ro_new)])
|
||||
# browser()
|
||||
all_l <- melt(data.frame(ro_new), id.vars = "log_dose", variable.name = "replname", value.name = "readout")
|
||||
@@ -268,7 +268,7 @@ plotSingularity <- function(dat) { # sigmoid,det_sig,
|
||||
#' Dat <- list()
|
||||
#' p <- plot_f(dat, sigmoid, det_sig, TransF)
|
||||
#' print(p)
|
||||
plot_f <- function(dat, TransFlag = F) { # sigmoid,det_sig,
|
||||
plot_f <- function(dat, TransFlag = FALSE) { # sigmoid,det_sig,
|
||||
CORdat <- cor(dat[, 1], dat[, ncol(dat)])
|
||||
# browser()
|
||||
all_l <- melt(data.frame(dat), id.vars = "log_dose", variable.name = "replname", value.name = "readout")
|
||||
@@ -276,7 +276,7 @@ plot_f <- function(dat, TransFlag = F) { # sigmoid,det_sig,
|
||||
isSample <- rep(c(0, 1), 1, each = nrow(all_l) / 2)
|
||||
all_l2 <- cbind(all_l, isRef, isSample)
|
||||
# browser()
|
||||
MODLS <- Fitting_FUNC(dat, TransFlag = F)
|
||||
MODLS <- Fitting_FUNC(dat, TransFlag = FALSE)
|
||||
s_mr <- MODLS[[1]]
|
||||
a <- s_mr$coefficients["a", 1]
|
||||
b <- s_mr$coefficients["b", 1]
|
||||
@@ -340,23 +340,23 @@ plot_f <- function(dat, TransFlag = F) { # sigmoid,det_sig,
|
||||
scale_x_continuous(breaks = scales::pretty_breaks(n = 10)) +
|
||||
scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
|
||||
# theme_bw() +
|
||||
theme(axis.text.x = element_text(size = 12, angle=90), axis.text.y = element_text(size = 12))
|
||||
theme(axis.text.x = element_text(size = 12, angle = 90), axis.text.y = element_text(size = 12))
|
||||
|
||||
p2 <- p + geom_line(
|
||||
data = as.data.frame(pl_df), aes(x = seq_x, y = SAMPLE), color = "#C2173F",
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
geom_line(
|
||||
data = as.data.frame(pl_df), aes(x = seq_x, y = REF), color = "#4545BA",
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
geom_line(
|
||||
data = as.data.frame(pl_df), aes(x = seq_x, y = SAMPLEtrue), color = "#C2173F", linetype = 2, alpha = 0.4,
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
geom_line(
|
||||
data = as.data.frame(pl_df), aes(x = seq_x, y = REFtrue), color = "#4545BA", linetype = 2, alpha = 0.4,
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
geom_vline(xintercept = c(Xbendl3, Xbendu3), col = "#4545BA", linetype = 2) +
|
||||
geom_vline(xintercept = c(XbendlT, XbenduT), col = "#C2173F", linetype = 2) +
|
||||
@@ -397,11 +397,11 @@ plot_f <- function(dat, TransFlag = F) { # sigmoid,det_sig,
|
||||
pl_df_trans <- cbind(seq_x, SAMPLEtrans, REFtrans)
|
||||
p_rt2 <- p_rt + geom_line(
|
||||
data = as.data.frame(pl_df_trans), aes(x = seq_x, y = SAMPLEtrans), color = "#C2173F",
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
geom_line(
|
||||
data = as.data.frame(pl_df_trans), aes(x = seq_x, y = REFtrans), color = "#4545BA",
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
geom_vline(xintercept = c(XbendlTrans, XbenduTrans), col = "#4545BA", linetype = 2) +
|
||||
geom_vline(xintercept = c(XbendlTransT, XbenduTransT), col = "#C2173F", linetype = 2) +
|
||||
@@ -419,8 +419,8 @@ plot_f <- function(dat, TransFlag = F) { # sigmoid,det_sig,
|
||||
cte <- Sum_u$coefficients["cs", 1] - Sum_u$coefficients["r", 1]
|
||||
dst <- Sum_u$coefficients["ds", 1]
|
||||
dte <- Sum_u$coefficients["dt", 1]
|
||||
|
||||
|
||||
|
||||
|
||||
REFu <- ast + (dst - ast) / (1 + exp(bst * (cst - seq_x)))
|
||||
SAMPLEu <- ate + (dte - ate) / (1 + exp(bte * (cte - seq_x)))
|
||||
pl_df2 <- cbind(seq_x, SAMPLEu, REFu)
|
||||
@@ -432,12 +432,12 @@ plot_f <- function(dat, TransFlag = F) { # sigmoid,det_sig,
|
||||
theme_bw()
|
||||
pu2 <- pu + geom_line(
|
||||
data = as.data.frame(pl_df2), aes(x = seq_x, y = SAMPLEu),
|
||||
color = "#C2173F", inherit.aes = F
|
||||
color = "#C2173F", inherit.aes = FALSE
|
||||
) +
|
||||
geom_line(
|
||||
data = as.data.frame(pl_df2), aes(x = seq_x, y = REFu),
|
||||
color = "#4545BA", inherit.aes = F,
|
||||
show.legend = F
|
||||
color = "#4545BA", inherit.aes = FALSE,
|
||||
show.legend = FALSE
|
||||
)
|
||||
pu2_ <- pu2 +
|
||||
theme(legend.position = "none", axis.text = element_text(size = 14))
|
||||
@@ -465,12 +465,12 @@ plot_f <- function(dat, TransFlag = F) { # sigmoid,det_sig,
|
||||
|
||||
pu2_t <- putrans + geom_line(
|
||||
data = as.data.frame(pl_df2u_t), aes(x = seq_x, y = SAMPLEu_trans),
|
||||
color = "#C2173F", inherit.aes = F
|
||||
color = "#C2173F", inherit.aes = FALSE
|
||||
) +
|
||||
geom_line(
|
||||
data = as.data.frame(pl_df2u_t), aes(x = seq_x, y = REFu_trans),
|
||||
color = "#4545BA", inherit.aes = F,
|
||||
show.legend = F
|
||||
color = "#4545BA", inherit.aes = FALSE,
|
||||
show.legend = FALSE
|
||||
)
|
||||
pu3_t <- pu2_t
|
||||
if (TransFlag) grid.arrange(p_rt2, pu3_t, nrow = 1) else grid.arrange(p2, pu2_, nrow = 1)
|
||||
@@ -782,19 +782,19 @@ ANOVAlintests <- function(ro_new, circles, Lim, PureErrFlag) {
|
||||
# F-test on regression: MSSreg/MSSE
|
||||
if (is.na(F_nonlin)) F_nonlin <- 0
|
||||
if (F_nonlin > 0) {
|
||||
p_F_nonlin <- round(pf(F_nonlin, 2, dfPureE, lower.tail = F), 5)
|
||||
p_F_nonlin <- round(pf(F_nonlin, 2, dfPureE, lower.tail = FALSE), 5)
|
||||
} else {
|
||||
p_F_nonlin <- "SSnonlin neg or 0"
|
||||
}
|
||||
|
||||
# significances
|
||||
F_regr <- (SSreg / 1) / (SSRes / dfRes)
|
||||
p_F_regr <- round(pf(F_regr, 1, dfRes, lower.tail = F), 3)
|
||||
p_F_treat <- round(pf(F_treat, 3, dfRes, lower.tail = F), 3)
|
||||
p_F_prep <- round(pf(F_prep, 1, dfRes, lower.tail = F), 3)
|
||||
p_F_slope_A <- round(pf(F_slope_A, 1, (nrow(circ_Al) - 2), lower.tail = F), 3)
|
||||
p_F_slope_B <- round(pf(F_slope_B, 1, (nrow(circ_Bl) - 2), lower.tail = F), 3)
|
||||
p_F_nonp <- round(pf(F_nonpar, 1, dfRes, lower.tail = F), 3)
|
||||
p_F_regr <- round(pf(F_regr, 1, dfRes, lower.tail = FALSE), 3)
|
||||
p_F_treat <- round(pf(F_treat, 3, dfRes, lower.tail = FALSE), 3)
|
||||
p_F_prep <- round(pf(F_prep, 1, dfRes, lower.tail = FALSE), 3)
|
||||
p_F_slope_A <- round(pf(F_slope_A, 1, (nrow(circ_Al) - 2), lower.tail = FALSE), 3)
|
||||
p_F_slope_B <- round(pf(F_slope_B, 1, (nrow(circ_Bl) - 2), lower.tail = FALSE), 3)
|
||||
p_F_nonp <- round(pf(F_nonpar, 1, dfRes, lower.tail = FALSE), 3)
|
||||
p_F_LoF <- p_F_nonlin
|
||||
|
||||
res_tab_lin <- data.frame(
|
||||
@@ -869,7 +869,7 @@ ANOVAlintests <- function(ro_new, circles, Lim, PureErrFlag) {
|
||||
#'
|
||||
#' PlotLinPLA_FUNC(circle, sigmoid, all_l2, pl_df, indS, indT)
|
||||
PlotLinPLA_FUNC <- function(circle, sigmoid, all_l2, pl_df, indS, indT) {
|
||||
#browser()
|
||||
# browser()
|
||||
mLin <- gsl_nls(readout ~ (intS + r) * isSample + intS * isRef + k * log_dose,
|
||||
data = circle,
|
||||
start = list(intS = 0, k = 1, r = 0),
|
||||
@@ -901,17 +901,17 @@ PlotLinPLA_FUNC <- function(circle, sigmoid, all_l2, pl_df, indS, indT) {
|
||||
theme_bw()
|
||||
p2 <- p + geom_line(
|
||||
data = pl_df, aes(x = lnC, y = plotS), color = "#4545BA",
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
geom_line(
|
||||
data = pl_df, aes(x = lnC, y = plotT), color = "#C2173F",
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
{
|
||||
if (!is.null(truePL_df)) {
|
||||
geom_line(
|
||||
data = data.frame(truePL_df), aes(x = seq_x, y = SAMPLEtrue), color = "#C2173F", linetype = 2, alpha = 0.4,
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
)
|
||||
}
|
||||
} +
|
||||
@@ -919,7 +919,7 @@ PlotLinPLA_FUNC <- function(circle, sigmoid, all_l2, pl_df, indS, indT) {
|
||||
if (!is.null(truePL_df)) {
|
||||
geom_line(
|
||||
data = data.frame(truePL_df), aes(x = seq_x, y = REFtrue), color = "#4545BA", linetype = 2, alpha = 0.4,
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
)
|
||||
}
|
||||
} +
|
||||
@@ -939,17 +939,17 @@ PlotLinPLA_FUNC <- function(circle, sigmoid, all_l2, pl_df, indS, indT) {
|
||||
|
||||
pr2 <- p + geom_line(
|
||||
data = pl_rest, aes(x = lnC, y = plotS), color = "#4545BA",
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
geom_line(
|
||||
data = pl_rest, aes(x = lnC, y = plotT), color = "#C2173F",
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
) +
|
||||
{
|
||||
if (!is.null(truePL_df)) {
|
||||
geom_line(
|
||||
data = data.frame(truePL_df), aes(x = seq_x, y = SAMPLEtrue), color = "#C2173F", linetype = 2, alpha = 0.4,
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
)
|
||||
}
|
||||
} +
|
||||
@@ -957,7 +957,7 @@ PlotLinPLA_FUNC <- function(circle, sigmoid, all_l2, pl_df, indS, indT) {
|
||||
if (!is.null(truePL_df)) {
|
||||
geom_line(
|
||||
data = data.frame(truePL_df), aes(x = seq_x, y = REFtrue), color = "#4545BA", linetype = 2, alpha = 0.4,
|
||||
inherit.aes = F
|
||||
inherit.aes = FALSE
|
||||
)
|
||||
}
|
||||
} +
|
||||
@@ -1012,7 +1012,7 @@ pot4plFUNC <- function(ro_new, PureErrFlag) {
|
||||
CORdat <- cor(ro_new[, 1], ro_new[, ncol(ro_new)])
|
||||
if (CORdat < 0) SLOPE <- -1 else SLOPE <- 1
|
||||
#
|
||||
FITs <- Fitting_FUNC(ro_new, TransFlag = F)
|
||||
FITs <- Fitting_FUNC(ro_new, TransFlag = FALSE)
|
||||
if (!PureErrFlag) {
|
||||
pot_est <- FITs[[3]]
|
||||
potU_est <- FITs[[4]]
|
||||
@@ -1205,10 +1205,10 @@ tests_FUNC <- function(ro_new, Lim, PureErrFlag) {
|
||||
SSnonlin <- sum((predict(lm(readout ~ factor(Conc) * isSample, all_l)) - predPotU)^2)
|
||||
LoF_df <- FitAnova[1, 1] + FitAnova[2, 1]
|
||||
F_regr <- (SSregr / AnovaDFs[3]) / ERR
|
||||
p_F_regr <- round(pf(F_regr, AnovaDFs[3], ERR_df, lower.tail = F), 5)
|
||||
p_F_regr <- round(pf(F_regr, AnovaDFs[3], ERR_df, lower.tail = FALSE), 5)
|
||||
if (ncol(ro_new) < 4) F_nonlin <- 0 else F_nonlin <- (SSnonlin / AnovaDFs[6]) / ERR
|
||||
if (F_nonlin > 0) {
|
||||
p_F_nonlin <- round(pf(F_nonlin, AnovaDFs[6], ERR_df, lower.tail = F), 5)
|
||||
p_F_nonlin <- round(pf(F_nonlin, AnovaDFs[6], ERR_df, lower.tail = FALSE), 5)
|
||||
} else {
|
||||
p_F_nonlin <- "SSnonlin neg or single dilutions"
|
||||
}
|
||||
@@ -1404,11 +1404,11 @@ ANOVA4plUnresfunc <- function(ro_new) {
|
||||
MSE <- RSS / RSS_df
|
||||
noConc <- length(unique(all_l$Conc))
|
||||
AnovaDFs <- c(noConc - 1, 1, 3, noConc - 4 - 1, nrow(all_l) - noConc, noConc, nrow(all_l) - noConc - noConc, nrow(all_l) - 1)
|
||||
p_SStreat <- round(pf((SStreat / AnovaDFs[1]) / MSE, AnovaDFs[1], RSS_df, lower.tail = F), 3)
|
||||
p_SSprep <- round(pf((SSprep / AnovaDFs[2]) / MSE, AnovaDFs[2], RSS_df, lower.tail = F), 3)
|
||||
p_SSregr <- round(pf((SSregr / AnovaDFs[3]) / MSE, AnovaDFs[3], RSS_df, lower.tail = F), 3)
|
||||
p_SSnonp <- round(pf((SSnonparallel / AnovaDFs[4]) / MSE, AnovaDFs[3], RSS_df, lower.tail = F), 3)
|
||||
p_SSLoF <- round(pf((SSnonlin / LoF_df) / (SSE / SSE_df), LoF_df, SSE_df, lower.tail = F), 5)
|
||||
p_SStreat <- round(pf((SStreat / AnovaDFs[1]) / MSE, AnovaDFs[1], RSS_df, lower.tail = FALSE), 3)
|
||||
p_SSprep <- round(pf((SSprep / AnovaDFs[2]) / MSE, AnovaDFs[2], RSS_df, lower.tail = FALSE), 3)
|
||||
p_SSregr <- round(pf((SSregr / AnovaDFs[3]) / MSE, AnovaDFs[3], RSS_df, lower.tail = FALSE), 3)
|
||||
p_SSnonp <- round(pf((SSnonparallel / AnovaDFs[4]) / MSE, AnovaDFs[3], RSS_df, lower.tail = FALSE), 3)
|
||||
p_SSLoF <- round(pf((SSnonlin / LoF_df) / (SSE / SSE_df), LoF_df, SSE_df, lower.tail = FALSE), 5)
|
||||
|
||||
ANOVAtab <- data.frame(
|
||||
Source = c(
|
||||
|
||||
Reference in New Issue
Block a user