Skip to content

Commit

Permalink
Merge branch 'master' into reference
Browse files Browse the repository at this point in the history
  • Loading branch information
myushen authored Aug 19, 2024
2 parents b5b6cc2 + 5d9409e commit e050870
Show file tree
Hide file tree
Showing 11 changed files with 1,198 additions and 108 deletions.
3 changes: 3 additions & 0 deletions R/methods.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Specify undefined global variables for R CMD check
utils::globalVariables(c("shape", "size", "text", ":="))

#the class definition
InputHeatmap<-setClass(
"InputHeatmap",
Expand Down
9 changes: 8 additions & 1 deletion R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,14 @@ get_top_left_annotation = function(.data_, .column, .row, .abundance, annotation

# If it is a list of colors
else
colorRampPalette(palette_annotation$discrete[[.y]])(length(unique(.x))) %>% setNames(unique(.x))
if (is(.x, "factor")) {
color_vector <- palette_annotation$discrete[[.y]] %>% setNames(levels(.x))
color_vector[!is.na(names(color_vector))]

} else {
colorRampPalette(palette_annotation$discrete[[.y]])(length(unique(.x))) %>% setNames(unique(.x))
}

} else if (.x %>% class %in% c("integer", "numerical", "numeric", "double")){

# If is colorRamp
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/tests/grouped-annotated-heatmap-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 14 additions & 14 deletions tests/testthat/_snaps/tests/grouped-custom-color-both.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 33 additions & 33 deletions tests/testthat/_snaps/tests/legend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e050870

Please sign in to comment.