Skip to contents

This function creates signal tracks from a data frame with grouping capabilities. It can separate data into individual tracks using facets (track_by) and create overlapping tracks within each facet using different colors (group_by).

Usage

plot_signal_df(
  data,
  region,
  track_by = NULL,
  group_by = NULL,
  color_by = NULL,
  colors = NULL,
  type = "area",
  alpha = 0.8,
  binwidth = NULL,
  facet_scales = "free_y",
  ...
)

Arguments

data

A data frame containing signal data with columns: start, end, score, track_by (optional), and group_by (optional)

region

Genomic region to display (e.g., "chr1:1000000-2000000")

track_by

Column name in data for separating tracks into facets (optional)

group_by

Column name in data for grouping overlapping tracks (optional)

color_by

Column name in data for coloring tracks (defaults to group_by if not specified)

colors

Vector of colors for different groups (default: NULL, uses default ggplot2 colors)

type

Type of signal visualization: "line", "area", or "heatmap" (default: "area")

alpha

Transparency (default: 0.8)

binwidth

Width of bins in base pairs (default: NULL)

facet_scales

Scale parameter for facet_wrap (default: "free_y")

...

Additional arguments passed to geom_coverage

Value

A ggplot2 object

Examples

if (FALSE) { # \dontrun{
# Basic usage with track separation
p <- plot_signal_df(signal_data, "chr1:1000000-2000000", track_by = "sample")

# With both track separation and grouping
p <- plot_signal_df(signal_data, "chr1:1000000-2000000",
  track_by = "sample", group_by = "condition"
)
} # }