plot_ras_scan: Plot RAS Scan Profile with Detected Changepoints

View source: R/plot.R

plot_ras_scanR Documentation

Plot RAS Scan Profile with Detected Changepoints

Description

Produces two diagnostic plots for one chromosome: the RAS scan profile with detected changepoints marked, and a dual-axis overlay of the profile with Davies test significance at each candidate position.

Usage

plot_ras_scan(
  x,
  y,
  detection.result,
  this_chrom,
  save.directory,
  p.threshold = 8,
  device = "pdf",
  y_cap = NULL,
  min_display_p = 1,
  xlim = NULL,
  min_signal = 2.5
)

Arguments

x

Numeric vector. SNP position index grid from the scan (scan$x returned by ras_scan).

y

Numeric vector. Averaged -\log_{10}(p)-value profile (scan$y returned by ras_scan).

detection.result

List. Output from ras_validate, containing tau_hats, all.changepoints, all.p.values, left.slopes, and right.slopes.

this_chrom

Integer. Chromosome number used in output file names and panel titles.

save.directory

Character. Directory path for saved files. Ignored when device = "screen".

p.threshold

Numeric. Significance reference line drawn on both plots (on the -\log_{10} scale). Default 8.

device

Character. Output device: "pdf" (default), "png", or "screen" (renders to the active graphics device without writing files).

y_cap

Numeric or NULL. If provided, the y-axis is capped at this value; positions above the cap are annotated with upward arrows and their true values. Useful when boundary effects produce extreme outliers. Default NULL (no cap).

min_display_p

Numeric. Minimum all.p.values required for a candidate changepoint to appear in Plot 2. Lower-valued candidates are omitted to reduce overplotting. Default 1.

xlim

Numeric vector of length 2, or NULL. If provided, both plots show only the genomic range [xlim[1], xlim[2]]. Default NULL (full range).

min_signal

Numeric. Low-signal colour boundary on the -\log_{10} scale. Values below this are drawn in blue; values at or above it switch to yellow (and higher tiers). A grey reference line is drawn at this level. Default 2.5.

Details

Plot 1 — Scan profile. The scan line is drawn segment-by-segment with colour determined by the local -\log_{10}(p) value:

  • Red (#d73027): \ge p.threshold

  • Orange (#fc8d59): \ge p.threshold / 2

  • Yellow (#fee090): \ge min_signal

  • Blue (#91bfdb): below min_signal

Detected changepoints (tau_hats) are marked with vertical dashed red lines, shaded bands, and labelled with their position and Davies -\log_{10}(p). Left and right slope lines (dark green and purple) are overlaid at each changepoint; their half-width is fixed at 2.5\ the total x-range. When y_cap is set, positions above the cap are shown as arrows with their true value annotated.

Plot 2 — Dual-axis overlay. The scan profile (left y-axis, blue line) is overlaid with triangle markers showing the Davies -\log_{10}(p) for each candidate (right y-axis, coloured by whether it exceeds p.threshold). Vertical dashed segments connect markers to the baseline.

Output files are named: chr-<chrom>-cp-plot.<ext> and chr-<chrom>-cp-p-values-plot.<ext>.

Value

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

See Also

plot_ras_zoom_regions for zoomed panels around each changepoint. ras which calls this function automatically. ras_validate whose output is passed as detection.result.


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