tests/testthat/test_fitDRCurve.R

# test_that(desc = "2d_data_were_outcome_depends_on_OS", code = {
#   y <- c(norm_rel_fc_protein_0_transformed = 0, 
#          norm_rel_fc_protein_0.02_transformed = 0.4215532379877233726262,
#          norm_rel_fc_protein_0.143_transformed = 1.026455783468937177361,
#          norm_rel_fc_protein_1_transformed = 0.9166168400334454569034,
#          norm_rel_fc_protein_5_transformed = 1)
#   
#   x <- c(0, 0.02, .143, 1, 5)
#   xLog <- c(-15, log10(x * 10^-6)[-1])
#   
#   yFit <- TPP:::fitDRCurve(protID = "X020466_44.1_IPI00007956.4", expName = "dummyExp", dose = xLog, response = y, cpd_effect = "stabilized", slBds = c(1,50), verbose = FALSE)
#   
#   ref <- tibble(Protein_ID = "X020466_44.1_IPI00007956.4",
#                 pEC50 = 7.686551133741927444021,
#                 slope = 25.47714239657176449327,
#                 R_sq = 0.9905214207643284751725,
#                 pEC50_outside_conc_range = FALSE,
#                 pEC50_quality_check = "7.68655113374193",
#                 model_converged = TRUE,
#                 sufficient_data_for_fit = TRUE)
#   
#   check1 <- all.equal(ref$pEC50, yFit$pEC50)
#   check2 <- all.equal(ref$slope, yFit$slope)
#   check3 <- all.equal(ref$R_sq, yFit$R_sq)
#   check4 <- all.equal(ref$pEC50_quality_check, yFit$pEC50_quality_check)
#   
#   expect_true(check1 & check2 & check3 & check4)
# })
# 
# ## Test just the ns part to understand why the above code fails on Linux:
# test_that("nls_difference_Linux_Mac", {
#   y <- c(norm_rel_fc_protein_0_transformed = 0, 
#          norm_rel_fc_protein_0.02_transformed = 0.4215532379877233726262,
#          norm_rel_fc_protein_0.143_transformed = 1.026455783468937177361,
#          norm_rel_fc_protein_1_transformed = 0.9166168400334454569034,
#          norm_rel_fc_protein_5_transformed = 1)
#   
#   x <- c(0, 0.02, .143, 1, 5)
#   xLog <- c(-15, log10(x * 10^-6)[-1])
#   
#   fitFct <- as.formula(paste("y ~ 1 / (1 + exp((infl - x) * hill))"))
#   
#   
#   m <- try(nls(formula = as.formula(paste("y ~ 1 / (1 + exp((infl - x) * hill))")), 
#                algorithm = "port", 
#                data = list(x = xLog, y = y), 
#                start = list(hill = 1, infl = -7.7), 
#                lower = c(1.000000, -8.126123), 
#                upper = c(50.000000, -5.728183), 
#                na.action=na.exclude))
#   
# })
# 

Try the TPP package in your browser

Any scripts or data that you put into this service are public.

TPP documentation built on Nov. 8, 2020, 5:55 p.m.