Skip to content

Commit

Permalink
Fix checks for rasterization messages
Browse files Browse the repository at this point in the history
Fixes #7842
  • Loading branch information
saketkc committed Sep 27, 2023
1 parent cfd7eca commit 643a57d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -4009,7 +4009,7 @@ SpatialPlot <- function(
}

# Get feature max for individual feature
if (!(is.null(x = keep.scale)) && keep.scale == "feature" && class(x = data[, features[j]]) != "factor") {
if (!(is.null(x = keep.scale)) && keep.scale == "feature" && !inherits(x = data[, features[j]], what = "factor") ) {
max.feature.value <- max(data[, features[j]])
}

Expand Down Expand Up @@ -4085,7 +4085,7 @@ SpatialPlot <- function(
}

# Plot multiple images depending on keep.scale
if (!(is.null(x = keep.scale)) && class(x = data[, features[j]]) != "factor") {
if (!(is.null(x = keep.scale)) && !inherits(x = data[, features[j]], "factor")) {
plot <- suppressMessages(plot & scale_fill_gradientn(colors = SpatialColors(n = 100), limits = c(NA, max.feature.value)))
}

Expand Down Expand Up @@ -4885,7 +4885,7 @@ AutoPointSize <- function(data, raster = NULL) {
#' hexadecimal codes
#' @param threshold Intensity threshold for light/dark cutoff; intensities
#' greater than \code{theshold} yield \code{dark}, others yield \code{light}
#' @param w3c Use \href{http://www.w3.org/TR/WCAG20/}{W3C} formula for calculating
#' @param w3c Use \href{https://www.w3.org/TR/WCAG20/}{W3C} formula for calculating
#' background text color; ignores \code{threshold}
#' @param dark Color for dark text
#' @param light Color for light text
Expand Down Expand Up @@ -7802,7 +7802,7 @@ globalVariables(names = '..density..', package = 'Seurat')
#' @param cols An optional vector of colors to use
#' @param pt.size Point size for the plot
#' @param smooth Make a smoothed scatter plot
#' @param rows.highight A vector of rows to highlight (like cells.highlight in
#' @param rows.highlight A vector of rows to highlight (like cells.highlight in
#' \code{\link{SingleDimPlot}})
#' @param legend.title Optional legend title
#' @param raster Convert points to raster format, default is \code{NULL}
Expand Down Expand Up @@ -7842,7 +7842,7 @@ SingleCorPlot <- function(
jitter = TRUE
) {
pt.size <- pt.size %||% AutoPointSize(data = data, raster = raster)
if ((nrow(x = data) > 1e5) & !isFALSE(raster)){
if ((nrow(x = data) > 1e5) & !is.null(x = raster)){
message("Rasterizing points since number of points exceeds 100,000.",
"\nTo disable this behavior set `raster=FALSE`")
}
Expand Down Expand Up @@ -8051,7 +8051,7 @@ SingleDimPlot <- function(
raster = NULL,
raster.dpi = NULL
) {
if ((nrow(x = data) > 1e5) & !isFALSE(raster)){
if ((nrow(x = data) > 1e5) & is.null(x = raster)){
message("Rasterizing points since number of points exceeds 100,000.",
"\nTo disable this behavior set `raster=FALSE`")
}
Expand Down Expand Up @@ -8245,7 +8245,7 @@ SingleExIPlot <- function(
if (PackageCheck('ggrastr', error = FALSE)) {
# Set rasterization to true if ggrastr is installed and
# number of points exceeds 100,000
if ((nrow(x = data) > 1e5) & !isFALSE(raster)){
if ((nrow(x = data) > 1e5) & is.null(x = raster)){
message("Rasterizing points since number of points exceeds 100,000.",
"\nTo disable this behavior set `raster=FALSE`")
# change raster to TRUE
Expand Down

0 comments on commit 643a57d

Please sign in to comment.