Closed xiw588 closed 3 years ago
@xiw588 It's a list of ggplot
object. You have to set the palette one by one either by hand or by code like lapply
.
load(system.file("extdata", "toy_copynumber_signature_by_M.RData",
package = "sigminer", mustWork = TRUE
))
# Assign samples to clusters
groups <- get_groups(sig, method = "k-means")
set.seed(1234)
groups$prob <- rnorm(10)
groups$new_group <- sample(c("1", "2", "3", "4", NA), size = nrow(groups), replace = TRUE)
# Compare groups (filter NAs for categorical coloumns)
groups.cmp <- get_group_comparison(groups[, -1],
col_group = "group",
cols_to_compare = c("prob", "new_group"),
type = c("co", "ca"), verbose = TRUE
)
ggcomp <- show_group_comparison(groups.cmp)
ggcomp
ggcomp$ca$new_group + scale_fill_brewer(palette = "Set1")
Hi Shixiang,
Thank you for your prompt response! It worked for single figures, but do you know if there is anyway to change in cowplot::plot_grid() ?
Thanks!
No, there is no way to change it as cowplot changed the plot in an unexpected way, so the result plot can not be editted like true ggplot.
However, you can extract the ggplot list and modify with lapply
, e.g.,
ca <- ggcomp$ca
lapply(ca, function(x) x + scale_fill_brewer(palette = "Set1"))
After modifying, you can combine the plots with your own way, cowplot
, patchwork
, etc.
ca <- lapply(ca, function(x) x + scale_fill_brewer(palette = "Set1"))
cowplot::plot_grid(plotlist = ca)
Hi Shixiang,
Thank you so much!! It totally solved my problem!
Hi Shixiang,
Do you know how to change the color of show_group_comparison()?
Thanks!