0

I want to add a set of custom labels outside the most external track on a chord diagram, however, the labels appear in the interior of the diagram and I can't figure out how to specify their location. Here's a reprex with the basic structure of my diagram:

library(tidyverse)
library(circlize)

set.seed(123)
df <- data.frame(
  groups = rep(letters[1:2], each = 10),
  classes = sample(fruit, 20),
  grp_col = rep( c("blue", "yellow"), each = 10),
  anoth_grp = sample(LETTERS[1:3], 20, replace = TRUE)
)

df <- arrange(df, anoth_grp)

grid.col <- setNames(c(df$grp_col, rep("grey", length(df$classes))), 
                     c(df$groups, df$classes))

groups_cat<- setNames(c(sample(LETTERS[1:3], 20, replace = TRUE), df$groups),
                      c(df$classes, df$groups)
                      )

class_col <- setNames(viridis_pal(option = "H")(length(unique(df$anoth_grp))),
                      unique(df$anoth_grp))

circos.clear()

circos.par(start.degree = 180)


ccdd <- chordDiagram( 
  df[,c("classes", "groups")],
  big.gap = 6,
  annotationTrack = "grid", 
  preAllocateTracks = list(
    list(track.height = circos.par("track.height")),
    list(track.height = 0.02)
  ),
  transparency = 0.5,
  grid.col = grid.col,
  #group = groups,
  link.decreasing = TRUE,
  link.sort = TRUE
)

lapply(unique(df$anoth_grp), function(x){
  highlight.sector(names(groups_cat[groups_cat == x]),
                   #text = x,
                   text.vjust = -10,
                   col = class_col[x],
                   #border = "black",
                   track.index = 3)
})

circos.labels(
  sectors = rep("blackberry", 8),
  labels = sample(words, 8),
  x = seq(from =0, to = 1, length.out = 8),
  side = "outside",
  cex=0.5,
  padding = 0.1,
  niceFacing = FALSE,
  connection_height = mm_h(15)
)

I would expect to have my labels outside the most external track.

Lumimoto
  • 133
  • 1
  • 7

0 Answers0