Skip to content

Commit

Permalink
add another check for data_lst unique class
Browse files Browse the repository at this point in the history
  • Loading branch information
MelodyJIN-Y committed Nov 13, 2024
1 parent 861773a commit 24c8975
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/create_genesets.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ length 2 for hexagon bins")
stop("Input bin_type is not supported. Supported bin_type is
rectangle/square or hexagon.")
}

if (length(unique(vapply(data_lst,class,FUN.VALUE = character(1)))) != 1) {
if (length(unique(vapply(data_lst, function(x) class(x)[1],
FUN.VALUE = character(1)))) != 1) {
stop("The input data_lst contains elements from multiple classes")
}
if (length(names(data_lst)) == 0){
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-create_genesets.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ expect_error(create_genesets(data_lst=list("a" = trans, "b" = list()),
bin_param=c(2,2),cluster_info = NULL,
w_x=c(0,25), w_y=c(0,25)))

expect_error(create_genesets(data_lst=list("a" = as.matrix(trans),
"b" = as.data.frame(trans)),
name_lst=list(dummy_W=c("A")),
bin_type="square",
bin_param=c(2,2),cluster_info = NULL,
w_x=c(0,25), w_y=c(0,25)))
expect_error(create_genesets(data_lst= list(trans),
name_lst=list(dummy_W=c("A")),
bin_type="square",
Expand Down

0 comments on commit 24c8975

Please sign in to comment.