Skip to content

Commit

Permalink
KB/MB -> kb/Mb
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed May 30, 2020
1 parent c16ea59 commit 5fd7958
Show file tree
Hide file tree
Showing 26 changed files with 585 additions and 24 deletions.
12 changes: 12 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export("circos.updatePlotRegion")
export("circos.violin")
export("circos.xaxis")
export("circos.yaxis")
export("cm_h")
export("cm_x")
export("cm_y")
export("col2value")
export("colorRamp2")
export("convert_height")
Expand All @@ -81,6 +84,15 @@ export("get.current.track.index")
export("getI")
export("highlight.chromosome")
export("highlight.sector")
export("inch_h")
export("inch_x")
export("inch_y")
export("inches_h")
export("inches_x")
export("inches_y")
export("mm_h")
export("mm_x")
export("mm_y")
export("posTransform.default")
export("posTransform.text")
export("rainfallTransform")
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Changes in version 0.4.10
* add `circos.boxplot()` and `circos.violin()`.
* sector index are all enforced to be character.
* `circos.nested()`: now the graphic parameters are reordered accordingly as the `correspondance`.
* add `mm_x()`, `mm_y()`, `mm_h()`, `cm_x()`, `cm_y()`, `cm_h()`, `inches_x()`, `inches_y()`, `inches_h()`
functions

