stat_bin {ggbio}R Documentation

Binning method

Description

Binning method especially for Rle and RleList, for data.frame it's just calling ggplot2::stat_bin.

Usage

## S4 method for signature 'data.frame'
stat_bin(data, ...)

## S4 method for signature 'Rle'
stat_bin(data, ..., binwidth, nbin = 30,
         xlab, ylab, main, geom = c("bar", "heatmap"),
         type = c("viewSums","viewMins",
                                  "viewMaxs", "viewMeans"))
## S4 method for signature 'RleList'
stat_bin(data, ..., binwidth, nbin = 30,
          xlab, ylab, main,
          indName = "sample",
          geom = c("bar", "heatmap"),
          type = c("viewSums","viewMins",
          "viewMaxs", "viewMeans"))

Arguments

data

a data.frame or Rle or RleList object.

...

arguments passed to aesthetics mapping.

binwidth

width of the bins.

nbin

number of bins.

xlab

x label.

ylab

y label.

main

title.

indName

when faceted by a RleList, name used for labeling faceted factor. Default is 'sample'.

geom

geometric types.

type

statistical summary method used within bins, shown as bar height or heatmap colors.

Value

a ggplot object.

Author(s)

Tengfei Yin

Examples

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() + stat_bin(xRle)
## Default use binwidth: range/30

plot of chunk unnamed-chunk-1

ggplot(xRle) + stat_bin()
## Default use binwidth: range/30

plot of chunk unnamed-chunk-1

ggplot(xRle) + stat_bin(nbin = 100)
## Default use binwidth: range/100

plot of chunk unnamed-chunk-1

ggplot(xRle) + stat_bin(binwidth = 200)

plot of chunk unnamed-chunk-1

p1 <- ggplot(xRle) + stat_bin(type = "viewMeans")
## Default use binwidth: range/30
p2 <- ggplot(xRle) + stat_bin(type = "viewSums")
## Default use binwidth: range/30
## y scale are different.
tracks(viewMeans = p1, viewSums = p2)

plot of chunk unnamed-chunk-1

ggplot(xRle) + stat_bin(geom = "heatmap")
## Default use binwidth: range/30

plot of chunk unnamed-chunk-1

ggplot(xRle) + stat_bin(nbin = 100, geom = "heatmap")
## Default use binwidth: range/100

plot of chunk unnamed-chunk-1

ggplot(xRle) + stat_bin(binwidth = 200, geom = "heatmap")

plot of chunk unnamed-chunk-1

## for RleList
ggplot(xRleList) + stat_bin()
## Default use binwidth: range/30

plot of chunk unnamed-chunk-1

ggplot(xRleList) + stat_bin(nbin = 100)
## Default use binwidth: range/100

plot of chunk unnamed-chunk-1

ggplot(xRleList) + stat_bin(binwidth = 200)

plot of chunk unnamed-chunk-1

p1 <- ggplot(xRleList) + stat_bin(type = "viewMeans")
## Default use binwidth: range/30
p2 <- ggplot(xRleList) + stat_bin(type = "viewSums")
## Default use binwidth: range/30
## y scale are different.
tracks(viewMeans = p1, viewSums = p2)

plot of chunk unnamed-chunk-1

ggplot(xRleList) + stat_bin(geom = "heatmap")
## Default use binwidth: range/30

plot of chunk unnamed-chunk-1

ggplot(xRleList) + stat_bin(nbin = 100, geom = "heatmap")
## Default use binwidth: range/100

plot of chunk unnamed-chunk-1

ggplot(xRleList) + stat_bin(binwidth = 200, geom = "heatmap")

plot of chunk unnamed-chunk-1


[Package ggbio version 1.5.20 ]