Skip to content

Commit

Permalink
Fix the "keep_scale" bug in FeatureDimPlot
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghao-njmu committed Nov 8, 2023
1 parent 30c2e04 commit ea08bbb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/SCP-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,8 @@ FeatureDimPlot <- function(srt, features, reduction = NULL, dims = c(1, 2), spli
if (!is.numeric(dat_exp) && !inherits(dat_exp, "Matrix")) {
stop("'features' must be type of numeric variable.")
}
dat_exp[, features][dat_exp[, features] <= bg_cutoff] <- NA

if (length(features) > 50 && !isTRUE(force)) {
warning("More than 50 features to be plotted", immediate. = TRUE)
answer <- askYesNo("Are you sure to continue?", default = FALSE)
Expand Down Expand Up @@ -2195,7 +2197,6 @@ FeatureDimPlot <- function(srt, features, reduction = NULL, dims = c(1, 2), spli
plist <- lapply(levels(dat_sp[[split.by]]), function(s) {
dat <- dat_split[[ifelse(split.by == "All.groups", 1, s)]][, , drop = FALSE]
for (f in features) {
dat[, f][dat[, f] <= bg_cutoff] <- NA
if (any(is.infinite(dat[, f]))) {
dat[, f][which(dat[, f] == max(dat[, f], na.rm = TRUE))] <- max(dat[, f][is.finite(dat[, f])], na.rm = TRUE)
dat[, f][which(dat[, f] == min(dat[, f], na.rm = TRUE))] <- min(dat[, f][is.finite(dat[, f])], na.rm = TRUE)
Expand Down Expand Up @@ -2502,7 +2503,6 @@ FeatureDimPlot <- function(srt, features, reduction = NULL, dims = c(1, 2), spli
f <- comb[i, "feature"]
s <- comb[i, "split"]
dat <- dat_split[[ifelse(split.by == "All.groups", 1, s)]][, c(colnames(dat_use), f), drop = FALSE]
dat[, f][dat[, f] <= bg_cutoff] <- NA
if (any(is.infinite(dat[, f]))) {
dat[, f][dat[, f] == max(dat[, f], na.rm = TRUE)] <- max(dat[, f][is.finite(dat[, f])], na.rm = TRUE)
dat[, f][dat[, f] == min(dat[, f], na.rm = TRUE)] <- min(dat[, f][is.finite(dat[, f])], na.rm = TRUE)
Expand Down

0 comments on commit ea08bbb

Please sign in to comment.