Changes in version 0.4.9
-----------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions R/genomic.R
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ circos.genomicAxis = function(

if(is.null(labels)) {
if(major.by > 1e6) {
major.tick.labels = paste((major.at-offset)/1000000, "MB", sep = "")
major.tick.labels = paste((major.at-offset)/1000000, "Mb", sep = "")
} else if(major.by > 1e3) {
major.tick.labels = paste((major.at-offset)/1000, "KB", sep = "")
major.tick.labels = paste((major.at-offset)/1000, "kb", sep = "")
} else {
major.tick.labels = paste((major.at-offset), "bp", sep = "")
}
Expand Down
242 changes: 234 additions & 8 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ col2value = function(r, g, b, col_fun) {
# Since in the circular plot, the aspect ratio is always 1, it does not matter this conversion
# is applied on x direction or y direction.
#
# This function is mainly used in the radical direction.
#
# == seealso
# `convert_x` and `convert_y` convert absolute units into a data coordinate in a specified cell.
#
Expand Down Expand Up @@ -630,6 +632,9 @@ convert_length = function(x, unit = c("mm", "cm", "inches")) {
# This function is same as `convert_length`. The reason for naming this function
# is `convert_length` is mostely used for defining the height of tracks and track margins.
#
# == seealso
# For pre-defined units, users can use `cm_h`, `mm_h` and `inches_h`.
#
# == author
# Zuguang Gu <[email protected]>
#
Expand Down Expand Up @@ -731,6 +736,8 @@ convert_unit_in_data_coordinate = function(x, unit = c("mm", "cm", "inches", "ca
# A vector of numeric values which are measured in the specified data coordinate
#
# == seealso
# For pre-defined units, users can use `cm_x`, `mm_x` and `inches_x`.
#
# `convert_y` converts on y direction.
#
# https://jokergoo.github.io/circlize_book/book/circular-layout.html#convert-functions
Expand All @@ -742,21 +749,21 @@ convert_unit_in_data_coordinate = function(x, unit = c("mm", "cm", "inches", "ca
# fa = letters[1:10]
# circos.par(cell.padding = c(0, 0, 0, 0), track.margin = c(0, 0))
# circos.initialize(fa, xlim = cbind(rep(0, 10), runif(10, 0.5, 1.5)))
# circos.track(ylim = c(0, 1), track.height = convert_height(5, "mm"),
# circos.track(ylim = c(0, 1), track.height = mm_h(5),
# panel.fun = function(x, y) {
# circos.lines(c(0, 0 + convert_x(5, "mm")), c(0.5, 0.5), col = "blue")
# circos.lines(c(0, 0 + mm_x(5)), c(0.5, 0.5), col = "blue")
# })
# circos.par(track.margin = c(0, convert_height(2, "mm")))
# circos.par(track.margin = c(0, mm_h(2)))
# circos.track(ylim = c(0, 1), track.height = convert_height(1, "cm"),
# panel.fun = function(x, y) {
# xcenter = get.cell.meta.data("xcenter")
# circos.lines(c(xcenter, xcenter), c(0, convert_y(1, "cm")), col = "red")
# circos.lines(c(xcenter, xcenter), c(0, cm_y(1)), col = "red")
# })
# circos.par(track.margin = c(0, convert_height(5, "mm")))
# circos.track(ylim = c(0, 1), track.height = convert_height(1, "inches"),
# circos.par(track.margin = c(0, mm_h(5)))
# circos.track(ylim = c(0, 1), track.height = inch_h(1),
# panel.fun = function(x, y) {
# line_length_on_x = convert_x(1*sqrt(2)/2, "cm")
# line_length_on_y = convert_y(1*sqrt(2)/2, "cm")
# line_length_on_x = cm_x(1*sqrt(2)/2)
# line_length_on_y = cm_y(1*sqrt(2)/2)
# circos.lines(c(0, line_length_on_x), c(0, line_length_on_y), col = "orange")
# })
# circos.clear()
Expand Down Expand Up @@ -803,6 +810,8 @@ ux = function(...) {
# A vector of numeric values which are measured in the specified data coordinate
#
# == seealso
# For pre-defined units, users can use `cm_y`, `mm_y` and `inches_y`.
#
# `convert_x` converts on x direction.
#
# https://jokergoo.github.io/circlize_book/book/circular-layout.html#convert-functions
Expand Down Expand Up @@ -867,6 +876,223 @@ convert_unit_in_canvas_coordinate = function(x, unit = c("mm", "cm", "inches"))
return(len)
}

# == title
# Convert unit on x direction in data coordinate
#
# == param
# -... pass to `convert_x`
#
# == details
# This function is same as `convert_x` in cm unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_x` page
# NULL
cm_x = function(...) {
convert_x(..., unit = "cm")
}
# == title
# Convert unit on y direction in data coordinate
#
# == param
# -... pass to `convert_y`
#
# == details
# This function is same as `convert_y` in cm unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_y` page
# NULL
cm_y = function(...) {
convert_y(..., unit = "cm")
}
# == title
# Convert units
#
# == param
# -... pass to `convert_length`
#
# == details
# This function is same as `convert_length` in cm unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_length` page
# NULL
cm_h = function(...) {
convert_length(..., unit = "cm")
}
# == title
# Convert unit on x direction in data coordinate
#
# == param
# -... pass to `convert_x`
#
# == details
# This function is same as `convert_x` in mm unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_x` page
# NULL
mm_x = function(...) {
convert_x(..., unit = "mm")
}
# == title
# Convert unit on y direction in data coordinate
#
# == param
# -... pass to `convert_y`
#
# == details
# This function is same as `convert_y` in mm unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_y` page
# NULL
mm_y = function(...) {
convert_y(..., unit = "mm")
}
# == title
# Convert units
#
# == param
# -... pass to `convert_length`
#
# == details
# This function is same as `convert_length` in mm unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_length` page
# NULL
mm_h = function(...) {
convert_length(..., unit = "mm")
}
# == title
# Convert unit on x direction in data coordinate
#
# == param
# -... pass to `convert_x`
#
# == details
# This function is same as `convert_x` in inch unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_x` page
# NULL
inches_x = function(...) {
convert_x(..., unit = "inches")
}
# == title
# Convert unit on y direction in data coordinate
#
# == param
# -... pass to `convert_y`
#
# == details
# This function is same as `convert_y` in inch unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_y` page
# NULL
inches_y = function(...) {
convert_y(..., unit = "inches")
}
# == title
# Convert units
#
# == param
# -... pass to `convert_length`
#
# == details
# This function is same as `convert_length` in inch unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_length` page
# NULL
inches_h = function(...) {
convert_length(..., unit = "inches")
}
# == title
# Convert unit on x direction in data coordinate
#
# == param
# -... pass to `convert_x`
#
# == details
# This function is same as `convert_x` in inch unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_x` page
# NULL
inch_x = function(...) {
convert_x(..., unit = "inches")
}
# == title
# Convert unit on y direction in data coordinate
#
# == param
# -... pass to `convert_y`
#
# == details
# This function is same as `convert_y` in inch unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_y` page
# NULL
inch_y = function(...) {
convert_y(..., unit = "inches")
}
# == title
# Convert units
#
# == param
# -... pass to `convert_length`
#
# == details
# This function is same as `convert_length` in inch unit.
#
# == author
# Zuguang Gu <[email protected]>
#
# == example
# # see example in `convert_length` page
# NULL
inch_h = function(...) {
convert_length(..., unit = "inches")
}

stop_wrap = function(...) {
x = paste0(...)
x = paste(strwrap(x), collapse = "\n")
Expand Down
2 changes: 1 addition & 1 deletion man/circos.genomicDensity.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This function is a high-level graphical function, and it will create a new track
load(system.file(package = "circlize", "extdata", "DMR.RData"))

# rainfall
\dontrun{
\donttest{
circos.initializeWithIdeogram(plotType = c("axis", "labels"))

bed_list = list(DMR_hyper, DMR_hypo)
Expand Down
2 changes: 1 addition & 1 deletion man/circos.genomicHeatmap.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ for the heamtaps. The heatmaps always fill the whole track.
\url{https://jokergoo.github.io/circlize_book/book/high-level-genomic-functions.html#genomic-heatmap}
}
\examples{
\dontrun{
\donttest{
circos.initializeWithIdeogram(plotType = c("labels", "axis"))
bed = generateRandomBed(nr = 100, nc = 4)
col_fun = colorRamp2(c(-1, 0, 1), c("green", "black", "red"))
Expand Down
2 changes: 1 addition & 1 deletion man/circos.genomicLink.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you want to have more controls on links, please use \code{\link{circos.link}}
\url{https://jokergoo.github.io/circlize_book/book/genomic-plotting-region.html#genomic-links}
}
\examples{
\dontrun{
\donttest{
set.seed(123)

bed1 = generateRandomBed(nr = 100)
Expand Down
2 changes: 1 addition & 1 deletion man/circos.genomicRainfall.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ On the plot, y-axis are log10-transformed.
\url{https://jokergoo.github.io/circlize_book/book/high-level-genomic-functions.html#genomic-density-and-rainfall-plot}
}
\examples{
\dontrun{
\donttest{
load(system.file(package = "circlize", "extdata", "DMR.RData"))

# rainfall
Expand Down
2 changes: 1 addition & 1 deletion man/circos.genomicRect.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ circos.genomicRect(
The function is a low-level graphical function and usually is put in \code{panel.fun} when using \code{\link{circos.genomicTrackPlotRegion}}.
}
\examples{
\dontrun{
\donttest{
############################
### rect matrix
circos.par("track.height" = 0.1, cell.padding = c(0, 0, 0, 0))
Expand Down
2 changes: 1 addition & 1 deletion man/circos.initializeWithIdeogram.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The style of ideogram is almost fixed, but you can customize it with your self-s
\url{https://jokergoo.github.io/circlize_book/book/initialize-genomic-plot.html#initialize-cytoband}
}
\examples{
\dontrun{
\donttest{
circos.initializeWithIdeogram()
cytoband.file = system.file(package = "circlize",
Expand Down
Loading

0 comments on commit 5fd7958

Please sign in to comment.