forked from YuLab-SMU/clusterProfiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue is that match.call doesn't capture default arguments. See https://stackoverflow.com/questions/14397364/match-call-with-default-arguments
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
context("Test compareCluster") | ||
|
||
data(gcSample) | ||
gc_small = gcSample[c("X1", "X2", 'X4')] | ||
test_that("compareCluster + KEGG no formula", { | ||
result = compareCluster(gc_small, fun="enrichKEGG", | ||
organism="hsa", pvalueCutoff=0.05) | ||
expect_is(result, 'compareClusterResult') | ||
}) | ||
|
||
|
||
test_that("compareCluster + KEGG + formula", { | ||
gc_small_dat = do.call(rbind, | ||
lapply(names(gc_small), | ||
function(x) data.frame(X = x, entrezID = gc_small[[x]], stringsAsFactors = FALSE) | ||
)) | ||
result = compareCluster(entrezID ~ X, data = gc_small_dat, fun="enrichKEGG", | ||
organism="hsa", pvalueCutoff=0.05) | ||
expect_is(result, 'compareClusterResult') | ||
}) | ||
|
||
test_that("compareCluster + GO no formula", { | ||
result = compareCluster(gc_small, fun="enrichGO", OrgDb = "org.Hs.eg.db", | ||
pvalueCutoff=0.05) | ||
expect_is(result, 'compareClusterResult') | ||
}) | ||
|
||
test_that("compareCluster + GO no formula, default value for function", { | ||
result = compareCluster(gc_small, OrgDb = "org.Hs.eg.db", | ||
pvalueCutoff=0.05) | ||
expect_is(result, 'compareClusterResult') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
context("Test extract_params") | ||
|
||
test_function = function(x, y, z = 'z'){ | ||
this_call = match.call(expand.dots = TRUE) | ||
return(extract_params(this_call)) | ||
} | ||
|
||
test_that("Can extract position parameters", { | ||
params = test_function(1, 2, 3) | ||
expect_equal(params, list(x = "1", y = "2", z = "3")) | ||
# note these are coerced to character, might not be desirable.. | ||
}) | ||
|
||
test_that("Can extract keyword parameters", { | ||
params = test_function(x = 1, z = 3, y = 2) | ||
expect_equal(params, list(x = "1", y = "2", z = "3")) | ||
}) | ||
|
||
test_that("Can extract default parameters", { | ||
params = test_function(x = 1, y = 2) | ||
expect_equal(params, list(x = "1", y = "2", z = "z")) | ||
}) |