Skip to content

Commit

Permalink
Export and add example for plot_events_single
Browse files Browse the repository at this point in the history
See #3.
  • Loading branch information
ezwelty committed Apr 6, 2023
1 parent fa9f969 commit bbc8bda
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export(has_overlapping_events)
export(is_events)
export(is_unsorted_events)
export(plot_events)
export(plot_events_single)
export(read_events)
export(sample_events)
export(seq_events)
Expand Down
12 changes: 9 additions & 3 deletions R/plot_events.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' @param mar Numerical vector of the form c(bottom, left, top, right) giving the size of the inner margins of each plot in lines of text.
#' @param oma Numeric vector of the form c(bottom, left, top, right) giving the size of the outer figure margins in lines of text.
#' @param ... Additional arguments passed to \code{\link{plot}}.
#' @seealso \code{\link{seq_events}} for generating groups of sequential bins, \code{\link{sample_events}} to populate groups of bins with event data.
#' @seealso \code{\link{plot_events_single}} for more control over individual plots, \code{\link{seq_events}} for generating groups of sequential bins, \code{\link{sample_events}} to populate groups of bins with event data.
#' @export
#' @import graphics
#' @examples
Expand Down Expand Up @@ -109,7 +109,7 @@ plot_events <- function(e, group.col = NULL, groups = NULL, data.cols = NULL, di
#'
#' Plots event table columns as vertical bars.
#'
#' The specified event table columns are plotted together as stacked bars. Negative and positive values are stacked separately from the \code{y = 0} baseline. Events with \code{NA} are not shown, differentiating them from zero-valued events which are drawn as thin black lines. Point events are drawn as thin vertical lines. Overlapping events are drawn as overlapping bars, so it is best to use \code{\link{sample_events}} with non-overlapping bins to flatten the data before plotting.
#' The specified event table columns are plotted together as stacked bars. Negative and positive values are stacked separately from the \code{y = 0} baseline. Events with \code{NA} are not shown, differentiating them from zero-valued events which are drawn as thin black lines. Point events are drawn as thin vertical lines. Overlapping events are drawn as overlapping bars, so it is best to use \code{\link{sample_events}} with non-overlapping bins to flatten the data before plotting, then call this function for each bin group (if using multiple bin groups).
#'
#' @param e An event table.
#' @param cols Names or indices of the event table columns to plot together as stacked bars.
Expand All @@ -127,8 +127,14 @@ plot_events <- function(e, group.col = NULL, groups = NULL, data.cols = NULL, di
#' @param xpd Logical value or \code{NA}. If \code{FALSE}, all plotting is clipped to the plot region, if \code{TRUE}, all plotting is clipped to the figure region, and if \code{NA}, all plotting is clipped to the device region.
#' @param ... Additional arguments passed to \code{\link{plot}}.
#' @seealso \code{\link{plot_events}}.
#' @keywords internal
#' @export
#' @import graphics
#' @examples
#' e <- events(from = c(0, 10, 15, 25), to = c(10, 20, 25, 40), length = c(10, 10, 10, 15),
#' x = c(1, 2, 1, 1), f = c('a', 'b', 'a', 'a'))
#' bins <- seq_events(event_coverage(e), c(8, 4, 2, 1))
#' e.bins <- sample_events(e, bins, list(sum, c('x', 'length')), scaled.cols = 'length')
#' plot_events_single(e.bins[e.bins$group == 1, ], cols = 'x')
plot_events_single <- function(e, cols, xlim = NULL, ylim = NULL, xticks = NULL, yticks = NULL, xtick.labels = NULL, ytick.labels = NULL, main = NA, xlab = NA, ylab = NA, plot.grid = FALSE, sigfigs = c(3, 3), col = grDevices::grey.colors(length(cols)), border = par("fg"), lty = par("lty"), lwd = par("lwd"), xpd = FALSE, ...) {

# Compute plot limits
Expand Down
2 changes: 1 addition & 1 deletion man/plot_events.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions man/plot_events_single.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bbc8bda

Please sign in to comment.