This function allows you to set or update the labels for specified clusters within a GC chart. It provides flexibility in terms of the title, visibility, width, position, and other additional customization options.
Arguments
- GC_chart
A GC chart object.
- title
Character vector. The title for the cluster label. Default is NULL.
- show
Logical. Whether to show the cluster label. Default is TRUE.
- width
Character. The width of the cluster label, which sets the left or right margin of the cluster. Default is NULL: a margin set with
GC_grid(), otherwise the width of the theme, otherwise "100px".- cluster
Numeric or character vector. Clusters in the GC chart to update. Default is NULL.
- position
Character. Position of the label, either "left" or "right". Default is NULL: the position of the theme, otherwise "left".
- align
Character vector. Horizontal alignment of the lines of the label in its margin, "left", "center" or "right", recycled over the clusters.
xmoves the label from this position, e.g.x = 5for some space at the left edge. Default is NULL: the alignment of the theme, otherwise "center".- wrapLabel
Logical. Indicates whether the label should be wrapped. Default is NULL: as set by the theme, otherwise TRUE.
- wrapOptions
List. Specifies the wrapping options. Default is an empty List.
- subtitle
Character vector. A second line below the title, e.g. the species, recycled over the clusters. Default is NULL: no subtitle.
- subtitleFont
List. Settings for the subtitle font, e.g.
list(fontStyle = "italic"). Default is an empty list: 11px, not bold.- spacing
Numeric vector. Pixels between the middle of the last line of the title and of the subtitle, recycled over the clusters. The title and subtitle are centred together on the cluster. Default is NULL: as set by the theme, otherwise 1.2 times the mean font size of the title and subtitle (14 for the default 12px and 11px).
- ...
Additional customization arguments for the cluster label, such as 'fontSize', 'fontStyle', 'fontWeight', 'fontFamily', 'cursor', etc.
Examples
genes_data <- data.frame(
start = c(10, 90, 130, 170, 210),
end = c(40, 120, 160, 200, 240),
name = c('Gene 1', 'Gene 3', 'Gene 4', 'Gene 5', 'Gene 6'),
group = c('A', 'B', 'B', 'A', 'C'),
cluster = c(1, 1, 2, 2, 2)
)
# Set cluster labels
GC_chart(genes_data, cluster ="cluster", group = "group", height = "200px") %>%
GC_clusterLabel(title = unique(genes_data$cluster))
# Set label for a specific cluster
GC_chart(genes_data, cluster ="cluster", group = "group", height = "200px") %>%
GC_clusterLabel(title = "Cluster 1", cluster = 1)
# Add a subtitle below each label
GC_chart(genes_data, cluster ="cluster", group = "group", height = "200px") %>%
GC_clusterLabel(
title = c("pQEB1", "pQEB1_inv1"),
subtitle = c("E. cloacae", "K. oxytoca"),
subtitleFont = list(fontStyle = "italic"),
spacing = 14
)
# Style labels
GC_chart(genes_data, cluster ="cluster", group = "group", height = "200px") %>%
GC_clusterLabel(
title = c("Cluster 1", "Cluster 2"),
width = "100px",
x = 0,
y = 0,
position = "left",
align = "left", # center / right
wrapLabel = TRUE,
wrapOptions = list(
dyAdjust = 0,
lineHeightEms = 1.05,
lineHeightSquishFactor = 1,
splitOnHyphen = TRUE,
centreVertically = TRUE
),
fontSize = "12px",
fontStyle = "normal",
fontWeight = "bold",
fontFamily = "sans-serif",
cursor = "default"
)
