Circos > Documentation > Tutorials > Recipes > Heatmap Links
Loading
20 imperatives of information design — BioVis 2012

Use the latest version of Circos and read Circos best practices—these list recent important changes and identify sources of common problems.
If you are having trouble, post your issue to the Circos Google Group and include all files and detailed error logs. Please do not email me directly unless it is urgent—you are much more likely to receive a timely reply from the group.
Don't know what question to ask? Read Points of View: Visualizing Biological Data by Bang Wong from the Points of View series.

8 — Recipes

11. Heat Map Links

You can color links by an associated value to create a heatmap effect.

Heatmaps were discussed in Tutorial 6.5. They were a combination of a highlight (had a start and end value) and a scatter plot (had an associated value). The heatmap track colors were defined as a comma-separated list, which was selected based on the value of the heatmap element.

giving links a value

At this time there is no way to associate a value with a link in the same way. However, you can subvert one of the link parameters to do so. For example, if you're not using z-depth, use the z parameter. Below, I use z to associate a value of 2 with link_4 and 5 with link_5.

link_4 hs12 117427133 132349534 color=chr12,z=2
link_4 hs2 94056542 114056542 color=chr12,z=2
link_5 hs22 33232924 49691432 color=chr22,z=5
link_5 hs4 88399610 108399610 color=chr22,z=5

Alternatively, you can use the "url" parameter to achieve the same result.

link_4 hs12 117427133 132349534 color=chr12,url=2
link_4 hs2 94056542 114056542 color=chr12,url=2
link_5 hs22 33232924 49691432 color=chr22,url=5
link_5 hs4 88399610 108399610 color=chr22,url=5

At the moment, this is a cludge — in future versions a "value" parameter will be supported.

coloring links by value

Now that each link has a value, it's time to use it to set its color. Rules are used for this.

To reference the links value (e.g. if the "url") parameter was used, the parsable string _URL{N}_ is used, where N=1 for "url" parmameter of the start of the link and N=2 for the end of the link. Since in this case both ends have the same value, I use _URL1_ arbitrarily.

The first rule maps the "url" value onto a list of colors. In this example, the "url" value is in the range [0,4]. To map the value to a color, you will need to use an eval() block and write a Perl one-liner to sample a list. If the list contains entries that do not have a space (e.g. single word colors), you can use the qw() operator which turns words into a list.

qw(red orange green blue purple)

Perl's syntax to sample an element of a list is

( ...list here...)[INDEX]

Combining these

(qw(red orange green blue purple))[INDEX]

In this case the INDEX is the "url" value, referenced by _URL1_.

To use Perl code in a rule, you need to pass it through eval(), so that Circos knows to interpret it correctly. Below are the two rules that (1) map the value to a color and (2) add transparency to the color.

<rules>

<rule>
importance = 100
# always trigger this rule
condition  = 1
# use the link's id value to sample from a list of colors
color = eval((qw(red orange green blue purple))[ _URL1_ ])
# continue parsing other rules
flow = continue
</rule>

<rule>
importance = 90
# always trigger this rule
condition  = 1
# add _a3 to the color of the ribbon, giving it 50% transparency (3/6)
color      = eval(sprintf('%s_a3',_COLOR_))
</rule>

</rules>