Skip to content

Commit 5e020c4

Browse files
committed
Fixed unit tests.
1 parent 9c6572c commit 5e020c4

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

R/do_RankedEnrichmentHeatmap.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ do_RankedEnrichmentHeatmap <- function(sample,
243243
tidyr::pivot_longer(cols = -dplyr::all_of("Cell"),
244244
names_to = key_col,
245245
values_to = "Score") %>%
246+
dplyr::mutate("{key_col}" := stringr::str_to_upper(.data[[key_col]])) %>%
246247
dplyr::filter(.data[[key_col]] %in% vapply(dims, function(x){paste0(key, x)}, FUN.VALUE = character(1))) %>%
247248
dplyr::group_by(.data[[key_col]]) %>%
248249
dplyr::reframe("rank" = rank(.data$Score),

R/do_RankedExpressionHeatmap.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ do_RankedExpressionHeatmap <- function(sample,
211211
tidyr::pivot_longer(cols = -dplyr::all_of("Cell"),
212212
names_to = key_col,
213213
values_to = "Score") %>%
214+
dplyr::mutate("{key_col}" := stringr::str_to_upper(.data[[key_col]])) %>%
214215
dplyr::filter(.data[[key_col]] %in% vapply(dims, function(x){paste0(key, x)}, FUN.VALUE = character(1))) %>%
215216
dplyr::group_by(.data[[key_col]]) %>%
216217
dplyr::reframe("rank" = rank(.data$Score),
@@ -266,7 +267,6 @@ do_RankedExpressionHeatmap <- function(sample,
266267
dplyr::mutate("Expression" = ifelse(.data$Expression >= limits[2], limits[2], .data$Expression))
267268

268269
# Compute scale limits, breaks etc.
269-
message(limits)
270270
scale.setup <- compute_scales(sample = NULL,
271271
feature = NULL,
272272
assay = NULL,

R/utils.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,10 @@ compute_scales <- function(sample,
12741274

12751275
}
12761276

1277+
if (is.na(limits[1]) || is.na(limits[2])) {
1278+
stop("Invalid axis limits: dmin or dmax is NA.")
1279+
}
1280+
12771281
breaks <- labeling::extended(dmin = limits[1],
12781282
dmax = limits[2],
12791283
m = number.breaks)

tests/testthat/test-do_LoadingsHeatmap.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if (base::isFALSE(dep_check[["do_LoadingsHeatmap"]])){
3535

3636
p <- SCpubr::do_LoadingsHeatmap(sample = sample,
3737
dims = 1:10,
38-
max.cutoff.expresion = 0.5)
38+
max.cutoff.expression = 0.5)
3939
testthat::expect_true(ggplot2::is_ggplot(p))
4040

4141
p <- SCpubr::do_LoadingsHeatmap(sample = sample,

tests/testthat/test-do_RankedExpressionHeatmap.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if (base::isFALSE(dep_check[["do_RankedExpressionHeatmap"]])){
6565
enforce_symmetry = FALSE)
6666
testthat::expect_type(p, "list")
6767

68-
testthat::expect_warning({SCpubr::do_RankedExpressionHeatmap(sample = sample,
68+
SCpubr::do_RankedExpressionHeatmap(sample = sample,
6969
features = genes,
7070
subsample = 100,
7171
reduction = "umap",
@@ -74,9 +74,9 @@ if (base::isFALSE(dep_check[["do_RankedExpressionHeatmap"]])){
7474
verbose = FALSE,
7575
assay = "SCT",
7676
use_viridis = FALSE,
77-
enforce_symmetry = FALSE)})
77+
enforce_symmetry = FALSE)
7878

79-
testthat::expect_warning({SCpubr::do_RankedExpressionHeatmap(sample = sample,
79+
SCpubr::do_RankedExpressionHeatmap(sample = sample,
8080
features = genes,
8181
subsample = 100,
8282
reduction = "umap",
@@ -85,7 +85,7 @@ if (base::isFALSE(dep_check[["do_RankedExpressionHeatmap"]])){
8585
verbose = FALSE,
8686
slot = "data",
8787
use_viridis = FALSE,
88-
enforce_symmetry = FALSE)})
88+
enforce_symmetry = FALSE)
8989

9090
suppressMessages({testthat::expect_message({p <- SCpubr::do_RankedExpressionHeatmap(sample = sample,
9191
features = genes,

0 commit comments

Comments
 (0)