Last updated: 2025-08-22

Checks: 7 0

Knit directory: DXR_continue/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20250701) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 82b76e3. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/Cormotif_data/
    Ignored:    data/DER_data/
    Ignored:    data/alignment_summary.txt
    Ignored:    data/all_peak_final_dataframe.txt
    Ignored:    data/cell_line_info_.tsv
    Ignored:    data/full_summary_QC_metrics.txt
    Ignored:    data/number_frag_peaks_summary.txt

Untracked files:
    Untracked:  analysis/Cormotif_analysis.Rmd
    Untracked:  analysis/Cormotif_outlier_removal.Rmd
    Untracked:  code/corMotifcustom.R
    Untracked:  code/making_analysis_file_summary.R

Unstaged changes:
    Modified:   analysis/Outlier_removal.Rmd
    Modified:   analysis/final_analysis.Rmd
    Modified:   analysis/index.Rmd
    Modified:   analysis/multiQC_cut_tag.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/DER_analysis.Rmd) and HTML (docs/DER_analysis.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 82b76e3 reneeisnowhere 2025-08-22 updates to color and lfc
html c3469d3 reneeisnowhere 2025-08-18 Build site.
Rmd 52b0f2c reneeisnowhere 2025-08-18 wflow_publish("analysis/DER_analysis.Rmd")
html 9f5827e reneeisnowhere 2025-08-13 Build site.
Rmd ad6bf1a reneeisnowhere 2025-08-13 adding in examples
html 3b2a52b reneeisnowhere 2025-08-13 Build site.
Rmd a6f8ac5 reneeisnowhere 2025-08-13 adding in examples
html aa92650 reneeisnowhere 2025-08-12 Build site.
Rmd fda033f reneeisnowhere 2025-08-12 fix index pages
html fda033f reneeisnowhere 2025-08-12 fix index pages

library(tidyverse)
library(readr)
library(edgeR)
library(ComplexHeatmap)
library(data.table)
library(dplyr)
library(stringr)
library(ggplot2)
library(viridis)
library(DT)
library(kableExtra)
library(genomation)
library(GenomicRanges)
library(ggpubr) ## For customizing figures
library(corrplot) ## For correlation plot
library(ggpmisc)
library(gcplyr)
library(Rsubread)
library(limma)
library(ggrastr)
library(cowplot)
library(smplot2)
library(ggVennDiagram)
library(ggsignif)

Differential analysis data frames:

H3K27ac_toplist <- readRDS( "data/DER_data/H3K27ac_toplist.RDS")
H3K27me3_toplist <- readRDS("data/DER_data/H3K27me3_toplist.RDS")
H3K36me3_toplist <- readRDS("data/DER_data/H3K36me3_toplist.RDS")
H3K9me3_toplist <- readRDS( "data/DER_data/H3K9me3_toplist.RDS")
sampleinfo <- read_delim("data/sample_info.tsv", delim = "\t")
cell_line_info <- data.frame(Individual = c("Ind1","Ind2","Ind3","Ind4","Ind5"),Cell_line = c ("78-1","75-1","17-3","90-1","84-1"), sex = c("F","F","M","M","M")) 
# write_delim(cell_line_info,"data/cell_line_info_.tsv",delim = "\t")
H3K27ac_toptable_list <- bind_rows(H3K27ac_toplist, .id = "group")
H3K27me3_toptable_list <- bind_rows(H3K27me3_toplist, .id = "group")
H3K36me3_toptable_list <- bind_rows(H3K36me3_toplist, .id = "group")
H3K9me3_toptable_list <- bind_rows(H3K9me3_toplist, .id = "group")

counts data frames:

H3K27ac_merged <- read_delim("data/peaks/H3K27ac_FINAL_counts.txt", 
    delim = "\t", escape_double = FALSE, 
    trim_ws = TRUE, skip = 1)
H3K27me3_merged <- read_delim("data/peaks/H3K27me3_FINAL_counts.txt", 
    delim = "\t", escape_double = FALSE, 
    trim_ws = TRUE, skip = 1)
H3K36me3_merged <- read_delim("data/peaks/H3K36me3_FINAL_counts.txt", 
    delim = "\t", escape_double = FALSE, 
    trim_ws = TRUE, skip = 1)
H3K9me3_merged <- read_delim("data/peaks/H3K9me3_FINAL_counts.txt", 
    delim = "\t", escape_double = FALSE, 
    trim_ws = TRUE, skip = 1)
rename_list <- sampleinfo %>% 
  mutate(stem= "_nobl.bam") %>% 
  mutate(prefix=paste0("/scratch/10819/styu/MW_multiQC/peaks/",Histone_Mark,"/",Treatment,"/",Timepoint,"/")) %>%
  mutate(oldname=paste0(prefix,`Library ID`,"/",`Library ID`,stem)) %>% 
  mutate(newname=paste0(Individual,"_",Treatment,"_",Timepoint)) %>% 
  dplyr::select(oldname,newname)
rename_vec <- setNames(rename_list$newname, rename_list$oldname)
names(H3K27ac_merged)[names(H3K27ac_merged) %in% names(rename_vec)] <- rename_vec[names(H3K27ac_merged)[names(H3K27ac_merged) %in% names(rename_vec)]]
names(H3K27me3_merged)[names(H3K27me3_merged) %in% names(rename_vec)] <- rename_vec[names(H3K27me3_merged)[names(H3K27me3_merged) %in% names(rename_vec)]]
names(H3K36me3_merged)[names(H3K36me3_merged) %in% names(rename_vec)] <- rename_vec[names(H3K36me3_merged)[names(H3K36me3_merged) %in% names(rename_vec)]]
names(H3K9me3_merged)[names(H3K9me3_merged) %in% names(rename_vec)] <- rename_vec[names(H3K9me3_merged)[names(H3K9me3_merged) %in% names(rename_vec)]]

Removing chrX and chrY

H3K27ac_merged_raw <- H3K27ac_merged %>% 
  dplyr::select(Geneid,contains("Ind")) %>% 
  column_to_rownames("Geneid") %>% 
  as.matrix()
H3K27ac_merged_lcpm <- H3K27ac_merged %>% 
  dplyr::select(Geneid,contains("Ind")) %>% 
  column_to_rownames("Geneid") %>% 
  cpm(., log = TRUE)
H3K27ac_merged_cor <- H3K27ac_merged_lcpm %>% 
  cor()


H3K27me3_merged_raw <- H3K27me3_merged %>% 
  dplyr::select(Geneid,contains("Ind")) %>% 
  column_to_rownames("Geneid") %>% 
  as.matrix()
H3K27me3_merged_lcpm <- H3K27me3_merged %>% 
  dplyr::select(Geneid,contains("Ind")) %>% 
  column_to_rownames("Geneid") %>% 
  cpm(., log = TRUE)
H3K27me3_merged_cor <- H3K27me3_merged_lcpm %>% 
  cor()

H3K36me3_merged_raw <- H3K36me3_merged %>% 
  dplyr::select(Geneid,contains("Ind")) %>% 
  column_to_rownames("Geneid") %>% 
  as.matrix()
H3K36me3_merged_lcpm <- H3K36me3_merged %>% 
  dplyr::select(Geneid,contains("Ind")) %>% 
  column_to_rownames("Geneid") %>% 
  cpm(., log = TRUE)
H3K36me3_merged_cor <- H3K36me3_merged_lcpm %>% 
  cor()

H3K9me3_merged_raw <- H3K9me3_merged %>% 
  dplyr::select(Geneid,contains("Ind")) %>% 
  column_to_rownames("Geneid") %>% 
  as.matrix()
H3K9me3_merged_lcpm <- H3K9me3_merged %>% 
  dplyr::select(Geneid,contains("Ind")) %>% 
  column_to_rownames("Geneid") %>% 
  cpm(., log = TRUE)
H3K9me3_merged_cor <- H3K9me3_merged_lcpm %>% 
  cor()
H3K27ac_merged_raw <- H3K27ac_merged_raw[rowMeans(H3K27ac_merged_lcpm)>0,]
H3K27ac_merged_raw <- H3K27ac_merged_raw[!grepl("chrY",rownames(H3K27ac_merged_raw)),]
H3K27ac_merged_raw <- H3K27ac_merged_raw[!grepl("chrX",rownames(H3K27ac_merged_raw)),]
H3K27ac_merged_filt_lcpm <- H3K27ac_merged_raw %>% cpm(., log = TRUE)

H3K27me3_merged_raw <- H3K27me3_merged_raw[rowMeans(H3K27me3_merged_lcpm)>0,]
H3K27me3_merged_raw <- H3K27me3_merged_raw[!grepl("chrY",rownames(H3K27me3_merged_raw)),]
H3K27me3_merged_raw <- H3K27me3_merged_raw[!grepl("chrX",rownames(H3K27me3_merged_raw)),]
H3K27me3_merged_filt_lcpm <- H3K27me3_merged_raw %>% cpm(., log = TRUE)


H3K36me3_merged_raw <- H3K36me3_merged_raw[rowMeans(H3K36me3_merged_lcpm)>0,]
H3K36me3_merged_raw <- H3K36me3_merged_raw[!grepl("chrY",rownames(H3K36me3_merged_raw)),]
H3K36me3_merged_raw <- H3K36me3_merged_raw[!grepl("chrX",rownames(H3K36me3_merged_raw)),]
H3K36me3_merged_filt_lcpm <- H3K36me3_merged_raw %>% cpm(., log = TRUE)

H3K9me3_merged_raw <- H3K9me3_merged_raw[rowMeans(H3K9me3_merged_lcpm)>0,]
H3K9me3_merged_raw <- H3K9me3_merged_raw[!grepl("chrY",rownames(H3K9me3_merged_raw)),]
H3K9me3_merged_raw <- H3K9me3_merged_raw[!grepl("chrX",rownames(H3K9me3_merged_raw)),]
H3K9me3_merged_filt_lcpm <- H3K9me3_merged_raw %>% cpm(., log = TRUE)

H3K27ac LFC correlation

H3K27ac_cor_mat <- H3K27ac_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>% 
  pivot_wider(id_cols = genes, values_from = logFC, names_from = group) %>% 
  column_to_rownames("genes") %>% 
  as.matrix() %>% 
  cor()

ComplexHeatmap::Heatmap(H3K27ac_cor_mat,
                        column_title = "H3K27ac correlation of LFC",
                        cell_fun = function(j, i, x, y, width, height, fill) {
          grid.text(sprintf("%.2f", H3K27ac_cor_mat[i, j]), x, y, gp = gpar(fontsize = 8, col = "black"))
        })

Version Author Date
9f5827e reneeisnowhere 2025-08-13
3b2a52b reneeisnowhere 2025-08-13

LFC and abs LFC by trt time

H3K27ac_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>%
  mutate(group=factor(group, levels = c("H3K27ac_24T","H3K27ac_24R","H3K27ac_144R"))) %>% 
  ggplot(., aes(x=group, y=logFC))+
  geom_boxplot(aes(fill=group))+
  geom_signif(comparisons = list(c("H3K27ac_24T", "H3K27ac_144R"),
                                 c("H3K27ac_24T","H3K27ac_24R"),
                                 c("H3K27ac_24R", "H3K27ac_144R")),
                              step_increase = 0.1, 
              map_signif_level = FALSE, 
              test = "wilcox.test")+
  theme_bw()+
  ggtitle("LFC across time for H3K27ac")

Version Author Date
c3469d3 reneeisnowhere 2025-08-18
9f5827e reneeisnowhere 2025-08-13
H3K27ac_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>%
  mutate(group=factor(group, levels = c("H3K27ac_24T","H3K27ac_24R","H3K27ac_144R")),
         logFC=abs(logFC)) %>% 
  ggplot(., aes(x=group, y=logFC))+
  geom_boxplot(aes(fill=group))+
  geom_signif(comparisons = list(c("H3K27ac_24T", "H3K27ac_144R"),
                                 c("H3K27ac_24T","H3K27ac_24R"),
                                 c("H3K27ac_24R", "H3K27ac_144R")),
                              step_increase = 0.1, 
              map_signif_level = FALSE, 
              test = "wilcox.test")+
  theme_bw()+
  ggtitle("Absolute LFC across time for H3K27ac")

Version Author Date
c3469d3 reneeisnowhere 2025-08-18

Example log2cpm top

### getting the Top3 DERs by 24T, 24R, or 144R (Time point)
Top_H3K27ac <- H3K27ac_toptable_list %>% 
  dplyr::filter(adj.P.Val<0.05) %>% 
  dplyr::select(genes, group, adj.P.Val) %>% 
  separate_wider_delim(., cols=group, delim="_",names=c("histone","cond"),cols_remove=FALSE) %>% 
  group_by(cond) %>% 
  slice_head(n=3)
### filtering the lcpm matrix by Top3 DERs for TP
H3K27ac_merged_filt_lcpm %>% 
  as.data.frame() %>% 
  dplyr::filter(row.names(H3K27ac_merged_filt_lcpm) %in% Top_H3K27ac$genes) %>% 
  ###pivot and add additional information from Top3 dataframe
  rownames_to_column("Peakid") %>% 
  pivot_longer(., cols = !Peakid, names_to = "sample", values_to = "lcpm" ) %>% 
  separate_wider_delim(., cols=sample, delim="_", names=c("ind","tx","time")) %>% 
  left_join(., Top_H3K27ac, by = c("Peakid"="genes")) %>% 
  mutate(ind=factor(ind, levels=c("Ind1", "Ind2", "Ind3", "Ind4","Ind5")),
         tx=factor(tx,levels = c("DOX","VEH")),
         time=factor(time, levels=c("24T","24R","144R")),
         group_graph= paste0(tx, "_", time),
      group_graph = factor(group_graph, levels = c(
        "DOX_24T",  "VEH_24T",
        "DOX_24R",  "VEH_24R",
        "DOX_144R",  "VEH_144R"))) %>% 
  
  ggplot(., aes(x=group_graph, y=lcpm)) +
  geom_boxplot()+
  facet_wrap(group~Peakid, scales="free")+
  theme_bw()+
  theme(axis.text.x=element_text(angle = 90))

Version Author Date
3b2a52b reneeisnowhere 2025-08-13

Proportion of H3K27ac DERs by time

H3K27ac_toptable_list %>% 
  dplyr::select(group,genes,logFC,adj.P.Val) %>% 
  mutate(sig_val=if_else(adj.P.Val<0.05,"sig","not_sig")) %>% 
  mutate(
    sig_val = factor(sig_val, levels = c("not_sig", "sig")),
    group = factor(group, levels = c("H3K27ac_24T","H3K27ac_24R","H3K27ac_144R"))) %>%
  ggplot(aes(x = group, fill = sig_val)) +
  geom_bar(position = "fill") +
  theme_bw() +
  ggtitle("H3K27ac") +
  ylab("Proportion") +
  scale_y_continuous(labels = scales::percent)

Version Author Date
c3469d3 reneeisnowhere 2025-08-18

H3K27me3 LFC correlation

H3K27me3_cor_mat <- H3K27me3_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>% 
  pivot_wider(id_cols = genes, values_from = logFC, names_from = group) %>% 
  column_to_rownames("genes") %>% 
  as.matrix() %>% 
  cor()

ComplexHeatmap::Heatmap(H3K27me3_cor_mat, 
                        column_title = "H3K27me3 correlation of LFC",
                        cell_fun = function(j, i, x, y, width, height, fill) {
          grid.text(sprintf("%.2f", H3K27me3_cor_mat[i, j]), x, y, gp = gpar(fontsize = 8, col = "black"))
        })

Version Author Date
c3469d3 reneeisnowhere 2025-08-18
9f5827e reneeisnowhere 2025-08-13
3b2a52b reneeisnowhere 2025-08-13

LFC and abs LFC by trt time

H3K27me3_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>%
  mutate(group=factor(group, levels = c("H3K27me3_24T","H3K27me3_24R","H3K27me3_144R"))) %>% 
  ggplot(., aes(x=group, y=logFC))+
  geom_boxplot(aes(fill=group))+
  geom_signif(comparisons = list(c("H3K27me3_24T", "H3K27me3_144R"),
                                 c("H3K27me3_24T","H3K27me3_24R"),
                                 c("H3K27me3_24R", "H3K27me3_144R")),
                              step_increase = 0.1, 
              map_signif_level = FALSE, 
              test = "wilcox.test")+
  theme_bw()+
  ggtitle("LFC across time for H3K27me3")

Version Author Date
c3469d3 reneeisnowhere 2025-08-18
9f5827e reneeisnowhere 2025-08-13
H3K27me3_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>%
  mutate(group=factor(group, levels = c("H3K27me3_24T","H3K27me3_24R","H3K27me3_144R")),
         logFC=abs(logFC)) %>% 
  ggplot(., aes(x=group, y=logFC))+
  geom_boxplot(aes(fill=group))+
  geom_signif(comparisons = list(c("H3K27me3_24T", "H3K27me3_144R"),
                                 c("H3K27me3_24T","H3K27me3_24R"),
                                 c("H3K27me3_24R", "H3K27me3_144R")),
                              step_increase = 0.1, 
              map_signif_level = FALSE, 
              test = "wilcox.test")+
  theme_bw()+
  ggtitle("Absolute LFC across time for H3K27me3")

Version Author Date
c3469d3 reneeisnowhere 2025-08-18

Example log2cpm top

### getting the Top3 DERs by 24T, 24R, or 144R (Time point)
Top_H3K27me3 <- H3K27me3_toptable_list %>% 
  dplyr::filter(adj.P.Val<0.05) %>% 
  dplyr::select(genes, group, adj.P.Val) %>% 
  separate_wider_delim(., cols=group, delim="_",names=c("histone","cond"),cols_remove=FALSE) %>% 
  group_by(cond) %>% 
  slice_head(n=3)
### filtering the lcpm matrix by Top3 DERs for TP
H3K27me3_merged_filt_lcpm %>% 
  as.data.frame() %>% 
  dplyr::filter(row.names(H3K27me3_merged_filt_lcpm) %in% Top_H3K27me3$genes) %>% 
  ###pivot and add additional information from Top3 dataframe
  rownames_to_column("Peakid") %>% 
  pivot_longer(., cols = !Peakid, names_to = "sample", values_to = "lcpm" ) %>% 
  separate_wider_delim(., cols=sample, delim="_", names=c("ind","tx","time")) %>% 
  left_join(., Top_H3K27me3, by = c("Peakid"="genes")) %>% 
  mutate(ind=factor(ind, levels=c("Ind1", "Ind2", "Ind3", "Ind4","Ind5")),
         tx=factor(tx,levels = c("DOX","VEH")),
         time=factor(time, levels=c("24T","24R","144R")),
         group_graph= paste0(tx, "_", time),
      group_graph = factor(group_graph, levels = c(
        "DOX_24T",  "VEH_24T",
        "DOX_24R",  "VEH_24R",
        "DOX_144R",  "VEH_144R"))) %>% 
  
  ggplot(., aes(x=group_graph, y=lcpm)) +
   geom_boxplot(aes(fill=tx))+
  facet_wrap(group~Peakid, scales="free")+
  theme_bw()+
  theme(axis.text.x=element_text(angle = 90))

Version Author Date
3b2a52b reneeisnowhere 2025-08-13

Proportion of H3K27me3 DERs by time

H3K27me3_toptable_list %>% 
  dplyr::select(group,genes,logFC,adj.P.Val) %>% 
  mutate(sig_val=if_else(adj.P.Val<0.05,"sig","not_sig")) %>% 
  mutate(
    sig_val = factor(sig_val, levels = c("not_sig", "sig")),
    group = factor(group, levels = c("H3K27me3_24T","H3K27me3_24R","H3K27me3_144R"))) %>%
  ggplot(aes(x = group, fill = sig_val)) +
  geom_bar(position = "fill") +
  theme_bw() +
  ggtitle("H3K27me3") +
  ylab("Proportion") +
  scale_y_continuous(labels = scales::percent)

Version Author Date
c3469d3 reneeisnowhere 2025-08-18

H3K36me3 LFC correlation

H3K36me3_cor_mat <- H3K36me3_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>% 
  pivot_wider(id_cols = genes, values_from = logFC, names_from = group) %>% 
  column_to_rownames("genes") %>% 
  as.matrix() %>% 
  cor()

ComplexHeatmap::Heatmap(H3K36me3_cor_mat, 
                        column_title = "H3K36me3 correlation of LFC",
                        cell_fun = function(j, i, x, y, width, height, fill) {
          grid.text(sprintf("%.2f", H3K36me3_cor_mat[i, j]), x, y, gp = gpar(fontsize = 8, col = "black"))
        })

Version Author Date
c3469d3 reneeisnowhere 2025-08-18
9f5827e reneeisnowhere 2025-08-13
3b2a52b reneeisnowhere 2025-08-13

LFC and abs LFC by trt time

H3K36me3_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>%
  mutate(group=factor(group, levels = c("H3K36me3_24T","H3K36me3_24R","H3K36me3_144R"))) %>% 
  ggplot(., aes(x=group, y=logFC))+
  geom_boxplot(aes(fill=group))+
  geom_signif(comparisons = list(c("H3K36me3_24T", "H3K36me3_144R"),
                                 c("H3K36me3_24T","H3K36me3_24R"),
                                 c("H3K36me3_24R", "H3K36me3_144R")),
                              step_increase = 0.1, 
              map_signif_level = FALSE, 
              test = "wilcox.test")+
  theme_bw()+
  ggtitle("LFC across time for H3K36me3")

Version Author Date
c3469d3 reneeisnowhere 2025-08-18
9f5827e reneeisnowhere 2025-08-13
H3K36me3_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>%
  mutate(group=factor(group, levels = c("H3K36me3_24T","H3K36me3_24R","H3K36me3_144R")),
         logFC=abs(logFC)) %>% 
  ggplot(., aes(x=group, y=logFC))+
  geom_boxplot(aes(fill=group))+
  geom_signif(comparisons = list(c("H3K36me3_24T", "H3K36me3_144R"),
                                 c("H3K36me3_24T","H3K36me3_24R"),
                                 c("H3K36me3_24R", "H3K36me3_144R")),
                              step_increase = 0.1, 
              map_signif_level = FALSE, 
              test = "wilcox.test")+
  theme_bw()+
  ggtitle("Absolute LFC across time for H3K36me3")

Version Author Date
c3469d3 reneeisnowhere 2025-08-18

Example log2cpm top

### getting the Top3 DERs by 24T, 24R, or 144R (Time point)
Top_H3K36me3 <- H3K36me3_toptable_list %>% 
  dplyr::filter(adj.P.Val<0.05) %>% 
  dplyr::select(genes, group, adj.P.Val) %>% 
  separate_wider_delim(., cols=group, delim="_",names=c("histone","cond"),cols_remove=FALSE) %>% 
  group_by(cond) %>% 
  slice_head(n=3)
### filtering the lcpm matrix by Top3 DERs for TP
H3K36me3_merged_filt_lcpm %>% 
  as.data.frame() %>% 
  dplyr::filter(row.names(H3K36me3_merged_filt_lcpm) %in% Top_H3K36me3$genes) %>% 
  ###pivot and add additional information from Top3 dataframe
  rownames_to_column("Peakid") %>% 
  pivot_longer(., cols = !Peakid, names_to = "sample", values_to = "lcpm" ) %>% 
  separate_wider_delim(., cols=sample, delim="_", names=c("ind","tx","time")) %>% 
  left_join(., Top_H3K36me3, by = c("Peakid"="genes")) %>% 
  mutate(ind=factor(ind, levels=c("Ind1", "Ind2", "Ind3", "Ind4","Ind5")),
         tx=factor(tx,levels = c("DOX","VEH")),
         time=factor(time, levels=c("24T","24R","144R")),
         group_graph= paste0(tx, "_", time),
      group_graph = factor(group_graph, levels = c(
        "DOX_24T",  "VEH_24T",
        "DOX_24R",  "VEH_24R",
        "DOX_144R",  "VEH_144R"))) %>% 
  
  ggplot(., aes(x=group_graph, y=lcpm)) +
   geom_boxplot(aes(fill=tx))+
  facet_wrap(group~Peakid, scales="free")+
  theme_bw()+
  theme(axis.text.x=element_text(angle = 90))

Version Author Date
3b2a52b reneeisnowhere 2025-08-13

Proportion of H3K36me3 DERs by time

H3K36me3_toptable_list %>% 
  dplyr::select(group,genes,logFC,adj.P.Val) %>% 
  mutate(sig_val=if_else(adj.P.Val<0.05,"sig","not_sig")) %>% 
  mutate(
    sig_val = factor(sig_val, levels = c("not_sig", "sig")),
    group = factor(group, levels = c("H3K36me3_24T","H3K36me3_24R","H3K36me3_144R"))) %>%
  ggplot(aes(x = group, fill = sig_val)) +
  geom_bar(position = "fill") +
  theme_bw() +
  ggtitle("H3K36me3") +
  ylab("Proportion") +
  scale_y_continuous(labels = scales::percent)

Version Author Date
c3469d3 reneeisnowhere 2025-08-18

H3K9me3 LFC correlation

H3K9me3_cor_mat <- H3K9me3_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>% 
  pivot_wider(id_cols = genes, values_from = logFC, names_from = group) %>% 
  column_to_rownames("genes") %>% 
  as.matrix() %>% 
  cor()

ComplexHeatmap::Heatmap(H3K9me3_cor_mat, 
                        column_title = "H3K9me3 correlation of LFC",
                        cell_fun = function(j, i, x, y, width, height, fill) {
          grid.text(sprintf("%.2f", H3K9me3_cor_mat[i, j]), x, y, gp = gpar(fontsize = 8, col = "black"))
        })

Version Author Date
c3469d3 reneeisnowhere 2025-08-18
9f5827e reneeisnowhere 2025-08-13
3b2a52b reneeisnowhere 2025-08-13

LFC and abs LFC by trt time

H3K9me3_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>%
  mutate(group=factor(group, levels = c("H3K9me3_24T","H3K9me3_24R","H3K9me3_144R"))) %>% 
  ggplot(., aes(x=group, y=logFC))+
  geom_boxplot(aes(fill=group))+
  geom_signif(comparisons = list(c("H3K9me3_24T", "H3K9me3_144R"),
                                 c("H3K9me3_24T","H3K9me3_24R"),
                                 c("H3K9me3_24R", "H3K9me3_144R")),
                              step_increase = 0.1, 
              map_signif_level = FALSE, 
              test = "wilcox.test")+
  theme_bw()+
  ggtitle("LFC across time for H3K9me3")

Version Author Date
c3469d3 reneeisnowhere 2025-08-18
9f5827e reneeisnowhere 2025-08-13
H3K9me3_toptable_list %>% 
  dplyr::select(group,genes,logFC) %>%
  mutate(group=factor(group, levels = c("H3K9me3_24T","H3K9me3_24R","H3K9me3_144R")),
         logFC=abs(logFC)) %>% 
  ggplot(., aes(x=group, y=logFC))+
  geom_boxplot(aes(fill=group))+
  geom_signif(comparisons = list(c("H3K9me3_24T", "H3K9me3_144R"),
                                 c("H3K9me3_24T","H3K9me3_24R"),
                                 c("H3K9me3_24R", "H3K9me3_144R")),
                              step_increase = 0.1, 
              map_signif_level = FALSE, 
              test = "wilcox.test")+
  theme_bw()+
  ggtitle("Absolute LFC across time for H3K9me3")

Version Author Date
c3469d3 reneeisnowhere 2025-08-18

Example log2cpm top

### getting the Top3 DERs by 24T, 24R, or 144R (Time point)
Top_H3K9me3 <- H3K9me3_toptable_list %>% 
  dplyr::filter(adj.P.Val<0.05) %>% 
  dplyr::select(genes, group, adj.P.Val) %>% 
  separate_wider_delim(., cols=group, delim="_",names=c("histone","cond"),cols_remove=FALSE) %>% 
  group_by(cond) %>% 
  slice_head(n=3)
### filtering the lcpm matrix by Top3 DERs for TP
H3K9me3_merged_filt_lcpm %>% 
  as.data.frame() %>% 
  dplyr::filter(row.names(H3K9me3_merged_filt_lcpm) %in% Top_H3K9me3$genes) %>% 
  ###pivot and add additional information from Top3 dataframe
  rownames_to_column("Peakid") %>% 
  pivot_longer(., cols = !Peakid, names_to = "sample", values_to = "lcpm" ) %>% 
  separate_wider_delim(., cols=sample, delim="_", names=c("ind","tx","time")) %>% 
  left_join(., Top_H3K9me3, by = c("Peakid"="genes")) %>% 
  mutate(ind=factor(ind, levels=c("Ind1", "Ind2", "Ind3", "Ind4","Ind5")),
         tx=factor(tx,levels = c("DOX","VEH")),
         time=factor(time, levels=c("24T","24R","144R")),
         group_graph= paste0(tx, "_", time),
      group_graph = factor(group_graph, levels = c(
        "DOX_24T",  "VEH_24T",
        "DOX_24R",  "VEH_24R",
        "DOX_144R",  "VEH_144R"))) %>% 
  
  ggplot(., aes(x=group_graph, y=lcpm)) +
  geom_boxplot(aes(fill=tx))+
  facet_wrap(group~Peakid, scales="free")+
  theme_bw()+
  theme(axis.text.x=element_text(angle = 90))

Version Author Date
3b2a52b reneeisnowhere 2025-08-13

Proportion of H3K9me3 DERs by time

H3K9me3_toptable_list %>% 
  dplyr::select(group,genes,logFC,adj.P.Val) %>% 
  mutate(sig_val=if_else(adj.P.Val<0.05,"sig","not_sig")) %>% 
  mutate(
    sig_val = factor(sig_val, levels = c("not_sig", "sig")),
    group = factor(group, levels = c("H3K9me3_24T","H3K9me3_24R","H3K9me3_144R"))) %>%
  ggplot(aes(x = group, fill = sig_val)) +
  geom_bar(position = "fill") +
  theme_bw() +
  ggtitle("H3K9me3") +
  ylab("Proportion") +
  scale_y_continuous(labels = scales::percent)

Version Author Date
c3469d3 reneeisnowhere 2025-08-18

sessionInfo()
R version 4.4.2 (2024-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

attached base packages:
[1] stats4    grid      stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] ggsignif_0.6.4        ggVennDiagram_1.5.4   smplot2_0.2.5        
 [4] cowplot_1.2.0         ggrastr_1.0.2         Rsubread_2.20.0      
 [7] gcplyr_1.12.0         ggpmisc_0.6.2         ggpp_0.5.9           
[10] corrplot_0.95         ggpubr_0.6.1          GenomicRanges_1.58.0 
[13] GenomeInfoDb_1.42.3   IRanges_2.40.1        S4Vectors_0.44.0     
[16] BiocGenerics_0.52.0   genomation_1.38.0     kableExtra_1.4.0     
[19] DT_0.33               viridis_0.6.5         viridisLite_0.4.2    
[22] data.table_1.17.8     ComplexHeatmap_2.22.0 edgeR_4.4.2          
[25] limma_3.62.2          lubridate_1.9.4       forcats_1.0.0        
[28] stringr_1.5.1         dplyr_1.1.4           purrr_1.1.0          
[31] readr_2.1.5           tidyr_1.3.1           tibble_3.3.0         
[34] ggplot2_3.5.2         tidyverse_2.0.0       workflowr_1.7.1      

loaded via a namespace (and not attached):
  [1] splines_4.4.2               later_1.4.2                
  [3] BiocIO_1.16.0               bitops_1.0-9               
  [5] rpart_4.1.24                XML_3.99-0.18              
  [7] lifecycle_1.0.4             rstatix_0.7.2              
  [9] doParallel_1.0.17           rprojroot_2.1.0            
 [11] vroom_1.6.5                 processx_3.8.6             
 [13] lattice_0.22-7              MASS_7.3-65                
 [15] backports_1.5.0             magrittr_2.0.3             
 [17] Hmisc_5.2-3                 sass_0.4.10                
 [19] rmarkdown_2.29              jquerylib_0.1.4            
 [21] yaml_2.3.10                 plotrix_3.8-4              
 [23] httpuv_1.6.16               RColorBrewer_1.1-3         
 [25] abind_1.4-8                 zlibbioc_1.52.0            
 [27] RCurl_1.98-1.17             nnet_7.3-20                
 [29] git2r_0.36.2                circlize_0.4.16            
 [31] GenomeInfoDbData_1.2.13     MatrixModels_0.5-4         
 [33] svglite_2.2.1               codetools_0.2-20           
 [35] DelayedArray_0.32.0         xml2_1.4.0                 
 [37] tidyselect_1.2.1            shape_1.4.6.1              
 [39] UCSC.utils_1.2.0            farver_2.1.2               
 [41] matrixStats_1.5.0           base64enc_0.1-3            
 [43] GenomicAlignments_1.42.0    jsonlite_2.0.0             
 [45] GetoptLong_1.0.5            Formula_1.2-5              
 [47] survival_3.8-3              iterators_1.0.14           
 [49] systemfonts_1.2.3           foreach_1.5.2              
 [51] tools_4.4.2                 Rcpp_1.1.0                 
 [53] glue_1.8.0                  gridExtra_2.3              
 [55] SparseArray_1.6.2           xfun_0.52                  
 [57] MatrixGenerics_1.18.1       withr_3.0.2                
 [59] fastmap_1.2.0               SparseM_1.84-2             
 [61] callr_3.7.6                 digest_0.6.37              
 [63] timechange_0.3.0            R6_2.6.1                   
 [65] seqPattern_1.38.0           textshaping_1.0.1          
 [67] colorspace_2.1-1            Cairo_1.6-5                
 [69] dichromat_2.0-0.1           generics_0.1.4             
 [71] rtracklayer_1.66.0          httr_1.4.7                 
 [73] htmlwidgets_1.6.4           S4Arrays_1.6.0             
 [75] whisker_0.4.1               pkgconfig_2.0.3            
 [77] gtable_0.3.6                impute_1.80.0              
 [79] XVector_0.46.0              htmltools_0.5.8.1          
 [81] carData_3.0-5               pwr_1.3-0                  
 [83] clue_0.3-66                 scales_1.4.0               
 [85] Biobase_2.66.0              png_0.1-8                  
 [87] knitr_1.50                  rstudioapi_0.17.1          
 [89] tzdb_0.5.0                  reshape2_1.4.4             
 [91] rjson_0.2.23                checkmate_2.3.3            
 [93] curl_7.0.0                  zoo_1.8-14                 
 [95] cachem_1.1.0                GlobalOptions_0.1.2        
 [97] KernSmooth_2.23-26          parallel_4.4.2             
 [99] vipor_0.4.7                 foreign_0.8-90             
[101] restfulr_0.0.16             pillar_1.11.0              
[103] vctrs_0.6.5                 promises_1.3.3             
[105] car_3.1-3                   cluster_2.1.8.1            
[107] htmlTable_2.4.3             beeswarm_0.4.0             
[109] evaluate_1.0.4              magick_2.8.7               
[111] cli_3.6.5                   locfit_1.5-9.12            
[113] compiler_4.4.2              Rsamtools_2.22.0           
[115] rlang_1.1.6                 crayon_1.5.3               
[117] labeling_0.4.3              ps_1.9.1                   
[119] getPass_0.2-4               plyr_1.8.9                 
[121] fs_1.6.6                    ggbeeswarm_0.7.2           
[123] stringi_1.8.7               gridBase_0.4-7             
[125] BiocParallel_1.40.2         Biostrings_2.74.1          
[127] quantreg_6.1                Matrix_1.7-3               
[129] BSgenome_1.74.0             patchwork_1.3.1            
[131] hms_1.1.3                   bit64_4.6.0-1              
[133] statmod_1.5.0               SummarizedExperiment_1.36.0
[135] broom_1.0.9                 bslib_0.9.0                
[137] bit_4.6.0                   polynom_1.4-1