Skip to content

Commit

Permalink
remove closeAllConnections() and use donttest for pkgdown to work
Browse files Browse the repository at this point in the history
  • Loading branch information
RC-88 committed May 1, 2023
1 parent 500f4f2 commit 55fad80
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 21 deletions.
8 changes: 5 additions & 3 deletions R/cadra.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
#'
#' @examples
#'
#'\donttest{
#'
#' # Load pre-computed feature set
#' data(sim_FS)
#'
Expand All @@ -96,16 +98,16 @@
#' set.seed(21)
#'
#' # Define additional parameters and start the function
#' # DONNOT RUN as this would take some time
#' cadra_result <- CaDrA(
#' FS = sim_FS, input_score = sim_Scores, method = "ks_pval",
#' weight = NULL, alternative = "less", top_N = 1,
#' search_start = NULL, search_method = "both", max_size = 7,
#' n_perm = 10, plot = FALSE, smooth = TRUE, obs_best_score = NULL,
#' ncores = 1, cache_path = NULL
#' )
#'
#' # Close all open connections
#' closeAllConnections()
#'
#'}
#'
#' @export
#' @import R.cache doParallel ggplot2 plyr methods SummarizedExperiment
Expand Down
8 changes: 5 additions & 3 deletions man/CaDrA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 54 additions & 15 deletions tests/testthat/test-cadra.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ test_that("CaDrA returns expected result for ks algorithm",{
"search_start", "search_method", "max_size"))
testthat::expect_type(result$key$FS, "double")

testthat::expect_length(result$perm_best_scores, 10L)
testthat::expect_equal(round(result$perm_best_scores,5),
testthat::expect_equal(round(result$perm_best_scores[1:10],5),
c("TN_981"=13.13674,
"TN_519"=16.10120,
"TN_490"=14.50847,
Expand All @@ -55,8 +54,16 @@ test_that("CaDrA returns expected result for ks algorithm",{
"TN_352"=14.60017))

testthat::expect_equal(round(result$obs_best_score,5), c("TN_716"=14.90173))
testthat::expect_equal(round(result$perm_pval,7), c(0.5454545))

# A smooth factor of 1
c <- 1

#Add a smoothing factor of 1
#This is just to not return a p-value of 0
testthat::expect_equal(
round((sum(result$perm_best_scores[1:10] > result$obs_best_score)+c)/(10+c),7),
c(0.5454545)
)

set.seed(21)
# ks_score
Expand Down Expand Up @@ -90,8 +97,7 @@ test_that("CaDrA returns expected result for ks algorithm",{
"search_start", "search_method", "max_size"))
testthat::expect_type(result$key$FS, "double")

testthat::expect_length(result$perm_best_scores, 10L)
testthat::expect_equal(round(result$perm_best_scores,2),
testthat::expect_equal(round(result$perm_best_scores[1:10],2),
c("TN_641"=0.97,
"TN_738"=0.99,
"TN_667"=0.99,
Expand All @@ -104,7 +110,16 @@ test_that("CaDrA returns expected result for ks algorithm",{
"TN_550"=0.95))

testthat::expect_equal(round(result$obs_best_score,2), c("TN_278"=0.98))
testthat::expect_equal(round(result$perm_pval,6), c(0.363636))

# A smooth factor of 1
c <- 1

#Add a smoothing factor of 1
#This is just to not return a p-value of 0
testthat::expect_equal(
round((sum(result$perm_best_scores[1:10] > result$obs_best_score)+c)/(10+c),6),
c(0.363636)
)

})

Expand Down Expand Up @@ -151,8 +166,7 @@ test_that("CaDrA returns expected result for Wilcoxon algorithm",{
"search_start", "search_method", "max_size"))
testthat::expect_type(result$key$FS, "double")

testthat::expect_length(result$perm_best_scores, 10L)
testthat::expect_equal(round(result$perm_best_scores,5),
testthat::expect_equal(round(result$perm_best_scores[1:10],5),
c("TN_674"=25.40974,
"TN_651"=29.96859,
"TN_490"=23.87704,
Expand All @@ -164,7 +178,16 @@ test_that("CaDrA returns expected result for Wilcoxon algorithm",{
"TN_296"=22.09454,
"TN_352"=23.90527))
testthat::expect_equal(round(result$obs_best_score,5), c("TP_9"=27.75113))
testthat::expect_equal(round(result$perm_pval,6), c(0.272727))

# A smooth factor of 1
c <- 1

#Add a smoothing factor of 1
#This is just to not return a p-value of 0
testthat::expect_equal(
round((sum(result$perm_best_scores[1:10] > result$obs_best_score)+c)/(10+c),6),
c(0.272727)
)


set.seed(21)
Expand Down Expand Up @@ -201,8 +224,7 @@ test_that("CaDrA returns expected result for Wilcoxon algorithm",{
"search_start", "search_method", "max_size"))
testthat::expect_type(result$key$FS, "double")

testthat::expect_length(result$perm_best_scores, 10L)
testthat::expect_equal(result$perm_best_scores,
testthat::expect_equal(result$perm_best_scores[1:10],
c("TN_446"=2154,
"TN_441"=2121,
"TN_791"=2142,
Expand All @@ -214,7 +236,16 @@ test_that("CaDrA returns expected result for Wilcoxon algorithm",{
"TN_891"=2145,
"TN_691"=2011))
testthat::expect_equal(result$obs_best_score, c("TN_277"=2150))
testthat::expect_equal(round(result$perm_pval,6), c(0.272727))

# A smooth factor of 1
c <- 1

#Add a smoothing factor of 1
#This is just to not return a p-value of 0
testthat::expect_equal(
round((sum(result$perm_best_scores[1:10] > result$obs_best_score)+c)/(10+c),6),
c(0.272727)
)
})


Expand Down Expand Up @@ -261,8 +292,7 @@ test_that("CaDrA returns expected result for Revealer algorithm",{
"search_start", "search_method", "max_size"))
testthat::expect_type(result$key$FS, "double")

testthat::expect_length(result$perm_best_scores, 10L)
testthat::expect_equal(round(result$perm_best_scores,7),
testthat::expect_equal(round(result$perm_best_scores[1:10],7),
c("TN_607"=0.6187632,
"TN_651"=0.6875289,
"TN_490"=0.6527741,
Expand All @@ -274,7 +304,16 @@ test_that("CaDrA returns expected result for Revealer algorithm",{
"TN_432"=0.6196864,
"TN_282"=0.6366899))
testthat::expect_equal(round(result$obs_best_score,5), c("TN_716"=0.68911))
testthat::expect_equal(round(result$perm_pval,6), c(0.181818))

# A smooth factor of 1
c <- 1

#Add a smoothing factor of 1
#This is just to not return a p-value of 0
testthat::expect_equal(
round((sum(result$perm_best_scores[1:10] > result$obs_best_score)+c)/(10+c),6),
c(0.181818)
)

})

Expand Down

0 comments on commit 55fad80

Please sign in to comment.