-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
enhancementNew feature or requestNew feature or request
Description
It can be helpful to view spatial patterns by overlapping multiple variables. A potential way of doing this is by independently assigning color gradients to the variables and then mixing the colors afterwards.
So far HSV #61 and RGB #62 have been added.
The HSV implementation should work for any two colors.
Additional color overlaps might be best done by mixing in the RGB space.
HSV however, does guarantee a color mixture output orthogonally to white and black, whereas RGB can produce surprisingly bright or dark colors. In both cases, color picking for the gradients is going to be important for interpretability.
Example implementation:
# load data
sl <- GiottoData::loadSubObjectMini("spatLocsObj")
cm <- GiottoData::loadSubObjectMini("cellMetaObj")
comb <- merge(sl[], cm[], by = "cell_ID")
# Create dummy gradient legends
legend_plot1 <- ggplot(comb, aes(x = sdimx, y = sdimy, color = nr_feats)) +
geom_point() +
scale_color_gradient(low = "black", high = "green", name = "Value 1") +
theme_void()
legend_plot2 <- ggplot(comb, aes(x = sdimx, y = sdimy, color = sdimy)) +
geom_point() +
scale_color_gradient(low = "black", high = "red", name = "Value 2") +
theme_void()
# Extract colors for legend plots
legend_colors1 <- ggplot_build(legend_plot1)$data[[1]]$colour
legend_colors2 <- ggplot_build(legend_plot2)$data[[1]]$colour
mixed_colors <- mixRGB(legend_colors1, legend_colors2)
comb$temp_colors <- mixed_colors
# Plot the actual data with color mixture
a1 <- ggplot(comb, aes(x = sdimx, y = sdimy)) +
geom_point(aes(color = legend_colors1), size = 3, show.legend = F) +
scale_color_identity() +
theme_dark()
a2 <- ggplot(comb, aes(x = sdimx, y = sdimy)) +
geom_point(aes(color = legend_colors2), size = 3, show.legend = F) +
scale_color_identity() +
theme_dark()
a3 <- ggplot(comb, aes(x = sdimx, y = sdimy)) +
geom_point(aes(color = mixed_colors), size = 3, show.legend = F) +
scale_color_identity() +
theme_dark()
plot(a1) # var 1
plot(a2) # var 2
plot(a3) # mixture
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request


