Last data update: 2014.03.03
R: Create a circle layout
layout_circle R Documentation
Create a circle layout
Description
Create a circle layout.
Usage
## S4 method for signature 'GRanges'
layout_circle(data, ..., geom = c("point", "line", "link", "ribbon",
"rect", "bar", "segment", "hist", "scale", "heatmap", "ideogram",
"text"), linked.to, radius = 10, trackWidth = 5,
space.skip = 0.015, direction = c("clockwise",
"anticlockwise"), link.fun = function(x, y, n = 30)
bezier(x, y, evaluation = n), rect.inter.n = 60, rank,
ylim = NULL,
scale.n = 60, scale.unit = NULL, scale.type = c("M",
"B", "sci"), grid.n = 5, grid.background = "gray70",
grid.line = "white", grid = FALSE, chr.weight = NULL)
## S4 method for signature 'missing'
layout_circle(data, ...)
circle(...)
Arguments
data
A GRanges
object.
...
Extra parameters such as aesthetics mapping in aes(), or
color, size
, etc. For circle function, it passed to layout_circle
.
geom
The geometric object to use display the data.
linked.to
Character indicates column that specifying end of the linking lines,
that column should be a GRanges
object.
radius
Numeric value indicates radius. Default is 10.
trackWidth
Numeric value indicates the track width.
space.skip
Numeric value indicates the ratio of skipped region between chunks(chromosomes
in GRanges
) to the whole track space.
direction
Space layout orders.
link.fun
Function used for interpolate the linking lines. Default is Hmisc::bezier.
rect.inter.n
n passed to interpolate function in rectangle transformation(from a
rectangle) to a section in circular view.
rank
For default equal trackWidth, use rank to specify the circle orders.
ylim
Numeric range to control y limits.
scale.n
Approximate number of ticks you want to show on the whole
space. used when scale.unit is NULL
.
scale.unit
Unit used for computing scale. Default is NULL
,
scale.type
Scale type used for
grid
logical value indicate showing grid background for track or not.
grid.n
integer value indicate horizontal grid line number.
grid.background
grid background color.
grid.line
grid line color.
chr.weight
numeric vectors which sum to <1, the names of vectors has to be
matched with seqnames in seqinfo, and you can only specify part of the
seqnames, other lengths of chromosomes will be assined proportionally
to their seqlengths, for example, you could specify chr1 to be 0.5, so
the chr1 will take half of the space and other chromosomes squeezed to
take left of the space.
Value
A 'Layer'.
Author(s)
Tengfei Yin
Examples
N <- 100
library(GenomicRanges)
## ======================================================================
## simmulated GRanges
## ======================================================================
gr <- GRanges(seqnames =
sample(c("chr1", "chr2", "chr3"),
size = N, replace = TRUE),
IRanges(
start = sample(1:300, size = N, replace = TRUE),
width = sample(70:75, size = N,replace = TRUE)),
strand = sample(c("+", "-", "*"), size = N,
replace = TRUE),
value = rnorm(N, 10, 3), score = rnorm(N, 100, 30),
sample = sample(c("Normal", "Tumor"),
size = N, replace = TRUE),
pair = sample(letters, size = N,
replace = TRUE))
seqlengths(gr) <- c(400, 500, 700)
values(gr)$to.gr <- gr[sample(1:length(gr), size = length(gr))]
## doesn't pass gr to the ggplot
ggplot() + layout_circle(gr, geom = "ideo", fill = "gray70", radius = 7, trackWidth = 3) +
layout_circle(gr, geom = "bar", radius = 10, trackWidth = 4, aes(fill = score, y = score)) +
layout_circle(gr, geom = "point", color = "red", radius = 14,
trackWidth = 3, grid = TRUE, aes(y = score)) +
layout_circle(gr, geom = "link", linked.to = "to.gr", radius = 6,
trackWidth = 1)
## more formal API
ggplot(gr) + layout_circle(geom = "ideo", fill = "gray70", radius = 7, trackWidth = 3) +
layout_circle(geom = "bar", radius = 10, trackWidth = 4, aes(fill = score, y = score)) +
layout_circle(geom = "point", color = "red", radius = 14,
trackWidth = 3, grid = TRUE, aes(y = score)) +
layout_circle(geom = "link", linked.to = "to.gr", radius = 6, trackWidth = 1)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(ggbio)
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Loading required package: ggplot2
Need specific help about ggbio? try mailing
the maintainer or visit http://tengfei.github.com/ggbio/
Attaching package: 'ggbio'
The following objects are masked from 'package:ggplot2':
geom_bar, geom_rect, geom_segment, ggsave, stat_bin, stat_identity,
xlim
Warning message:
replacing previous import 'ggplot2::Position' by 'BiocGenerics::Position' when loading 'ggbio'
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/ggbio/layout_circle-method.Rd_%03d_medium.png", width=480, height=480)
> ### Name: layout_circle
> ### Title: Create a circle layout
> ### Aliases: circle layout_circle layout_circle,GRanges-method
> ### layout_circle,missing-method layout_circle,uneval-method
>
> ### ** Examples
>
> N <- 100
> library(GenomicRanges)
Loading required package: S4Vectors
Loading required package: stats4
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
Loading required package: IRanges
Loading required package: GenomeInfoDb
> ## ======================================================================
> ## simmulated GRanges
> ## ======================================================================
> gr <- GRanges(seqnames =
+ sample(c("chr1", "chr2", "chr3"),
+ size = N, replace = TRUE),
+ IRanges(
+ start = sample(1:300, size = N, replace = TRUE),
+ width = sample(70:75, size = N,replace = TRUE)),
+ strand = sample(c("+", "-", "*"), size = N,
+ replace = TRUE),
+ value = rnorm(N, 10, 3), score = rnorm(N, 100, 30),
+ sample = sample(c("Normal", "Tumor"),
+ size = N, replace = TRUE),
+ pair = sample(letters, size = N,
+ replace = TRUE))
>
>
> seqlengths(gr) <- c(400, 500, 700)
> values(gr)$to.gr <- gr[sample(1:length(gr), size = length(gr))]
>
> ## doesn't pass gr to the ggplot
> ggplot() + layout_circle(gr, geom = "ideo", fill = "gray70", radius = 7, trackWidth = 3) +
+ layout_circle(gr, geom = "bar", radius = 10, trackWidth = 4, aes(fill = score, y = score)) +
+ layout_circle(gr, geom = "point", color = "red", radius = 14,
+ trackWidth = 3, grid = TRUE, aes(y = score)) +
+ layout_circle(gr, geom = "link", linked.to = "to.gr", radius = 6,
+ trackWidth = 1)
>
> ## more formal API
> ggplot(gr) + layout_circle(geom = "ideo", fill = "gray70", radius = 7, trackWidth = 3) +
+ layout_circle(geom = "bar", radius = 10, trackWidth = 4, aes(fill = score, y = score)) +
+ layout_circle(geom = "point", color = "red", radius = 14,
+ trackWidth = 3, grid = TRUE, aes(y = score)) +
+ layout_circle(geom = "link", linked.to = "to.gr", radius = 6, trackWidth = 1)
>
>
>
>
>
>
> dev.off()
null device
1
>