Skip to content

Commit

Permalink
Color palette fix, additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oligomyeggo committed Jan 31, 2024
1 parent 6bacbf7 commit 3eef54c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/experiments_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ add_cluster_annotations <- function(seurat_obj, cluster_obj, silent = FALSE){
}
annotation_set <- data.frame(
factor(cluster_number),
factor(cluster_display_name),
factor(cluster_color)
cluster_display_name,
cluster_color
)
colnames(annotation_set) <- c(target_res, clean_display_name, "cluster_color")
annotation_map <- annotation_set[c(target_res, clean_display_name)]
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ CUSTOM_ANNOTATION_SETS <- c("cell_types",
"default_clusters_res_0_4",
"default_clusters_res_0_6",
"default_clusters_res_1_0")
NUM_COLOR_PALETTES <- 5
CLUSTER_COLOR_CHECK_1 <- "#e056fd"
CLUSTER_COLOR_CHECK_2 <- "#6366f1"
6 changes: 6 additions & 0 deletions tests/testthat/test-experiments_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,18 @@ test_that("pluto_read_seurat_object final works", {
expected_cells <- NUM_EXPT_CELLS_FINAL_SCRNASEQ
expected_cols <- NUM_EXPT_COLS_FINAL_SCRNASEQ_WA
expected_annotation_sets <- CUSTOM_ANNOTATION_SETS
expected_palettes <- NUM_COLOR_PALETTES
expected_color_1 <- CLUSTER_COLOR_CHECK_1
expected_color_2 <- CLUSTER_COLOR_CHECK_2
so <- pluto_read_seurat_object(experiment_id = TESTTHAT_EXPT_ID_SCRNASEQ,
seurat_type = "final",
silent = FALSE)
expect_equal(nrow(so$obj@meta.data), expected_cells)
expect_equal(ncol(so$obj@meta.data), expected_cols)
expect_in(expected_annotation_sets, colnames(so$obj@meta.data))
expect_equal(length(so$colors), expected_palettes)
expect_equal(so$colors$cell_types[[4]], expected_color_1)
expect_equal(so$colors$default_clusters_res_0_4[[1]], expected_color_2)
})

test_that("pluto_download_seurat_object downloads raw RDS", {
Expand Down

0 comments on commit 3eef54c

Please sign in to comment.