rgraphcirclizecircos

R (circlize): How to remove self links?


Here is an example code:

df <- rbind(matrix(rep(sample(5),2),5,2),matrix(sample(10),5,2))

model_color <- unique(as.vector(df))
names(model_color) <- model_color

brand <- unique(as.vector(df))
names(brand) <- brand

chordDiagram(data.frame(df), order = names(brand), grid.col = model_color, directional = 0)
circos.clear()

How can I "mask" the self-links? I would like to remove them keeping the space empty (picture on the right).

enter image description here


Solution

  • This seems to work...

    transparency <- ifelse(df[,1]==df[,2],1,0.5)
    chordDiagram(data.frame(df), order = names(brand), 
             transparency=transparency,grid.col = model_color, directional = 0)
    

    enter image description here