| fancyMask | R Documentation |
Convenience helper that returns a list of ggplot2 components
that draws polygon-like outlines and
places cluster labels.
The plotting limits are expanded (via limits.expand) to provide
extra room for labels.
fancyMask(
maskTable,
ratio = NULL,
limits.expand = ifelse(label, 0.1, 0.05),
linewidth = 1,
shape.expand = linewidth * unit(-1, "pt"),
cols = "inherit",
label = TRUE,
label.fontsize = 10,
label.buffer = unit(0, "cm"),
label.fontface = "plain",
label.margin = margin(2, 2, 2, 2, "pt")
)
maskTable |
A data.frame of mask coordinates. The first two
columns are interpreted as x/y coordinates (in that order). Must contain
at least the columns |
ratio |
Optional aspect ratio passed to |
limits.expand |
Numeric scalar giving the fraction of the x/y range to
expand on both sides when setting plot limits. Default is |
linewidth |
Line width passed to |
shape.expand |
Expansion or contraction applied to the marked shapes,
passed to |
cols |
Color specification for cluster outlines (and labels). One of:
|
label |
Boolean flag wheter the labels should be displayed. |
label.fontsize |
Label font size passed to |
label.buffer |
Label buffer distance passed to
|
label.fontface |
Label font face passed to
|
label.margin |
Label margin passed to
|
The first two columns of maskTable are used as x/y coordinates. Cluster
labels are taken from maskTable$cluster. Shapes are grouped by
maskTable$group.
A list of ggplot2 components suitable for adding to a plot with +,
containing a ggplot2::coord_cartesian() specification and a
geom_mark_shape() layer. When cols = "inherit", returns an
opaque object whose colors are resolved when added to a plot.
geom_mark_shape()
data("exampleMascarade")
maskTable <- generateMask(dims=exampleMascarade$dims,
clusters=exampleMascarade$clusters)
library(ggplot2)
basePlot <- ggplot(do.call(cbind, exampleMascarade)) +
geom_point(aes(x=UMAP_1, y=UMAP_2, color=GNLY)) +
scale_color_gradient2(low = "#404040", high="red") +
theme_classic()
basePlot + fancyMask(maskTable, ratio=1, cols=scales::hue_pal())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.