<!-- Generated by pkgdown: do not edit by hand --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Create plotting regions for a whole track — circos.trackPlotRegion • circlize</title> <!-- jquery --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> <!-- Bootstrap --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script> <!-- bootstrap-toc --> <link rel="stylesheet" href="../bootstrap-toc.css"> <script src="../bootstrap-toc.js"></script> <!-- Font Awesome icons --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" /> <!-- clipboard.js --> <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script> <!-- headroom.js --> <script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script> <!-- pkgdown --> <link href="../pkgdown.css" rel="stylesheet"> <script src="../pkgdown.js"></script> <meta property="og:title" content="Create plotting regions for a whole track — circos.trackPlotRegion" /> <meta property="og:description" content="Create plotting regions for a whole track" /> <!-- mathjax --> <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body data-spy="scroll" data-target="#toc"> <div class="container template-reference-topic"> <header> <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">circlize</a> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.4.11</span> </span> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li> <a href="../index.html"> <span class="fas fa fas fa-home fa-lg"></span> </a> </li> <li> <a href="../articles/circlize.html">Get started</a> </li> <li> <a href="../reference/index.html">Reference</a> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li> <a href="https://github.com/jokergoo/circlize/"> <span class="fab fa fab fa-github fa-lg"></span> </a> </li> </ul> </div><!--/.nav-collapse --> </div><!--/.container --> </div><!--/.navbar --> </header> <div class="row"> <div class="col-md-9 contents"> <div class="page-header"> <h1>Create plotting regions for a whole track</h1> <div class="hidden name"><code>circos.trackPlotRegion.Rd</code></div> </div> <div class="ref-description"> <p>Create plotting regions for a whole track</p> </div> <pre class="usage"><span class='fu'>circos.trackPlotRegion</span>( <span class='kw'>sectors</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>x</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>ylim</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>force.ylim</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>track.index</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>track.height</span> <span class='kw'>=</span> <span class='fu'><a href='circos.par.html'>circos.par</a></span>(<span class='st'>"track.height"</span>), <span class='kw'>track.margin</span> <span class='kw'>=</span> <span class='fu'><a href='circos.par.html'>circos.par</a></span>(<span class='st'>"track.margin"</span>), <span class='kw'>cell.padding</span> <span class='kw'>=</span> <span class='fu'><a href='circos.par.html'>circos.par</a></span>(<span class='st'>"cell.padding"</span>), <span class='kw'>bg.col</span> <span class='kw'>=</span> <span class='fl'>NA</span>, <span class='kw'>bg.border</span> <span class='kw'>=</span> <span class='st'>"black"</span>, <span class='kw'>bg.lty</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/graphics/par.html'>par</a></span>(<span class='st'>"lty"</span>), <span class='kw'>bg.lwd</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/graphics/par.html'>par</a></span>(<span class='st'>"lwd"</span>), <span class='kw'>panel.fun</span> <span class='kw'>=</span> <span class='kw'>function</span>(<span class='no'>x</span>, <span class='no'>y</span>) {<span class='kw'>NULL</span>}, <span class='kw'>factors</span> <span class='kw'>=</span> <span class='no'>sectors</span>)</pre> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> <table class="ref-arguments"> <colgroup><col class="name" /><col class="desc" /></colgroup> <tr> <th>sectors</th> <td><p>A <code><a href='https://rdrr.io/r/base/factor.html'>factor</a></code> or a character vector which represents categories of data, if it is <code>NULL</code>, then it uses all sector index.</p></td> </tr> <tr> <th>factors</th> <td><p>The same as <code>sectors</code>. It will be removed in future versions.</p></td> </tr> <tr> <th>x</th> <td><p>Data on x-axis. It is only used if <code>panel.fun</code> is set.</p></td> </tr> <tr> <th>y</th> <td><p>Data on y-axis</p></td> </tr> <tr> <th>ylim</th> <td><p>Range of data on y-axis</p></td> </tr> <tr> <th>force.ylim</th> <td><p>Whether to force all cells in the track to share the same <code>ylim</code>. Normally, all cells on a same track should have same <code>ylim</code>.</p></td> </tr> <tr> <th>track.index</th> <td><p>Index for the track which is going to be created/updated. If the specified track has already been created, this function just updated corresponding track with new plot. If the specified track is <code>NULL</code> or has not been created, this function just creates it. Note the value for this argument should not exceed maximum track index plus 1.</p></td> </tr> <tr> <th>track.height</th> <td><p>Height of the track. It is the percentage to the radius of the unit circles. The value can be set by <code><a href='uh.html'>uh</a></code> to an absolute unit. If updating a track (with proper <code>track.index</code> value), this argument is ignored.</p></td> </tr> <tr> <th>track.margin</th> <td><p>only affect current track</p></td> </tr> <tr> <th>cell.padding</th> <td><p>only affect current track</p></td> </tr> <tr> <th>bg.col</th> <td><p>Background color for the plotting regions. It can be vector which has the same length of sectors.</p></td> </tr> <tr> <th>bg.border</th> <td><p>Color for the border of the plotting regions. It can be vector which has the same length of sectors.</p></td> </tr> <tr> <th>bg.lty</th> <td><p>Line style for the border of the plotting regions. It can be vector which has the same length of sectors.</p></td> </tr> <tr> <th>bg.lwd</th> <td><p>Line width for the border of the plotting regions. It can be vector which has the same length of sectors.</p></td> </tr> <tr> <th>panel.fun</th> <td><p>Panel function to add graphics in each cell, see "details" section and vignette for explanation.</p></td> </tr> </table> <h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2> <p>This function tends to be a high-level plotting function, which means, you must first call this function to create plotting regions, then those low-level graphic function such as <code><a href='circos.points.html'>circos.points</a></code>, <code><a href='circos.lines.html'>circos.lines</a></code> can be applied.</p> <p>Currently, all the cells that are created in a same track sharing same height, which means, there is no cell has larger height than others.</p> <p>Since ranges for values on x-axis has already been defined by <code><a href='circos.initialize.html'>circos.initialize</a></code>, only ranges for values on y-axis should be specified in this function. There are two ways to identify the ranges for values on y-axes either by <code>y</code> or <code>ylim</code>. If <code>y</code> is set, it must has the same length as <code>factors</code> and the <code>ylim</code> for each cell is calculated from y values. Also, the ylim can be specified from <code>ylim</code> which can be a two-element vector or a matrix which has two columns and the number of rows is the same as the length of the levels of the factors.</p> <p>If there is no enough space for the new track or the new track overlaps with other tracks, there will be an error.</p> <p>If <code>factors</code> does not cover all sectors, the cells in remaining unselected sectors would also be created but without drawing anything. The <code>ylim</code> for these cells are the same as that in the last created cell.</p> <p>The function can also update a already-created track if the index for the track is specified. If updating an existed track, those parameters related to the position (such as track height and track margin) of the plotting region can not be changed.</p> <h2 class="hasAnchor" id="panel"><a class="anchor" href="#panel"></a>Panel</h2> <p><code>panel.fun</code> provides a convenient way to add graphics in each cell when initializing the tracks. The self-defined function needs two arguments: <code>x</code> and <code>y</code> which correspond to the data points in the current cell. When <code>factors</code>, <code>x</code>, and <code>y</code> are set in <code>circos.trackPlotRegion</code>, a subset of <code>x</code> and <code>y</code> are split by <code>factors</code> and are sent to <code>panel.fun</code> in the "current" cell. <code>circos.trackPlotRegion</code> creates plotting regions one by one on the track and <code>panel.fun</code> adds graphics in the 'current' cell after the plotting region for a certain cell has been created.</p> <p>See vignette for examples of how to use this feature.</p> <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2> <div class='dont-index'><p><a href='https://jokergoo.github.io/circlize_book/book/circular-layout.html'>https://jokergoo.github.io/circlize_book/book/circular-layout.html</a></p></div> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <pre class="examples"><div class='input'><span class='fu'><a href='circos.initialize.html'>circos.initialize</a></span>(<span class='no'>letters</span>[<span class='fl'>1</span>:<span class='fl'>8</span>], <span class='kw'>xlim</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>0</span>, <span class='fl'>1</span>))</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/base/Random.html'>set.seed</a></span>(<span class='fl'>123</span>) <span class='no'>df</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(<span class='kw'>fa</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/sample.html'>sample</a></span>(<span class='no'>letters</span>[<span class='fl'>1</span>:<span class='fl'>8</span>], <span class='fl'>100</span>, <span class='kw'>replace</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>), <span class='kw'>x</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/stats/Uniform.html'>runif</a></span>(<span class='fl'>100</span>), <span class='kw'>y</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/stats/Normal.html'>rnorm</a></span>(<span class='fl'>100</span>)) <span class='fu'><a href='circos.track.html'>circos.track</a></span>(<span class='kw'>ylim</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>0</span>, <span class='fl'>1</span>), <span class='kw'>bg.col</span> <span class='kw'>=</span> <span class='fu'><a href='rand_color.html'>rand_color</a></span>(<span class='fl'>8</span>))</div><div class='input'><span class='fu'><a href='circos.track.html'>circos.track</a></span>(<span class='no'>df</span>$<span class='no'>fa</span>, <span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>df</span>$<span class='no'>x</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>df</span>$<span class='no'>y</span>, <span class='kw'>panel.fun</span> <span class='kw'>=</span> <span class='kw'>function</span>(<span class='no'>x</span>, <span class='no'>y</span>) { <span class='fu'><a href='circos.points.html'>circos.points</a></span>(<span class='no'>x</span>, <span class='no'>y</span>) }, <span class='kw'>track.height</span> <span class='kw'>=</span> <span class='fl'>0.2</span>, <span class='kw'>bg.border</span> <span class='kw'>=</span> <span class='fu'><a href='rand_color.html'>rand_color</a></span>(<span class='fl'>8</span>))</div><div class='img'><img src='circos.trackPlotRegion-1.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'><a href='circos.clear.html'>circos.clear</a></span>()</div></pre> </div> <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar"> <nav id="toc" data-toggle="toc" class="sticky-top"> <h2 data-toc-skip>Contents</h2> </nav> </div> </div> <footer> <div class="copyright"> <p>Developed by Zuguang Gu.</p> </div> <div class="pkgdown"> <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p> </div> </footer> </div> </body> </html>