I need to visualise additional information on my chord diagram made via circlize. I cannot figure out how to. I tried to highlight.section, but that did not seem to work as straightforward
Let’s use this data.
set.seed(1)
df <- data.frame(
Genes = 1:52,
Description = sample(LETTERS[1:7], size = 52, replace = TRUE),
value1 = sample(0:1, size = 52, replace = TRUE),
value2 = sample(runif(52, min = 0, max = 0.001), size = 52, replace = TRUE),
value3 = sample(10:20, size = 52, replace = TRUE)
)
I have made this plot using the following code
library(circlize)
library(viridis)
matrix <- with(df, table(Description, Genes))
circos.clear()
circos.par(start.degree = 90)
description_colors <- setNames(viridis(length(rownames(matrix))), rownames(matrix))
col_names_color <- setNames(rep("grey", length(colnames(matrix))), colnames(matrix))
all_colors <- c(description_colors, col_names_color)
# Generate the chord diagram with specified colors
chordDiagram(matrix, transparency = 0.5,
annotationTrack = "grid",
annotationTrackHeight = c(0.03),
preAllocateTracks = list(track.height = 0.1), # Reduced track height for genes
grid.col = all_colors, # Apply colors to both descriptions and genes
directional = -1,
big.gap = 30, small.gap = 1) # Adjust the highlight sector height here
# Text labels for the sectors
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))
}, bg.border = NA)
Chord Diagram
Question As you can see, df also have value1,
value2, $value3. I try to create the following from my data
KEGG Chord
From the GO term to gene connection, want to create a heatmap with a cluster with the chord diagram from the log2FC value like the image provided. The 3 value column in df could denote log2-fold change. Therefore, a gradient colour legend should be added.
Please help me with this.
Joydeep Shaw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.