Skip to content

Commit

Permalink
Change the number of bins in dot plot for the FeatureStatPlot function
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghao-njmu committed Nov 25, 2023
1 parent 3a8c86a commit f2b43f2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions R/SCP-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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)),
Expand All @@ -3681,19 +3683,20 @@ 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(),
axis.text.y = element_text(vjust = c(0, 1)),
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)),
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit f2b43f2

Please sign in to comment.