plotMotif: Plot Motif Count or Fraction as Bar Plot

View source: R/plotMotif.R

plotMotifR Documentation

Plot Motif Count or Fraction as Bar Plot

Description

Creates a bar plot to visualize motif counts or fractions from genomic data. Uses 'ggplot2' for plotting and 'tidyr' and 'dplyr' for data manipulation.

Usage

plotMotif(
  x,
  ylim = NULL,
  x_title = "Motif",
  plot_type = c("Fraction"),
  bar_color = c(A = "cornflowerblue", C = "darksalmon", G = "palevioletred2", T =
    "forestgreen"),
  motif_levels = c("C", "G", "A", "T"),
  output_file = NULL,
  ggsave_params = list(width = 16, height = 4, unit = "cm", bg = "white", dpi = 500),
  ...
)

Arguments

x

Object containing the data to plot.

ylim

Numeric vector of length 2 providing y axis limits.

x_title

Character string, title for the x axis.

plot_type

Character string specifying the type of plot: 'count' or 'fraction'.

bar_color

Color to be used for bars in the plot.

motif_levels

Character vector specifying the order and inclusion of motif levels.

output_file

Optional string specifying the path and filename where the plot should be saved. Include the file extension, such as '.png' or '.pdf'.

ggsave_params

List of parameters to be passed to 'ggplot2::ggsave()'. This list can include any of the arguments that 'ggsave()' accepts. Example: 'list(width = 10, height = 8, dpi = 300)'

...

Additional arguments passed on to 'geom_bar()'.

Value

Returns a 'ggplot2' object.

Examples

## Not run: 
  plot <- plotMotif(data, ylim = c(0, 20), x_title = "Motif",
                    plot_type = "count", bar_color = "blue")

## End(Not run)

hw538/cfDNAPro documentation built on Feb. 17, 2025, 6:09 p.m.