This is a little R script that translates a 2 x 2 table into a karyotype file for input into Circos
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is a little R script that translates a 2 x 2 table into a karyotype file for input into Circos. Inputting data using the regular karyotype/segdup process is more flesible--but a little more difficult--than the tableviewer. This was originally used for a Circos diagram created to visualize transitions from college major to employment. However, this is flexible to translate any 2 x 2 table into the appropriate karyotype.


Typically, data from a database is available in a 2 x 2 file that is easily generated from a database or from an Excel PivotTable. For example:

In this example, the row represents one variable and the columns represent a second. Notice the table may be rectangular when using circosRearrange.

The karyotype file needs to keep a running table to mark the start and end point for each ribbon. In this example, the first ribbon would be from position 0 to 5, while the second will be between 6 and 15, and so forth.


This is an adaptation from another project where I worked with two types of variables (CAREER CLUSTERS) and industry (NAIC CODES). Load the function into R circosRearrange, which takes one input--xtab.




xtabA rectangular or square matric of integers or numeric data representing two variables (row and column).

Post Processing

This was adapted from a prior project, so you will need to change some naming conventions. In particular, adjust line 78 to represent the chr column for row data and adjust line 98 to represent the chr column for column data.

You also need to give each row a unique id before using the output from circosRearrange in Circos. The best way is to open the output from R in a spreadsheet editor and manually add the unique id.


This is distributed under GNU-GPL 2.0.