ShixiangWang / sigminer

🌲 An easy-to-use and scalable toolkit for genomic alteration signature (a.k.a. mutational signature) analysis and visualization in R https://shixiangwang.github.io/sigminer/reference/index.html
https://shixiangwang.github.io/sigminer/
Other
147 stars 19 forks source link

Custom color problem #449

Closed RuimeiL closed 11 months ago

RuimeiL commented 11 months ago

When visualizing signatures, the function show_sig_exposure(rs_sig, hide_samps = FALSE) is utilized to display the sample signatures. However, the documentation does not provide clear instructions for customizing colors.

option: style = c("default", "cosmic"), palette = use_color_style(style)

style
plot style, one of 'default' and 'cosmic', works when parameter set_gradient_color is FALSE. palette palette used to plot, default use a built-in palette according to parameter style.

I would like to inquire whether it is possible to customize colors. If so, how to define the color parameter? what is the method for achieving this customization?

ShixiangWang commented 11 months ago

@RuimeiL Thanks for your question. It's quite easy. to customize the colors.

library(sigminer)

load(system.file("extdata", "toy_mutational_signature.RData",
                 package = "sigminer", mustWork = TRUE
))
# Show signature exposure
p1 <- show_sig_exposure(sig2)
p1

# palette means the colors for using
use_color_style("default")

# directly change the palette
show_sig_exposure(sig2, palette = c("black", "blue", "red"))

# as the result is a ggplot object
# modify with ggplot2 approach
p1 + ggplot2::scale_fill_brewer()

image

image

image