Skip to content

Commit

Permalink
add xaxis.clock.wise option in circos.par()
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed Aug 15, 2020
1 parent 98cb515 commit 6d0077f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: circlize
Type: Package
Title: Circular Visualization
Version: 0.4.11
Date: 2020-06-14
Date: 2020-08-15
Author: Zuguang Gu
Maintainer: Zuguang Gu <[email protected]>
Depends: R (>= 3.0.0), graphics
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export("uh")
export("ux")
export("uy")

import(graphics)
import("GlobalOptions")
import(graphics)
importFrom("colorspace", HLS)
importFrom("colorspace", HSV)
importFrom("colorspace", LAB)
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changes in version 0.4.11
* `chordDiagram()`: add `link.target.prop` and `target.prop.height` arguments
* `circos.par()`: add `circle.margin` option
* `circos.genomicLabels()`: fixed a bug when `direction = "outside"`
* add `xaxis.clock.wise` option in `circos.par()`

Changes in version 0.4.10
-----------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions R/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ resetGlobalVariable()
# circle in the region of (0, pi/2).
# -``canvas.ylim`` The coordinate for the canvas. By default it is ``c(-1, 1)``
# -``clock.wise`` The direction for adding sectors. Default is ``TRUE``.
# -``xaxis.clock.wise`` The direction in the x-axes for all sectors. Default is ``TRUE``.
#
# Similar as `graphics::par`, you can get the parameter values by specifying the
# names of parameters and you can set the parameter values by specifying a
Expand Down Expand Up @@ -177,6 +178,14 @@ circos.par = setGlobalOptions(
}
return(x)
}),
xaxis.clock.wise = list(
.value = TRUE,
.filter = function(x) {
if(is.circos.initialized()){
warning_wrap("'xaxis.clock.wise' can only be modified before `circos.initialize`, or maybe you forgot to call `circos.clear` in your last plot.")
}
return(x)
}),
lend = list(
.value = NULL,
.visible = FALSE,
Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ circlize = function(

theta = sector.data["start.degree"] - (x - sector.data["min.value"]) / (sector.data["max.value"] - sector.data["min.value"]) *
abs(sector.data["start.degree"] - sector.data["end.degree"])

if(!circos.par("xaxis.clock.wise")) {
theta = sector.data["start.degree"] - theta + sector.data["end.degree"]
}

if(track.index == 0) {
rou = rep(1, length(theta))
Expand Down
1 change: 1 addition & 0 deletions man/circos.par.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Global parameters for the circular layout. Currently supported parameters are:
\item{\code{canvas.xlim}}{The coordinate for the canvas. Because \code{circlize} draws everything (or almost everything) inside the unit circle, the default \code{canvas.xlim} and \code{canvas.ylim} for the canvas would be all \code{c(-1, 1)}. However, you can set it to a more broad interval if you want to draw other things out of the circle. By choosing proper \code{canvas.xlim} and \code{canvas.ylim}, you can draw part of the circle. E.g. setting \code{canvas.xlim} to \code{c(0, 1)} and \code{canvas.ylim} to \code{c(0, 1)} would only draw circle in the region of (0, pi/2).}
\item{\code{canvas.ylim}}{The coordinate for the canvas. By default it is \code{c(-1, 1)}}
\item{\code{clock.wise}}{The direction for adding sectors. Default is \code{TRUE}.}
\item{\code{xaxis.clock.wise}}{The direction in the x-axes for all sectors. Default is \code{TRUE}.}
}
Similar as \code{\link[graphics]{par}}, you can get the parameter values by specifying the
Expand Down

0 comments on commit 6d0077f

Please sign in to comment.