| plot_tm | R Documentation |
Visualise how melting temperature (and optionally other numeric metadata)
differs between region classes such as peak vs. non-peak, mutant vs.
wild-type, or any categorical annotation stored in a GRanges object.
Designed as the visual companion to compare_groups().
plot_tm(
gr,
group,
value = "Tm",
plot_type = c("box", "violin", "rank", "density", "ridgeline", "ecdf", "sina"),
color_palette = c("viridis", "magma", "plasma", "inferno", "cividis"),
show_points = FALSE,
point_size = 1,
point_alpha = 0.3,
notch = FALSE,
add_mean = FALSE,
facet_by = NULL,
show_pvalue = FALSE,
p_adjust_method = "BH",
title = NULL,
ylab = "Tm (°C)",
xlab = NULL,
show_legend = TRUE
)
gr |
A |
group |
Character. Name of the metadata column that defines the groups
to compare (e.g. |
value |
Character. Numeric metadata column to plot on the y-axis.
Default: |
plot_type |
Character. Visualisation style:
|
color_palette |
Character. Viridis palette for group colours:
|
show_points |
Logical. Overlay jittered points on box / violin plots.
Default: |
point_size |
Numeric. Point size. Default: |
point_alpha |
Numeric in |
notch |
Logical. Draw notched box plots (approximate 95% CI for
median). Default: |
add_mean |
Logical. Add a diamond marker at the group mean on box /
violin plots. Default: |
facet_by |
Character or |
show_pvalue |
Logical. Annotate the plot with Wilcoxon rank-sum test
p-values. For two groups a single p-value is shown; for three or more
groups all pairwise comparisons are displayed. P-values are placed as
bracket annotations on box / violin / sina plots, or as a subtitle on
density / ecdf / rank / ridgeline plots. Default: |
p_adjust_method |
Character. Method for p-value adjustment when there
are more than two groups (passed to |
title |
Character or |
ylab |
Character. Y-axis label. Default: |
xlab |
Character. X-axis label. Default: group column name for
box/violin/sina, |
show_legend |
Logical. Show colour legend. Default: |
The function pairs naturally with integrate_granges() and
compare_groups():
Use integrate_granges() to annotate Tm windows with feature
overlaps (e.g. ChIP-seq peaks, repeat classes).
Use compare_groups() for the statistical test.
Use plot_tm() to visualise the distributional difference.
A ggplot object.
## Not run:
library(GenomicRanges)
data(ecoli_rep_hotspots)
library("BSgenome.Ecoli.NCBI.ASM584v2")
genome_name <- "BSgenome.Ecoli.NCBI.ASM584v2"
chr_name <- "U00096.3"
genome <- get(genome_name, envir = asNamespace(genome_name))
chr_length <- length(genome[[chr_name]])
genome_name="BSgenome.Ecoli.NCBI.ASM584v2"
bins_gc <- make_genomiccoord(
bsgenome = genome_name,
chromosomes = chr_name,
window = 200L,
slide = 200L,
start = 1,
end = chr_length,
strand = "+"
)
input_new <- list(pkg_name = genome_name, seq = bins_gc)
gr_batch <- to_genomic_ranges_fast(input_new)
tm_ASM584v2 <- tm_calculate(
gr_batch,
method = "tm_nn"
)
gr_tm <- tm_ASM584v2$gr
# Annotate with MutL-AR peak membership
mutH_peaks <- GRanges(
seqnames = ecoli_rep_hotspots$all_peaks_IP_mutH$chr,
ranges = IRanges(start = ecoli_rep_hotspots$all_peaks_IP_mutH$start,
end = ecoli_rep_hotspots$all_peaks_IP_mutH$end)
)
mutH_peaks$peak_id <- paste0("mutH_", seq_along(mutH_peaks))
gr_annot <- integrate_granges(
gr_tm = gr_tm, gr_features = mutH_peaks,
strategy = "overlap", feature_cols = "peak_id",
keep_unmatched = TRUE
)
gr_annot$in_mutH <- ifelse(is.na(gr_annot$peak_id), "non_peak", "peak")
# Box plot — peak vs non-peak Tm
plot_tm(gr_annot, group = "in_mutH")
# Box plot with Wilcoxon p-value bracket
plot_tm(gr_annot, group = "in_mutH", show_pvalue = TRUE)
# Violin plot with p-value and jittered points
plot_tm(gr_annot, group = "in_mutH", plot_type = "violin",
show_points = TRUE, show_pvalue = TRUE)
# Rank plot — visual Wilcoxon test with p-value subtitle
plot_tm(gr_annot, group = "in_mutH", plot_type = "rank",
show_pvalue = TRUE)
# Density overlay with p-value
plot_tm(gr_annot, group = "in_mutH", plot_type = "density",
show_pvalue = TRUE)
# ECDF — cumulative distribution comparison
plot_tm(gr_annot, group = "in_mutH", plot_type = "ecdf",
show_pvalue = TRUE)
# Compare GC content instead of Tm
plot_tm(gr_annot, group = "in_mutH", value = "GC", ylab = "GC content",
show_pvalue = TRUE)
# Notched box plot with mean markers and p-value
plot_tm(gr_annot, group = "in_mutH", notch = TRUE, add_mean = TRUE,
show_pvalue = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.