Skip to content

Commit

Permalink
Avoid filtering colors if ident column is empty in spatial plots
Browse files Browse the repository at this point in the history
Fix satijalab#6179. If the `ident` column is not present in the data, all colors get filtered out. Only filter colors if this column is non-null.
  • Loading branch information
yoda-vid committed Aug 22, 2022
1 parent 9bb1fa7 commit 5624506
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -7682,7 +7682,9 @@ SingleSpatialPlot <- function(
colors <- DiscretePalette(length(unique(data[[col.by]])), palette = cols)
scale <- scale_fill_manual(values = colors, na.value = na.value)
} else {
cols <- cols[names(x = cols) %in% data$ident]
if (!is.null(data$ident)) {
cols <- cols[names(x = cols) %in% data$ident]
}
scale <- scale_fill_manual(values = cols, na.value = na.value)
}
plot <- plot + scale
Expand Down

0 comments on commit 5624506

Please sign in to comment.