Color cells using a background density
add_density_coloring(
cell_positions,
color_density = c("none", "grouping", "feature"),
trajectory,
grouping = NULL,
groups = NULL,
feature_oi = NULL,
expression_source = "expression",
padding = 0.1,
nbins = 1000,
bw = 0.2,
density_cutoff = 0.3,
density_cutoff_label = density_cutoff/10
)
The positions of the cells in 2D. Must be a tibble with character column cell_id
and numeric columns comp_1
and comp_2
.
How to color density, can be "none", "grouping", or "feature".
A dynwrap trajectory.
A grouping of the cells (e.g. clustering) as a named character vector.
A tibble containing character columns group_id
and color
. If NULL
, this object is inferred from the grouping
itself.
The name of a feature to use for colouring the cells.
Source of the feature expression, defaults to get_expression(trajectory)
.
The padding in the edges to the plot, relative to the size of the plot.
Number of bins for calculating the density.
Bandwidth, relative to the size of the plot.
Cutoff for density, the lower the larger the areas.
Cutoff for density for labeling, the lower the further way from cells.
A named list with objects:
polygon: A layer to add to the ggplot.
scale: A scale to add to the ggplot.