Closed wish1832 closed 1 year ago
This error was due to improper syntax in the code passing the palette to Seurat::FeatureScatter
:
FeatureScatter(
object,
feature1 = feature_1,
feature2 = feature_2,
group.by = group_by,
# Cols: use user defined palette, or the defaults if palette() == NULL
cols =
if (!is.null(palette)){
# colorRampPalette() extends or contracts the given palette to
# produce exactly the required number of colors
colorRampPalette(palette(n_colors))
# Use ggplot2 defaults if palette() is unspecified
} else NULL,
)
colorRampPalette(palette(n_colors))
should be colorRampPalette(palette)(n_colors)
. colorRampPalette
creates a function from the palette passed to it, which n_colors
is passed to to create a new palette to "stretch" or "shrink" the number of colors to match the number needed based on the number of group by categories.
palette
is a vector of hex codes, so it must be passed as an argument to colorRampPalette()
. If called as a function, it will result in the error returned.
The erroneous line of code is only ran when palette is not equal to NULL, which is why the error does not result when the default palette is passed.
This was fixed with the merge of #200.
When attempting to plot a scatterplot in the plots tab using a non-default palette, the error below is returned. When the default categorical palette is selected, the error disappears.