Skip to contents

This function creates an interaction track visualization from a BEDPE file or data frame. It is a wrapper around geom_link that provides a simpler interface.

Usage

ez_link(
  data,
  region,
  curvature = 0.5,
  height_factor = 0.15,
  direction = c("down", "up"),
  color = "gray50",
  size = 0.5,
  alpha = 0.7,
  use_score = FALSE,
  ...
)

Arguments

data

A BEDPE file path or data frame with interaction data

region

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

curvature

Numeric value controlling the arc curvature (0-1). Higher values create more pronounced curves. Default: 0.5

height_factor

Height of curves as proportion of genomic distance span. Higher values create taller arcs. Default: 0.15

direction

Direction of curve arcs: "down" (negative y, default) or "up" (positive y). Default: "down"

color

Color of the arcs. This is used when use_score = FALSE. Default: "gray50"

size

Line width of the arcs. Default: 0.5

alpha

Transparency level of the arcs (0 = transparent, 1 = opaque). Default: 0.7

use_score

Logical indicating whether to use the 'score' column for arc coloring. If TRUE, a color gradient will be applied based on the interaction scores. Default: FALSE

...

Additional arguments passed to geom_link()

Value

A ggplot2 object representing the link track.

Details

The function automatically handles different input types:

  • For BEDPE files: Uses interaction_track to read and process the data

  • For data frames: Expects columns for interaction coordinates (chr1, start1, end1, chr2, start2, end2) and optionally a 'score' column if use_score = TRUE

The visualization includes:

  • Arcs connecting interaction anchors

  • Optional score-based coloring

  • Automatic scaling to fit the specified genomic region

Examples

# From a data frame with uniform coloring
data(example_interactions)
ez_link(
  example_interactions,
  "chr1:1-15000",
  color = "darkblue",
  size = 1,
  alpha = 0.8
)