geom_rect {ggbio}R Documentation

Rect geoms for GRanges object

Description

Show interval data as rectangle.

Usage

## For data.frame
## S4 method for signature 'data.frame'
geom_rect(data, ...)
## For GRanges
## S4 method for signature 'GRanges'
geom_rect(data,..., xlab, ylab, main,
          facets = NULL, stat = c("stepping", "identity"),
          rect.height = NULL,
          group.selfish = TRUE)

Arguments

data

A GRanges or data.frame object. When it's data.frame, it's simply calling ggplot2::geom_rect.

...

Extra parameters such as aes() or color, size passed.

xlab

Label for x

ylab

Label for y

main

Title for plot.

facets

Faceting formula to use.

stat

Character vector specifying statistics to use. "stepping" with randomly assigned stepping levels as y varialbe. "identity" allow users to specify y value in aes.

rect.height

Half height of the arrow body.

group.selfish

Passed to addStepping, control whether to show each group as unique level or not. If set to FALSE, if two groups are not overlapped with each other, they will probably be layout in the same level to save space.

Value

A 'Layer'.

Author(s)

Tengfei Yin

Examples

set.seed(1)
N <- 100
require(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))
## ======================================================================
##  data.frame call ggplot2::geom_rect
## ======================================================================
ggplot() + geom_rect(data = mtcars, aes(xmin = mpg, ymin = wt, xmax = mpg + 10, ymax = wt + 0.2,
                       fill = cyl))

plot of chunk unnamed-chunk-1

## ======================================================================
##  default
## ======================================================================
ggplot(gr) + geom_rect()

plot of chunk unnamed-chunk-1

# or
ggplot() + geom_rect(gr)

plot of chunk unnamed-chunk-1

## ======================================================================
##  facetting and aesthetics
## ======================================================================
ggplot(gr) + geom_rect(facets = sample ~ seqnames, aes(color = strand, fill = strand))

plot of chunk unnamed-chunk-1

## ======================================================================
##  stat:identity
## ======================================================================
ggplot(gr) + geom_rect(stat = "identity", aes(y = value))

plot of chunk unnamed-chunk-1

## ======================================================================
##  stat:stepping
## ======================================================================
ggplot(gr) + geom_rect(stat = "stepping", aes(y = value, group = pair))

plot of chunk unnamed-chunk-1

## ======================================================================
##  group.selfish controls when 
## ======================================================================
ggplot(gr) + geom_rect(stat = "stepping", aes(y = value, group = pair), group.selfish = FALSE)

plot of chunk unnamed-chunk-1


[Package ggbio version 1.5.20 ]