stat_identity {ggbio} | R Documentation

## Transform the data to a data.frame and for multiple geoms.

### Description

Transform the data to a suitable data.frame and then one could use multiple geom or even stat to re-plot the data.

### Usage

    ## S4 method for signature 'ANY'
    stat_identity(data, ...)

    ## S4 method for signature 'GRanges'
    stat_identity(data, ..., geom = NULL)

    ## S4 method for signature 'Rle'
    stat_identity(data, ..., xlab, ylab, main, geom = NULL)

    ## S4 method for signature 'RleList'
    stat_identity(data, ..., xlab, ylab, main,
              geom = NULL, indName = "sample")

### Arguments

`data` | Typically a `GRanges` or `data.frame` object.
`...` | Extra parameters such as aes() passed to `geom_rect`, `geom_alignment`, or `geom_segment`.
`geom` | The geometric object to use display the data.
`xlab` | x label.
`ylab` | y label.
`main` | title of graphic..
`indName` | sample name.

### Value

A 'Layer'.

### Author(s)

Tengfei Yin

### Examples

    ##  load
    set.seed(1)
    N <- 50

    require(GenomicRanges)
    ##  simul
    ## ======================================================================
    ##  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))

    ##  geom_point_start
    ggplot() + stat_identity(gr, aes(x = start, y = value), geom = "point")
    ## or more formal
    ggplot(gr) + stat_identity(aes(x = start, y = value), geom = "point")

    ##  geom_point_midpoint
    ggplot(gr) + stat_identity(aes(x = midpoint, y = value), geom = "point")

    ##  geom_rect_all
    ggplot(gr) + stat_identity(aes(xmin = start, xmax = end,
                                     ymin = value - 0.5, ymax = value + 0.5),
                               geom = "rect")

    ##  geom_rect_y
    ggplot(gr) + stat_identity(aes(y = value), geom = "rect")

    ##  geom_line
    ggplot(gr) + stat_identity(aes(x = start, y = value),  geom = "line")

    ##  geom_segment
    ggplot(gr) + stat_identity(aes(y = value), geom = "segment")

    ## Rle/RleList
    library(IRanges)
    lambda <- c(rep(0.001, 4500), seq(0.001, 10, length = 500),
                seq(10, 0.001, length = 500))
    xVector <- rpois(1e4, lambda)
    xRle <- Rle(xVector)
    xRleList <- RleList(xRle, 2L * xRle)

    ggplot(xRle) + stat_identity(geom = "point")
    ggplot(xRleList) + stat_identity(geom = "point")

[Package ggbio version 1.35.2 Index]