From f2b43f277b0917032d7c2428b6002fc95cce70ae Mon Sep 17 00:00:00 2001 From: zhanghao-njmu <542370159@qq.com> Date: Sat, 25 Nov 2023 16:24:04 +0800 Subject: [PATCH] Change the number of bins in dot plot for the FeatureStatPlot function --- R/SCP-plot.R | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/R/SCP-plot.R b/R/SCP-plot.R index 771bdf87..fae6aacc 100644 --- a/R/SCP-plot.R +++ b/R/SCP-plot.R @@ -3650,9 +3650,9 @@ FeatureStatPlot <- function(srt, stat.by, group.by = NULL, split.by = NULL, bg.b if (i != 1) { suppressWarnings(p <- p + theme( legend.position = "none", - panel.grid = element_blank(), plot.title = element_blank(), plot.subtitle = element_blank(), + panel.grid = element_blank(), axis.title = element_blank(), axis.text.y = element_blank(), axis.text.x = element_text(vjust = c(1, 0)), @@ -3662,6 +3662,8 @@ FeatureStatPlot <- function(srt, stat.by, group.by = NULL, split.by = NULL, bg.b } else { suppressWarnings(p <- p + theme( legend.position = "none", + plot.title = element_blank(), + plot.subtitle = element_blank(), panel.grid = element_blank(), axis.title.x = element_blank(), axis.text.x = element_text(vjust = c(1, 0)), @@ -3681,6 +3683,8 @@ FeatureStatPlot <- function(srt, stat.by, group.by = NULL, split.by = NULL, bg.b if (i != length(plist_g)) { suppressWarnings(p <- p + theme( legend.position = "none", + plot.title = element_blank(), + plot.subtitle = element_blank(), panel.grid = element_blank(), axis.title = element_blank(), axis.text.x = element_blank(), @@ -3688,12 +3692,11 @@ FeatureStatPlot <- function(srt, stat.by, group.by = NULL, split.by = NULL, bg.b axis.ticks.length.x = unit(0, "pt"), plot.margin = unit(c(-0.5, 0, 0, 0), "mm") )) - if (i == 1) { - p <- p + theme(plot.title = element_blank(), plot.subtitle = element_blank()) - } } else { suppressWarnings(p <- p + theme( legend.position = "none", + plot.title = element_blank(), + plot.subtitle = element_blank(), panel.grid = element_blank(), axis.title.y = element_blank(), axis.text.y = element_text(vjust = c(0, 1)), @@ -4183,7 +4186,7 @@ ExpressionStatPlot <- function(exp.data, meta.data, stat.by, group.by = NULL, sp y_min_use <- layer_scales(p)$y$range$range[1] } if (plot_type == "dot") { - bins <- cut(dat$value, breaks = seq(y_min_use, y_max_use, length.out = 15), include.lowest = TRUE) + bins <- cut(dat$value, breaks = seq(y_min_use, y_max_use, length.out = 8), include.lowest = TRUE) bins_median <- sapply(strsplit(levels(bins), ","), function(x) median(as.numeric(gsub("\\(|\\)|\\[|\\]", "", x)), na.rm = TRUE)) names(bins_median) <- levels(bins) dat[["bins"]] <- bins_median[bins]