Rearrange values position in chordDiagram() in R

63 Views Asked by At

I have the following correlation values in R namely ``dat` as follows:

dat <- as.matrix(cbind(c(1.0000000, 0.5161944, 0.5190630, 0.3717464, 0.5719125),
                       c(0.5161944, 1.0000000, 0.2549985, 0.8469740, 0.7761113),
                       c(0.5190630, 0.2549985, 1.0000000, 0.2130771, 0.2930945),
                       c(0.3717464, 0.8469740, 0.2130771, 1.0000000, 0.5652874),
                       c(0.5719125, 0.7761113, 0.2930945, 0.5652874, 1.0000000))
)
colnames(dat) <- c(paste0("X",1:ncol(dat)))
rownames(dat) <- c(paste0("X",1:ncol(dat)))
dat[lower.tri(dat)] <- 0 

and I have created the following chord diagram:

circos.par(gap.degree = 0.8)
chordDiagram(dat, transparency = 0.5, scale = T, annotationTrack = c("name", "grid"))

for (i in 1:ncol(dat)) {
  circos.xaxis(sector.index = paste0("X", i), 
               major.at = seq(0, 1, .25), 
               minor.ticks = 0, 
               labels.cex = .5)
}

which results in: enter image description here

However, even though the values are represented in the plot in the correct colour, they are not placed in the correct position in the grid axis. For example the value between X3 and X4 is 0.21, but in the X4 is placed between [0.25-0.5) and in the X3 is placed between [0,0.25) but it should be closer to 0.25 and not 0 as it is displayed. How can I fix the positions??

0

There are 0 best solutions below