I have made a chordDiagram for two datasets, each of which contain ‘modules’ that are named with a colour. The links show how modules from dataset1 overlap with modules from dataset2. However, in reality, not every element of a module in dataset1 overlaps with modules in dataset2. Currently, the chordDiagram just shows the size of each module as the total of the elements that overlap with modules in dataset2. In reality module size is perhaps twice that. Is it possible to have each segment of the circle represent the true size of the module, rather than just the elements that overlap with modules in dataset2. Here is an example below, but any help making the segment size reflect the actual module size, rather than just the total of the elements that overlap would be great!
full_size1 <- c(black = 795L, blue = 4433L, brown = 4383L, cyan = 201L, green = 1209L,
greenyellow = 319L, grey = 538L, grey60 = 152L, lightcyan = 165L,
lightgreen = 138L, lightyellow = 109L, magenta = 438L, midnightblue = 197L,
pink = 542L, purple = 340L, red = 1012L, royalblue = 74L, salmon = 254L,
tan = 310L, turquoise = 5949L, yellow = 2391L)
full_size2 <- c(black = 1289L, blue = 2324L, brown = 1861L, cyan = 205L, darkgreen = 64L,
darkgrey = 56L, darkorange = 50L, darkred = 75L, darkturquoise = 59L,
green = 1660L, greenyellow = 443L, grey = 245L, grey60 = 141L,
lightcyan = 183L, lightgreen = 138L, lightyellow = 137L, magenta = 848L,
midnightblue = 190L, orange = 53L, pink = 911L, purple = 539L,
red = 1345L, royalblue = 89L, salmon = 222L, tan = 322L, turquoise = 2679L,
white = 48L, yellow = 1690L)
comparison_table <- structure(c(0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 4, 0, 0, 0, 0, 0, 8, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0, 0, 17, 19, 0, 0, 30, 0, 0, 0, 184, 0,
0, 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 10, 0, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0,
0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0,
179, 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0,
72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 9,
0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,
0, 0, 0, 0), dim = c(15L, 24L), dimnames = structure(list(c("black1",
"blue1", "brown1", "cyan1", "green1", "greenyellow1", "grey601",
"lightgreen1", "magenta1", "pink1", "purple1", "red1", "tan1",
"turquoise1", "yellow1"), c("black2", "blue2", "brown2", "cyan2",
"darkgreen2", "darkgrey2", "darkorange2", "darkred2", "green2",
"greenyellow2", "grey2", "grey602", "lightcyan2", "lightgreen2",
"lightyellow2", "magenta2", "orange2", "pink2", "purple2", "red2",
"royalblue2", "salmon2", "tan2", "white2")), names = c("", ""
)), class = "table")
colour_vector <- c(black1 = "black", blue1 = "blue", brown1 = "brown", cyan1 = "cyan",
green1 = "green", greenyellow1 = "greenyellow", grey601 = "grey60",
lightgreen1 = "lightgreen", magenta1 = "magenta", pink1 = "pink",
purple1 = "purple", red1 = "red", tan1 = "tan", turquoise1 = "turquoise",
yellow1 = "yellow", black2 = "black", blue2 = "blue", brown2 = "brown",
cyan2 = "cyan", darkgreen2 = "darkgreen", darkgrey2 = "darkgrey",
darkorange2 = "darkorange", darkred2 = "darkred", green2 = "green",
greenyellow2 = "greenyellow", grey2 = "grey", grey602 = "grey60",
lightcyan2 = "lightcyan", lightgreen2 = "lightgreen", lightyellow2 = "lightyellow",
magenta2 = "magenta", orange2 = "orange", pink2 = "pink", purple2 = "purple",
red2 = "red", royalblue2 = "royalblue", salmon2 = "salmon", tan2 = "tan",
white2 = "white")
chord_title <- "My comparisons"
# Clear existing circos plot to reset parameters
circos.clear()
# Set gap degrees for sectors
circos.par(gap.after = c(rep(1, length(rownames(comparison_table)) - 1), 10, rep(1, length(colnames(comparison_table)) - 1), 10),
canvas.xlim = c(-1.2, 1.2), # Adjust x-axis limits for more space
canvas.ylim = c(-1.2, 1.2)) # Adjust y-axis limits for more space
# Create chord diagram
chordDiagram(comparison_table,
transparency = 0.5,
grid.col = colour_vector,
annotationTrack = "grid",
preAllocateTracks = list(track.height = 0.2))
# Add custom tracks and annotations
circos.trackPlotRegion(track.index = 1, panel.fun = function(x, y) {
xlim = get.cell.meta.data("xlim")
ylim = get.cell.meta.data("ylim")
sector.name = get.cell.meta.data("sector.index")
circos.text(CELL_META$xcenter, ylim[1] + cm_h(2),sector.name,
facing = "clockwise",niceFacing = TRUE, adj = c(0, 0.5))
circos.axis(h = "bottom",labels.cex = .6,sector.index = sector.name)
}, bg.border = NA)
# Add the title
title(chord_title)
I’ve tried googling and AI, but no joy on getting it working.