saeyslab / FlowSOM

Using self-organizing maps for visualization and interpretation of cytometry data
25 stars 7 forks source link

PlotVariable with partially named colorPalette #6

Closed SofieVG closed 1 year ago

SofieVG commented 3 years ago

If any color is unnamed in the colorpalette, the names of the other colors are also ignored. Not sure if this is something we can solve or if this is a ggplot issue. Reported by @AnneliesEmmaneel.

Reproducible example:

fileName <- system.file("extdata", "68983.fcs", package = "FlowSOM")
flowSOM.res <- FlowSOM(fileName, 
                       compensate = TRUE, transform = TRUE, scale = FALSE,
                       colsToUse = c(9, 12, 14:18),
                       nClus = 10,
                       seed = 1)
values <- factor(sample(c("A", "B", "C"), 100, replace = TRUE))
p1 <- PlotVariable(flowSOM.res, 
             variable = values,
             variableName = "Random",
             colorPalette = c("B" = "green",
                              "A" = "red",  
                              "C" = "blue"))
p2 <- PlotVariable(flowSOM.res, 
             variable = values,
             variableName = "Random",
             colorPalette = c("B" = "green", 
                              "A" = "red",  
                              "C" = "blue",
                              "cyan"))

library(patchwork)
p1 + p2