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)
)
# Add labels to all clusters
GC_chart(genes_data, cluster = "cluster", group = "group", height = "200px") %>%
GC_labels()
# Add labels and styling
GC_chart(genes_data, cluster = "cluster", group = "group", height = "200px") %>%
GC_labels(
label = "group",
show = TRUE,
x = 0,
y = 50,
dy = "-1.2em",
dx = "0em",
rotate = 0,
adjustLabels = TRUE, # Rotate labels to prevent overlap
fontSize = "12px",
fontStyle = "italic",
fill = "black",
fontFamily = "sans-serif",
textAnchor = "middle",
cursor = "default",
)
# Alter style of a specific label
GC_chart(genes_data, cluster = "cluster", group = "group", height = "200px") %>%
GC_labels(label = "group") %>%
GC_labels(
cluster = 1,
itemStyle = list(
list(index = 0, fill = "red", fontSize = "14px", fontWeight = "bold")
)
)
Run the code above in your browser using DataLab