Skip to contents

Creates a detailed DMR plot with an integrated heatmap showing beta values across samples for seeds and surrounding sites. The plot consists of two panels: the top panel shows the DMR structure with seeds and extended sites, and the bottom panel displays a heatmap of beta values for all samples, if beta values are provided. Additionally, if motif information is available or can be extracted, a sequence logo plot is added showing the nucleotide composition and information content around site sites in the DMR.

Usage

plotDMR(
  dmrs,
  dmr_index,
  beta = NULL,
  pheno = NULL,
  genome = NULL,
  array = NULL,
  beta_locs = NULL,
  sample_group_col = NULL,
  extend_by_dmr_size_ratio = 0.2,
  min_extension_bp = 50,
  max_sites = 100,
  max_samples_per_group = 10,
  plot_motif = TRUE,
  motif_site_flank_size = 5,
  plot_title = TRUE,
  output_file = NULL,
  width = 8,
  height = 12
)

Arguments

dmrs

GRanges object. Output from buildDMRs.

dmr_index

Integer. Which DMR to plot.

beta

BetaHandler object, character path to beta file, or beta values matrix. If a character path or matrix is provided, a BetaHandler will be created automatically.

pheno

Data frame or character path to phenotype file. Sample information with rownames matching beta column names (required).

genome

Character. Genome version. Required for data.frame DMRs; inferred from GRanges seqinfo when available.

array

Character. Array platform type. Required when beta row names are array probe IDs and beta_locs is not provided.

beta_locs

Data frame. Genomic locations sorted by position (optional).

sample_group_col

Character. Required column in pheno for sample grouping when pheno is provided.

extend_by_dmr_size_ratio

Numeric. Ratio of the DMR width to extend the plot region outside of the DMR in both sides (default: 0.2).

min_extension_bp

Integer. Minimum extension in base pairs (default: 50).

max_sites

Integer. Maximum number of sites to show in heatmap (default: 100).

max_samples_per_group

Integer. Maximum number of samples to show per group in heatmap (default: 10).

plot_motif

Logical. Whether to plot the sequence logo motif (default: TRUE).

motif_site_flank_size

Integer. Number of base pairs to include as flanking regions around each site site for motif extraction (default: 5).

plot_title

Logical. Whether to display the title on the plot. If FALSE, the title is shown in the logs (default: TRUE).

output_file

Character. If provided, saves the plot to the specified file path (PDF format).

width

Numeric. Width of the output PDF in inches when output_file is provided (default: 8).

height

Numeric. Height of the output PDF in inches when output_file is provided (default: 12).

Value

A combined plot object (gridExtra) containing the DMR structure plot, beta values heatmap (if beta is provided), and sequence logo motif plot (if motif information is available and plot_motif is TRUE).

Examples

dmrs <- readRDS(system.file(
    "extdata", "example_outputChr5And11.rds", package = "CMEnt"
))
if (requireNamespace(
    "IlluminaHumanMethylation450kanno.ilmn12.hg19", quietly = TRUE
)) {
    plotDMR(dmrs, 1, array = "450K", plot_motif = FALSE)
}