Skip to content

Commit

Permalink
fix: color code checking
Browse files Browse the repository at this point in the history
  • Loading branch information
jiajic committed Jan 8, 2025
1 parent 2433979 commit 555c5ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

# GiottoVisuals 0.2.11

## bug fixes
- fix color code/name checking to allow hex codes in `cell_color` plotting param.

# GiottoVisuals 0.2.10 (2024/12/04)

## bug fixes
Expand Down
20 changes: 10 additions & 10 deletions R/gg_info_layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ plot_spat_point_layer_ggplot <- function(
alpha = point_alpha
)
} else if (is.character(cell_color)) { # cell_color is hex codes
if (!all(cell_color %in% grDevices::colors())) {
if (!all(.is_color_code(cell_color))) {
stop("cell_color is not numeric,
a factor or vector of colors \n")
}
Expand All @@ -164,7 +164,7 @@ plot_spat_point_layer_ggplot <- function(
}
} else if (is.character(cell_color)) {
if (!cell_color %in% colnames(cell_locations_metadata_selected)) {
if (!cell_color %in% grDevices::colors()) {
if (!.is_color_code(cell_color)) {
stop(cell_color, " is not a color or a column name \n")
}
pl <- pl + giotto_point(
Expand Down Expand Up @@ -436,7 +436,7 @@ plot_spat_point_layer_ggplot_noFILL <- function(
...
)
} else if (is.character(cell_color)) {
if (!all(cell_color %in% grDevices::colors())) {
if (!all(.is_color_code(cell_color))) {
stop("cell_color is not numeric, a factor or vector of
colors \n")
}
Expand All @@ -453,7 +453,7 @@ plot_spat_point_layer_ggplot_noFILL <- function(
}
} else if (is.character(cell_color)) {
if (!cell_color %in% colnames(cell_locations_metadata_selected)) {
if (!cell_color %in% grDevices::colors()) {
if (!.is_color_code(cell_color)) {
stop(cell_color, " is not a color or a column name \n")
}
pl <- pl + giotto_point(
Expand Down Expand Up @@ -774,7 +774,7 @@ plot_spat_voronoi_layer_ggplot <- function(
} else if (is.character(cell_color)) {
## 3. character vector to convert to colors ##

if (!all(cell_color %in% grDevices::colors())) {
if (!all(.is_color_code(cell_color))) {
stop("cell_color is not numeric, a factor or vector of
colors \n")
}
Expand Down Expand Up @@ -819,7 +819,7 @@ plot_spat_voronoi_layer_ggplot <- function(
}
} else if (is.character(cell_color)) {
if (!cell_color %in% colnames(cell_locations_metadata_selected)) {
if (!cell_color %in% grDevices::colors()) {
if (!.is_color_code(cell_color)) {
stop(cell_color, " is not a color or a column name \n")
}

Expand Down Expand Up @@ -1698,7 +1698,7 @@ plot_point_layer_ggplot <- function(
alpha = point_alpha
)
} else if (is.character(cell_color)) {
if (!all(cell_color %in% grDevices::colors())) {
if (!all(.is_color_code(cell_color))) {
stop("cell_color is not numeric,
a factor or vector of colors \n")
}
Expand All @@ -1715,7 +1715,7 @@ plot_point_layer_ggplot <- function(
} else if (is.character(cell_color)) {
# color by col values
if (!cell_color %in% colnames(annotated_DT_selected)) {
if (!cell_color %in% grDevices::colors()) {
if (!.is_color_code(cell_color)) {
stop(cell_color, " is not a color or a column name \n")
}
pl <- pl + ggplot2::geom_point(
Expand Down Expand Up @@ -1945,7 +1945,7 @@ plot_point_layer_ggplot_noFILL <- function(ggobject,
alpha = point_alpha
)
} else if (is.character(cell_color)) {
if (!all(cell_color %in% grDevices::colors())) {
if (!all(.is_color_code(cell_color))) {
stop("cell_color is not numeric, a factor or vector
of colors \n")
}
Expand All @@ -1961,7 +1961,7 @@ plot_point_layer_ggplot_noFILL <- function(ggobject,
}
} else if (is.character(cell_color)) {
if (!cell_color %in% colnames(annotated_DT_selected)) {
if (!cell_color %in% grDevices::colors()) {
if (!.is_color_code(cell_color)) {
stop(cell_color, " is not a color or a column name \n")
}
pl <- pl + giotto_point(
Expand Down

0 comments on commit 555c5ed

Please sign in to comment.