From ff6ac698d895a370a1996f02adcf03886601e6cb Mon Sep 17 00:00:00 2001 From: Bingxin Lu Date: Mon, 13 Mar 2023 15:22:41 +0000 Subject: [PATCH] add option to adjust font size in heatmap --- util/plot-trees-all.R | 24 ++++++++++++++++++++++++ util/plot-util.R | 23 +---------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/util/plot-trees-all.R b/util/plot-trees-all.R index 1b94730..f7e6016 100644 --- a/util/plot-trees-all.R +++ b/util/plot-trees-all.R @@ -63,6 +63,8 @@ option_list = list( help="The width for the plot [default=%default]", metavar="numeric"), make_option(c("", "--height"), type="numeric", default = 5, help="The height for the plot [default=%default]", metavar="numeric"), + make_option(c("", "--font_size"), type="numeric", default = 6, + help="The font size for labels on the heatmap plot [default=%default]", metavar="numeric"), make_option(c("-m", "--mut_rate"), type="numeric", default = 0, help="The rate of somatic chromosomal aberrations [default=%default]", metavar="numeric"), make_option(c("-u", "--dup_rate"), type="numeric", default = 0, @@ -127,6 +129,28 @@ title = opt$title seed = opt$seed height = opt$height width = opt$width +font_size = opt$font_size + +theme1 = theme(legend.position = "none", + #strip.text.x = element_blank(), + #strip.text.y = element_blank(), + strip.text.y.left = element_text(size=font_size, angle=0), + strip.background = element_blank(), + axis.line.x = element_blank(), + axis.line.y = element_blank(), + axis.text.x = element_blank(), + axis.text.y = element_blank(), + axis.title.y = element_blank(), + axis.title.x = element_blank(), + axis.ticks.x = element_blank(), + axis.ticks.y = element_blank(), + panel.grid.minor = element_blank(), + panel.grid.major = element_blank(), + panel.spacing.y = unit(0, "lines"), + panel.spacing.x = unit(0, "lines"), + panel.border = element_rect(color = "#d8d8d8", fill = NA, size = .2), + panel.background = element_rect(fill = "#f0f0f0") +) if(!is.na(seed)) set.seed(seed) diff --git a/util/plot-util.R b/util/plot-util.R index f7effb5..e33c6e2 100644 --- a/util/plot-util.R +++ b/util/plot-util.R @@ -20,27 +20,6 @@ suppressMessages(library(ggpubr)) # 3) plotting all tree files in a directory -theme1 = theme(legend.position = "none", - #strip.text.x = element_blank(), - #strip.text.y = element_blank(), - strip.text.y.left = element_text(size=6, angle = 0), - strip.background = element_blank(), - axis.line.x = element_blank(), - axis.line.y = element_blank(), - axis.text.x = element_blank(), - axis.text.y = element_blank(), - axis.title.y = element_blank(), - axis.title.x = element_blank(), - axis.ticks.x = element_blank(), - axis.ticks.y = element_blank(), - panel.grid.minor = element_blank(), - panel.grid.major = element_blank(), - panel.spacing.y = unit(0, "lines"), - panel.spacing.x = unit(0, "lines"), - panel.border = element_rect(color = "#d8d8d8", fill = NA, size = .2), - panel.background = element_rect(fill = "#f0f0f0") -) - # cn_colors1 = c("#6283A9","#bdd7e7","#f0f0f0","#FCAE91", "#B9574E", "#76000D", "#8B0000", "#000000") # Max CN to show in heatmap MAX_CN = 6 @@ -966,7 +945,7 @@ plot.tree.ci.node.mut.smpl <- function(tree_ci, title = "", lextra = 0, rextra = xl = 0 - lextra p <- ggtree(tree_ci) - p <- p + geom_tiplab() + ggtitle(title) + p <- p + geom_tiplab() + ggtitle(title) + geom_treescale() if(has_inode_label){ p <- p + geom_text2(aes(subset = !isTip, label = label), hjust = -0.3)