if (FALSE) {
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)
}
Run the code above in your browser using DataLab