Skip to content

Commit

Permalink
Vucinick patch (#10)
Browse files Browse the repository at this point in the history
* Update test-cli.R

Please check if this is correct.

* Update test-run.R

`run_single_sample()` and `run_integration()` are soft-deprecated since scdrake 1.4.0.  Using `run_single_sample_r()` and `run_integration_r()` instead.

* Aesthetics: orders cluster numbers by ascending.

Clusters were ordered in the following manner 1, 10, 11, 12, 13 .. etc. Changed to 1, 2, 3, 4 etc.

* Visually improved markers report:

If numbered clusters, order by numbers. Otherwise, keep it as is.

* Fixes plotting clustree when best k is in CLUSTER_KMEANS_K parameter

Bug noticed by Lucie Pfeiferova. Error when tryint to create a tibble:  Column name `k1` must not be duplicated. Tibble wouldn't have unique column names because best would be a part of the k values. Fixed by taking only unique values.

* fix exit code in run_tests.R

* Removes forgotten lines

* Removes unnecessary as.character()

* remove unnecessary test

* fix exit status

---------

Co-authored-by: Jiri Novotny <jiri.novotny@img.cas.cz>
  • Loading branch information
vucinick and gorgitko authored Aug 31, 2024
1 parent 9bdf431 commit d859db4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
4 changes: 4 additions & 0 deletions R/markers.R
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,10 @@ generate_markers_results_section <- function(df, group_var, dt_order_by, base_ou

df_list <- dplyr::group_split(df) %>%
set_names(dplyr::group_keys(df) %>% dplyr::pull(!!sym(group_var)))

if (!any(names(df_list) %in% c("binom", "t", "wilcox"))) {
df_list <- df_list[order(names(df_list))]
}

z <- lapply(names(df_list), function(name) {
md_header(name, 4)
Expand Down
9 changes: 3 additions & 6 deletions R/visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -577,19 +577,16 @@ dimred_plots_from_params_df <- function(sce_dimred, dimred_plots_params_df) {
#' @concept sce_visualization
#' @export
plot_clustree <- function(cluster_list, params, prefix, title = deparse(substitute(cluster_list)), edge_arrow = FALSE, highlight_core = TRUE, ...) {
cluster_list <- unique(cluster_list)
params <- unique(params)

assert_that_(length(cluster_list) == length(params))

clustree_list <- cluster_list %>%
purrr::map(as.character) %>%
set_names(glue("{prefix}{params}")) %>%
purrr::map(as.integer)

# if (length(params) == 1) {
# title <- glue("{title} ({prefix} {params})")
# } else {
# title <- glue("{title} ({prefix} {params[1]}-{params[length(params)]})")
# }

clustree(tibble::as_tibble(clustree_list), prefix = prefix, edge_arrow = edge_arrow, highlight_core = highlight_core) +
ggplot2::ggtitle(title)
}
Expand Down
2 changes: 1 addition & 1 deletion dev/run_tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,6 @@ if (output_dir != "-") {
cli::cli_alert_success("Writing {.file {out_file}}")
}

status <- dplyr::if_else(res_summary$failed == 0, 0, 1)
status <- dplyr::if_else(all(c(res_summary$failed, res_summary$error) == 0), 0, 1)
cli::cli_alert_info("Exiting with status {.val {status}}")
quit(save = "no", status = status)
2 changes: 1 addition & 1 deletion tests/testthat/test-cli.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cli::cli_h1("{.file tests/testthat/test-run_cli.R}")
cli::cli_h1("{.file tests/testthat/test-cli.R}")

cli_dir <- fs::path(get_tmp_dir(), glue("scdrake-cli-bin-test-{get_random_strings(1, 10)}")) %>% fs::path_abs()
withr::local_envvar(PATH = str_c(cli_dir, Sys.getenv("PATH"), sep = ":"))
Expand Down
22 changes: 0 additions & 22 deletions tests/testthat/test-run.R

This file was deleted.

0 comments on commit d859db4

Please sign in to comment.