Search code examples
rintersectionchord-diagram

How to create a chord intersection diagram in R?


In R, I would like to visualize the one-to-n-way intersections between many sets, using a chord diagram.

What I have in mind is nicely illustrated here. For clarity, let me copy the example from the illustration. Say there are three sets (e.g., person characteristics), with each a couple observations (e.g., names). Some of these observations are in all three sets, some are in two sets, and some in only one. With only three sets a Venn diagram can also be used to visualize the intersection, but in a situation with many sets, the 'chord intersection diagram' might help visualize all intersections.

In R, the circlize package can be used to create chord diagrams. However, in the book about that package I could not find pointers on how to create a chord intersection diagram.

Importantly, there are other ways to visualize many one-to-n-way intersections in R (e.g., UpSetR), but those are restricted in the number of intersections that can be shown, and I hope a chord diagram turns out to be less restrictive.

Is it possible to use the circlize package in such a way that it returns a chord intersection diagram? And if not, are there other R (preferably) packages that do the job?


Solution

  • The circlize package can now be used for chord intersection diagrams. In this GitHub issue, the package author gives an example.

    Also, I found out that the ggraph package can do it. I created a Shiny app that illustrates the chord intersection diagram (and other methods for visualizing complex set intersections). R functions for the different methods can be found on Github.