Skip to contents

Visualizes how DMR blocks are formed on a single chromosome by layering raw scores, smoothed scores, piecewise-linear segments, slope-based candidate blocks, distance-based split boundaries, and final accepted blocks.

Usage

plotDMRBlockFormation(
  dmrs,
  chromosome,
  genome = "hg38",
  k_neighbors = 5L,
  min_segment_size = 2L,
  block_gap_mode = "adaptive",
  block_gap_fixed_bp = NULL,
  block_gap_quantile = 0.95,
  block_gap_multiplier = 1.5,
  block_gap_min_bp = 250000,
  block_gap_max_bp = 5e+06,
  point_alpha = 0.7,
  point_size = 1
)

Arguments

dmrs

GRanges object or data frame. DMR results from buildDMRs or scoreDMRs.

chromosome

Character. Chromosome to inspect (e.g., "chr7" or "7").

genome

Character. Genome version passed to .convertToGRanges (default: "hg38").

k_neighbors

Integer. Number of nearest neighbors used in adaptive Gaussian smoothing (default: 5).

min_segment_size

Integer. Minimum size of linear segments in PELT segmentation (default: 2).

block_gap_mode

Character. Gap rule for block splitting: "adaptive" (default), "fixed", or "none".

block_gap_fixed_bp

Numeric. Maximum allowed midpoint gap (bp) when block_gap_mode = "fixed". Ignored otherwise.

block_gap_quantile

Numeric in (0, 1). Gap quantile used for adaptive thresholding (default: 0.95).

block_gap_multiplier

Numeric > 0. Multiplier for adaptive gap threshold (default: 1.5).

block_gap_min_bp

Numeric >= 0. Lower clamp for adaptive gap threshold (bp). Default is 250000.

block_gap_max_bp

Numeric >= block_gap_min_bp. Upper clamp for adaptive gap threshold (bp). Default is 5000000.

point_alpha

Numeric. Alpha for raw score points in [0, 1] (default: 0.7).

point_size

Numeric. Point size for raw scores (default: 1.0).

Value

A ggplot object.

Examples

dmrs <- data.frame(
    chr = "chr7",
    start = seq(1e6, by = 5e4, length.out = 10),
    end = seq(1e6, by = 5e4, length.out = 10) + 100,
    score = seq(0.5, 0.8, length.out = 10)
)
p <- plotDMRBlockFormation(dmrs, chromosome = "chr7")