circle_discrete()
Published

August 7, 2025

Circlular plot

library(ggalign)
#> Loading required package: ggplot2
#> 
#> Attaching package: 'ggalign'
#> The following object is masked from 'package:ggplot2':
#> 
#>     element_polygon
set.seed(123)
# Prepare heatmap matrix
mat <- matrix(
    rnorm(100, mean = 0, sd = 2),
    nrow = 10, ncol = 10,
    dimnames = list(paste0("G", 1:10), paste0("S", 1:10))
)

Construct a circular heatmap layout using ggalign’s grammar

circle_discrete(mat, radial = coord_radial(inner.radius = 0.1)) +

    # add a dendrogram
    align_dendro(aes(color = branch), k = 3L, size = 0.5) +
    scale_color_brewer(palette = "Dark2") +

    # add a heatmap
    ggalign() +
    geom_tile(aes(y = .column_index, fill = value)) +
    scale_fill_viridis_c() +

    # add a single tile for each group
    ggalign(NULL, size = 0.1) +
    geom_tile(aes(y = 1L, fill = .panel)) +
    scale_fill_brewer(palette = "Dark2", guide = "none") &
    theme_no_axes("y")