position_disjoint_ranges: Segregrating overlapping ranges

Description Usage Arguments Details Value See Also Examples

View source: R/position_disjoint_ranges.R

Description

One-dimensional ranged data in the x-direction is segregated in the y-direction such that no overlap in twodimensional space occurs. This positioning works best when no relevant information is plotted in the y-direction.

Usage

1
position_disjoint_ranges(extend = 1, stepsize = 1, dir = NULL)

Arguments

extend

a numeric of length 1 indicating how far a range should be extended in total for calculating overlaps. Setting this argument to a positive number leaves some space between ranges in the same bin.

stepsize

a numeric of length 1 that determines how much space is added between bins in the y-direction. A positive value grows the bins from bottom to top, while a negative value grows the bins from top to bottom.

dir

A character of length 1, either "x" or "y", naming the direction to consider the range. NULL (the default) tries to sniff which direction to take, but internally defaults to "x" when it can't decide

Details

An object is considered disjoint from a second object when the range between their xmin and xmax coordinates don't overlap. Objects that overlap are assigned to different bins in the y-direction, whereby lower bins are filled first. This way, information in the x-direction is preserved and different objects can be discerned.

Note that this positioning is only particularly useful when y-coordinates do not encode relevant information. Geoms that pair well with this positioning are geom_rect, geom_tile.

This positioning function was inspired by the disjointBins() function in the IRanges package, but has been written such that it accepts any numeric input next to solely integer input.

Value

A Position ggproto object.

See Also

disjointBins

Examples

1
2
3
4
5
6
7
8
# Even though geom_tile() is parametrised by middle-x values, it is
# internally converted to xmin, xmax, ymin, ymax parametrisation so the
# positioning still works.

ggplot() +
  geom_tile(aes(x = rnorm(200), y = 0),
            width = 0.2, height = 0.9,
            position = position_disjoint_ranges(extend = 0.1))

teunbrand/ggnomics documentation built on Aug. 2, 2020, 7:34 p.m.