Skip to contents

Draws BED-like intervals as bars of fixed height, one row per level of the y aesthetic. xmin and xmax default to the start and end columns. Pair with coord_locus() to zoom to a window and theme_genomic() for track styling.

Usage

geom_bed_track(
  mapping = NULL,
  data = NULL,
  bar_height = 5,
  ...,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping

Set of aesthetic mappings created by ggplot2::aes(). Typically y (e.g. sample) and optionally fill.

data

GRanges object or data frame of intervals with seqnames, start, and end columns, e.g. from devgru::read_bed_file().

bar_height

Height of the bars in mm, default: 5

...

Other arguments passed to gggenes::geom_gene_arrow(), e.g. colour or alpha. Bars have no outline unless colour is mapped or set.

na.rm, show.legend, inherit.aes

See ggplot2::layer().

Value

ggplot2 layer

Examples

if (FALSE) { # \dontrun{
chrom_states <- devgru::read_bed_file("segments.bed", additional_col_names = "segment_label")

ggplot2::ggplot() +
  geom_bed_track(data = chrom_states, ggplot2::aes(y = sample, fill = segment_label)) +
  coord_locus("chr1:203296001-203313000") +
  theme_genomic()

# Tornado sort: order rows by interval width, largest at top
ggplot2::ggplot() +
  geom_bed_track(data = chrom_states, ggplot2::aes(y = reorder(sample, end - start))) +
  coord_locus("chr1:203296001-203313000")
} # }