plot.ras: Plot a RAS Result Object

View source: R/plot.R

plot.rasR Documentation

Plot a RAS Result Object

Description

S3 plot method for objects of class "ras" returned by ras. When zoom = FALSE (default) produces the full-chromosome scan profile with detected changepoints marked. When zoom = TRUE produces the zoomed multi-panel figure around each detected changepoint.

Usage

## S3 method for class 'ras'
plot(
  x,
  zoom = FALSE,
  device = "pdf",
  p.threshold = 8,
  y_cap = NULL,
  min_display_p = 1,
  xlim = NULL,
  zoom_half_width = 3000,
  ncol = 3,
  min_signal = 2.5,
  ...
)

Arguments

x

Object of class "ras" as returned by ras.

zoom

Logical. FALSE (default) plots the full scan profile; TRUE plots zoomed panels around each detected changepoint.

device

Character. Output device: "pdf" (default), "png", or "screen".

p.threshold

Numeric. Significance reference line on the -\log_{10} scale. Default 8.

y_cap

Numeric or NULL. Cap the y-axis (scan plot only). Default NULL.

min_display_p

Numeric. Minimum all.p.values for a candidate to appear in the dual-axis overlay (scan plot only). Default 1.

xlim

Numeric vector of length 2, or NULL. Restrict plot to this genomic range (scan plot only). Default NULL.

zoom_half_width

Numeric. Half-width of each zoom panel in SNP index units (zoom plot only). Default 3000.

ncol

Integer. Columns in the zoom panel grid (zoom plot only). Default 3.

min_signal

Numeric. Low-signal colour boundary on the -\log_{10} scale: scan values below this threshold are drawn in blue; values at or above it are drawn in yellow or higher. Should match the value passed to ras_validate. Default 2.5.

...

Currently unused.

Value

Invisibly returns x. Called for its side effect of writing plot files or rendering to the active graphics device.

See Also

ras for the function that produces the "ras" object. print.ras for the console summary.

Examples

## Build a minimal "ras" object by hand (see ras() for the full pipeline)
set.seed(7)
xg <- seq(1, 2000, by = 10)
yg <- c(seq(0, 9, length.out = length(xg) %/% 2),
        seq(9, 1, length.out = length(xg) - length(xg) %/% 2)) +
      rnorm(length(xg), sd = 0.4)
detection <- list(
  tau_hats         = xg[100],
  all.changepoints = xg[c(95, 100, 105)],
  all.p.values     = c(5, 12, 4),
  left.slopes      = 0.3,
  right.slopes     = -0.3
)
result <- structure(
  list(scan = list(x = xg, y = yg), detection = detection,
       chrom = 1, save_dir = tempdir()),
  class = "ras")

plot(result, device = "screen")
plot(result, zoom = TRUE, device = "screen")

RAS documentation built on July 24, 2026, 5:06 p.m.