Last updated: 2026-01-30
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 6ec912d. 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/Bed_exports/
Ignored: data/Cormotif_data/
Ignored: data/DER_data/
Ignored: data/Other_paper_data/
Ignored: data/RDS_files/
Ignored: data/TE_annotation/
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/motif_lists/
Ignored: data/number_frag_peaks_summary.txt
Untracked files:
Untracked: H3K27ac_all_regions_test.bed
Untracked: H3K27ac_consensus_clusters_test.bed
Untracked: analysis/ATAC_integration_data1.Rmd
Untracked: analysis/GREAT_H3K27ac.Rmd
Untracked: analysis/H3K27ac_ChromHMM_FC.Rmd
Untracked: analysis/H3K27ac_TE_investigation.Rmd
Untracked: analysis/H3K27ac_cisRE.Rmd
Untracked: analysis/H3K27me3_TE_investigation.Rmd
Untracked: analysis/H3K36me3_TE_investigation.Rmd
Untracked: analysis/H3K9me3_TE_investigation.Rmd
Untracked: analysis/Top2a_Top2b_expression.Rmd
Untracked: analysis/maps_and_plots.Rmd
Untracked: analysis/proteomics.Rmd
Untracked: other_analysis/
Unstaged changes:
Modified: analysis/H3K27ac_RNA_integration.Rmd
Modified: analysis/H3K27ac_TF_motifs.Rmd
Modified: analysis/chromHMM.Rmd
Modified: analysis/final_analysis.Rmd
Modified: analysis/index.Rmd
Modified: analysis/summit_files_processing.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/dual_histone_TE_investigation.Rmd) and HTML
(docs/dual_histone_TE_investigation.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 | 6ec912d | reneeisnowhere | 2026-01-30 | first commits |
library(tidyverse)
library(GenomicRanges)
library(plyranges)
library(genomation)
library(readr)
library(rtracklayer)
library(stringr)
library(ggrepel)
library(DT)
library(ChIPseeker)
library(ggVennDiagram)
library(smplot2)
First steps: Pulling and overlapping each ROI set with specific families of TEs
repeatmasker <- read_delim("data/Other_paper_data/repeatmasker_20250911.txt",
delim = "\t", escape_double = FALSE,
trim_ws = TRUE)
autosomes <- paste0("chr", 1:22)
repeatmasker_clean <- repeatmasker %>% mutate(
strand = ifelse(strand == "C", "-", "+")
) %>%
mutate(
start = genoStart + 1,
end = genoEnd)%>%
mutate(repFamily= str_remove(repFamily, "\\?$")) %>%
dplyr::filter(genoName %in% autosomes) %>%
mutate(RM_id=paste0(genoName,":",start,"-",end,":",id))
rpt_split <- split(repeatmasker_clean, repeatmasker_clean$repClass)
rpt_split_gr_list <- lapply(rpt_split, function(df) {
GRanges(
seqnames = df$genoName,
ranges = IRanges(start = df$start, end = df$end),
strand = df$strand,
repName = df$repName,
repClass = df$repClass,
repFamily = df$repFamily,
swScore = df$swScore,
milliDiv = df$milliDiv,
milliDel = df$milliDel,
milliIns = df$milliIns,
RM_id = df$RM_id
)
})
SINE_gr <- rpt_split_gr_list$SINE
LINE_gr <- rpt_split_gr_list$LINE
LTR_gr <- rpt_split_gr_list$LTR
SVA_gr <- rpt_split_gr_list$Retroposon
DNA_gr <- rpt_split_gr_list$DNA
Pulling in ROI granges for H3K27ac and H3K9me3
peakAnnoList_H3K9me3 <- readRDS("data/motif_lists/H3K9me3_annotated_peaks.RDS")
peakAnnoList_H3K27ac <- readRDS("data/motif_lists/H3K27ac_annotated_peaks.RDS")
H3K9me3_lookup <- imap_dfr(peakAnnoList_H3K9me3[1:3], ~
tibble(Peakid = .x@anno$Peakid, cluster = .y)
)
H3K27ac_lookup <- imap_dfr(peakAnnoList_H3K27ac[1:3], ~
tibble(Peakid = .x@anno$Peakid, cluster = .y)
)
H3K9me3_sets_gr <- lapply(peakAnnoList_H3K9me3, function(df) {
as_granges(df)
})
H3K27ac_sets_gr <- lapply(peakAnnoList_H3K27ac, function(df) {
as_granges(df)
})
H3K9me3_toplist <- readRDS( "data/DER_data/H3K9me3_toplist_nooutlier.RDS")
# H3K36me3_toplist <- readRDS( "data/DER_data/H3K36me3_toplist_nooutlier.RDS")
# H3K27me3_toplist <- readRDS( "data/DER_data/H3K27me3_toplist.RDS")
H3K27ac_toplist <- readRDS( "data/DER_data/H3K27ac_toplist.RDS")
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")
K9me3_lfctable <- H3K9me3_toptable_list %>%
dplyr::select(group,genes, logFC) %>%
pivot_wider(.,id_cols = genes, names_from = group, values_from = logFC)
K27ac_lfctable <- H3K27ac_toptable_list %>%
dplyr::select(group,genes, logFC) %>%
pivot_wider(.,id_cols = genes, names_from = group, values_from = logFC)
Overlapping SINE family with ROIs
sine_hits_H3K9me3 <- findOverlaps(H3K9me3_sets_gr$all_H3K9me3_regions, SINE_gr, ignore.strand = TRUE)
SINE_overlap_df_H3K9me3 <- tibble(
peak_row = queryHits(sine_hits_H3K9me3),
Peakid = H3K9me3_sets_gr$all_H3K9me3$Peakid[queryHits(sine_hits_H3K9me3)],
cluster = H3K9me3_sets_gr$all_H3K9me3$cluster[queryHits(sine_hits_H3K9me3)],
repClass = SINE_gr$repClass[subjectHits(sine_hits_H3K9me3)],
repName = SINE_gr$repName[subjectHits(sine_hits_H3K9me3)],
RM_id = SINE_gr$RM_id[subjectHits(sine_hits_H3K9me3)],
TE_type = ifelse(
SINE_gr$repFamily[subjectHits(sine_hits_H3K9me3)] == "SVA",
SINE_gr$repName[subjectHits(sine_hits_H3K9me3)],
SINE_gr$repFamily[subjectHits(sine_hits_H3K9me3)]
),
milliDiv = SINE_gr$milliDiv[subjectHits(sine_hits_H3K9me3)],
milliDel = SINE_gr$milliDel[subjectHits(sine_hits_H3K9me3)],
milliIns = SINE_gr$milliIns[subjectHits(sine_hits_H3K9me3)]
)
sine_hits_H3K27ac <- findOverlaps(H3K27ac_sets_gr$all_H3K27ac, SINE_gr, ignore.strand = TRUE)
SINE_overlap_df_H3K27ac <- tibble(
peak_row = queryHits(sine_hits_H3K27ac),
Peakid = H3K27ac_sets_gr$all_H3K27ac$Peakid[queryHits(sine_hits_H3K27ac)],
cluster = H3K27ac_sets_gr$all_H3K27ac$cluster[queryHits(sine_hits_H3K27ac)],
repClass = SINE_gr$repClass[subjectHits(sine_hits_H3K27ac)],
repName = SINE_gr$repName[subjectHits(sine_hits_H3K27ac)],
RM_id = SINE_gr$RM_id[subjectHits(sine_hits_H3K27ac)],
TE_type = ifelse(
SINE_gr$repFamily[subjectHits(sine_hits_H3K27ac)] == "SVA",
SINE_gr$repName[subjectHits(sine_hits_H3K27ac)],
SINE_gr$repFamily[subjectHits(sine_hits_H3K27ac)]
),
milliDiv = SINE_gr$milliDiv[subjectHits(sine_hits_H3K27ac)],
milliDel = SINE_gr$milliDel[subjectHits(sine_hits_H3K27ac)],
milliIns = SINE_gr$milliIns[subjectHits(sine_hits_H3K27ac)]
)
common_sine_RMs <- intersect(
SINE_overlap_df_H3K27ac$RM_id,
SINE_overlap_df_H3K9me3$RM_id
)
length(unique(common_sine_RMs))
[1] 7675
Visualizing the overlapping SINE families
H3K27ac_SINE_peakid <- SINE_overlap_df_H3K27ac %>%
dplyr::filter(RM_id %in% common_sine_RMs) %>%
left_join(., H3K27ac_lookup) %>%
distinct(Peakid)
H3K9me3_SINE_peakid <- SINE_overlap_df_H3K9me3 %>%
dplyr::filter(RM_id %in% common_sine_RMs) %>%
left_join(., H3K9me3_lookup) %>%
distinct(Peakid)
I struggled with figuring out whether a TE is unique to a peak. I do have some SINE elements mapping to multiple peaks, but not a whole lot.
SINE_overlap_df_H3K9me3 %>%
count(RM_id, name = "n_peaks") %>%
count(n_peaks)
# A tibble: 2 × 2
n_peaks n
<int> <int>
1 1 50658
2 2 361
SINE_overlap_df_H3K9me3 %>%
count(RM_id) %>%
summarise(
min = min(n),
median = median(n),
mean = mean(n),
max = max(n)
)
# A tibble: 1 × 4
min median mean max
<int> <int> <dbl> <int>
1 1 1 1.01 2
SINE_overlap_df_H3K27ac %>%
count(RM_id, name = "n_peaks") %>%
count(n_peaks)
# A tibble: 2 × 2
n_peaks n
<int> <int>
1 1 149643
2 2 1230
SINE_overlap_df_H3K27ac %>%
count(RM_id) %>%
summarise(
min = min(n),
median = median(n),
mean = mean(n),
max = max(n)
)
# A tibble: 1 × 4
min median mean max
<int> <int> <dbl> <int>
1 1 1 1.01 2
Because of this many to many situation, I chose to average the log fold changes of the SINE elements overlapping multiple peaks.
### linking shared RM_id to Peakid by histone ROI for LFC plotting
##
SINE_K27ac_rmid_lfc <- data_frame(RM_id=common_sine_RMs) %>%
left_join(.,(SINE_overlap_df_H3K27ac %>%
dplyr::filter(RM_id %in% common_sine_RMs) %>%
distinct(RM_id,Peakid, .keep_all = TRUE) %>%
mutate(K27ac_Peakid=Peakid) %>%
dplyr::select(RM_id, K27ac_Peakid))) %>%
left_join(K27ac_lfctable, by =c("K27ac_Peakid"="genes")) %>%
group_by(RM_id) %>%
summarize(K27ac_24T=mean(H3K27ac_24T, na.rm=TRUE),
K27ac_24R=mean(H3K27ac_24R,na.rm=TRUE),
K27ac_144R=mean(H3K27ac_144R, na.rm=TRUE),
n_K27_peaks = dplyr::n(),
.groups="drop")
SINE_K9me3_rmid_lfc <- data_frame(RM_id=common_sine_RMs) %>%
left_join(.,(SINE_overlap_df_H3K9me3 %>%
dplyr::filter(RM_id %in% common_sine_RMs) %>%
distinct(RM_id,Peakid, .keep_all = TRUE) %>%
mutate(K9me3_Peakid=Peakid) %>%
dplyr::select(RM_id, K9me3_Peakid))) %>%
left_join(K9me3_lfctable, by =c("K9me3_Peakid"="genes")) %>%
group_by(RM_id) %>%
summarize(K9me3_24T=mean(H3K9me3_24T, na.rm=TRUE),
K9me3_24R=mean(H3K9me3_24R,na.rm=TRUE),
K9me3_144R=mean(H3K9me3_144R, na.rm=TRUE),
n_K27_peaks = dplyr::n(),
.groups="drop")
SINE_RM_lfc_concordance <- tibble(RM_id = common_sine_RMs) %>%
left_join(SINE_K27ac_rmid_lfc, by = "RM_id") %>%
left_join(SINE_K9me3_rmid_lfc, by = "RM_id")
Now to try to visualize this concordance. I am specifically looking at TEs that up in one and down in another.
SINE_RM_lfc_concordance %>%
ggplot(., aes(x=K27ac_24T, y=K9me3_24T))+
geom_point(, alpha=0.2, size=1)+
geom_density_2d(color= "black")+
sm_statCorr(corr_method="spearman")+
geom_hline(yintercept = 0, linetype = "dashed", color="red") +
geom_vline(xintercept = 0, linetype = "dashed", color="red") +
labs(
x = "H3K27ac logFC (24T)",
y = "H3K9me3 logFC (24T)",
title = "Concordance of chromatin changes at shared SINEs for 24T"
) +
theme_classic()

SINE_RM_lfc_concordance %>%
ggplot(., aes(x=K27ac_24R, y=K9me3_24R))+
geom_point(, alpha=0.2, size=1)+
geom_density_2d(color= "black")+
sm_statCorr(corr_method="spearman")+
geom_hline(yintercept = 0, linetype = "dashed", color="red") +
geom_vline(xintercept = 0, linetype = "dashed", color="red") +
labs(
x = "H3K27ac logFC (24R)",
y = "H3K9me3 logFC (24R)",
title = "Concordance of chromatin changes at shared SINEs for 24R"
) +
theme_classic()

SINE_RM_lfc_concordance %>%
ggplot(., aes(x=K27ac_144R, y=K9me3_144R))+
geom_point(, alpha=0.2, size=1)+
geom_density_2d(color= "black")+
sm_statCorr(corr_method="spearman")+
geom_hline(yintercept = 0, linetype = "dashed", color="red") +
geom_vline(xintercept = 0, linetype = "dashed", color="red") +
labs(
x = "H3K27ac logFC (144R)",
y = "H3K9me3 logFC (144R)",
title = "Concordance of chromatin changes at shared SINEs for 144R"
) +
theme_classic()

Overlapping LTR family with ROIs
LTR_hits_H3K9me3 <- findOverlaps(H3K9me3_sets_gr$all_H3K9me3_regions, LTR_gr, ignore.strand = TRUE)
LTR_overlap_df_H3K9me3 <- tibble(
peak_row = queryHits(LTR_hits_H3K9me3),
Peakid = H3K9me3_sets_gr$all_H3K9me3$Peakid[queryHits(LTR_hits_H3K9me3)],
cluster = H3K9me3_sets_gr$all_H3K9me3$cluster[queryHits(LTR_hits_H3K9me3)],
repClass = LTR_gr$repClass[subjectHits(LTR_hits_H3K9me3)],
repName = LTR_gr$repName[subjectHits(LTR_hits_H3K9me3)],
RM_id = LTR_gr$RM_id[subjectHits(LTR_hits_H3K9me3)],
TE_type = ifelse(
LTR_gr$repFamily[subjectHits(LTR_hits_H3K9me3)] == "SVA",
LTR_gr$repName[subjectHits(LTR_hits_H3K9me3)],
LTR_gr$repFamily[subjectHits(LTR_hits_H3K9me3)]
),
milliDiv = LTR_gr$milliDiv[subjectHits(LTR_hits_H3K9me3)],
milliDel = LTR_gr$milliDel[subjectHits(LTR_hits_H3K9me3)],
milliIns = LTR_gr$milliIns[subjectHits(LTR_hits_H3K9me3)]
)
LTR_hits_H3K27ac <- findOverlaps(H3K27ac_sets_gr$all_H3K27ac, LTR_gr, ignore.strand = TRUE)
LTR_overlap_df_H3K27ac <- tibble(
peak_row = queryHits(LTR_hits_H3K27ac),
Peakid = H3K27ac_sets_gr$all_H3K27ac$Peakid[queryHits(LTR_hits_H3K27ac)],
cluster = H3K27ac_sets_gr$all_H3K27ac$cluster[queryHits(LTR_hits_H3K27ac)],
repClass = LTR_gr$repClass[subjectHits(LTR_hits_H3K27ac)],
repName = LTR_gr$repName[subjectHits(LTR_hits_H3K27ac)],
RM_id = LTR_gr$RM_id[subjectHits(LTR_hits_H3K27ac)],
TE_type = ifelse(
LTR_gr$repFamily[subjectHits(LTR_hits_H3K27ac)] == "SVA",
LTR_gr$repName[subjectHits(LTR_hits_H3K27ac)],
LTR_gr$repFamily[subjectHits(LTR_hits_H3K27ac)]
),
milliDiv = LTR_gr$milliDiv[subjectHits(LTR_hits_H3K27ac)],
milliDel = LTR_gr$milliDel[subjectHits(LTR_hits_H3K27ac)],
milliIns = LTR_gr$milliIns[subjectHits(LTR_hits_H3K27ac)]
)
common_LTR_RMs <- intersect(
LTR_overlap_df_H3K27ac$RM_id,
LTR_overlap_df_H3K9me3$RM_id
)
length(unique(common_LTR_RMs))
[1] 5947
Visualizing the overlapping LTR families
H3K27ac_LTR_peakid <- LTR_overlap_df_H3K27ac %>%
dplyr::filter(RM_id %in% common_LTR_RMs) %>%
left_join(., H3K27ac_lookup) %>%
distinct(Peakid)
H3K9me3_LTR_peakid <- LTR_overlap_df_H3K9me3 %>%
dplyr::filter(RM_id %in% common_LTR_RMs) %>%
left_join(., H3K9me3_lookup) %>%
distinct(Peakid)
# ggVennDiagram(list(H3K27ac=H3K27ac_LTR_peakid_split$Set_1$RM_id,H3K9me3= H3K9me3_LTR_peakid_split$Set_1$RM_id))+
# ggtitle("No Response overlaping TEs")
# ggVennDiagram(list(H3K27ac=H3K27ac_LTR_peakid_split$Set_1$RM_id,H3K9me3= H3K9me3_LTR_peakid_split$Set_2$RM_id))+
# ggtitle("Set-3 overlaping TEs")
I struggled with figuring out whether a TE is unique to a peak. I do have some LTR elements mapping to multiple peaks, but not a whole lot.
LTR_overlap_df_H3K9me3 %>%
count(RM_id, name = "n_peaks") %>%
count(n_peaks)
# A tibble: 8 × 2
n_peaks n
<int> <int>
1 1 74479
2 2 4627
3 3 458
4 4 133
5 5 35
6 6 21
7 7 3
8 8 2
LTR_overlap_df_H3K9me3 %>%
count(RM_id) %>%
summarise(
min = min(n),
median = median(n),
mean = mean(n),
max = max(n)
)
# A tibble: 1 × 4
min median mean max
<int> <dbl> <dbl> <int>
1 1 1 1.08 8
LTR_overlap_df_H3K27ac %>%
count(RM_id, name = "n_peaks") %>%
count(n_peaks)
# A tibble: 4 × 2
n_peaks n
<int> <int>
1 1 35045
2 2 421
3 3 13
4 4 4
LTR_overlap_df_H3K27ac %>%
count(RM_id) %>%
summarise(
min = min(n),
median = median(n),
mean = mean(n),
max = max(n)
)
# A tibble: 1 × 4
min median mean max
<int> <int> <dbl> <int>
1 1 1 1.01 4
Because of this many to many situation, I chose to average the log fold changes of the LTR elements overlapping multiple peaks.
### linking shared RM_id to Peakid by histone ROI for LFC plotting
##
K27ac_rmid_lfc <- data_frame(RM_id=common_LTR_RMs) %>%
left_join(.,(LTR_overlap_df_H3K27ac %>%
dplyr::filter(RM_id %in% common_LTR_RMs) %>%
distinct(RM_id,Peakid, .keep_all = TRUE))) %>%
mutate(K27ac_Peakid=Peakid) %>%
dplyr::select(RM_id, K27ac_Peakid) %>%
left_join(K27ac_lfctable, by =c("K27ac_Peakid"="genes")) %>%
left_join(., H3K27ac_lookup, by =c("K27ac_Peakid"="Peakid")) %>%
group_by(RM_id) %>%
summarize(K27ac_24T=mean(H3K27ac_24T, na.rm=TRUE),
K27ac_24R=mean(H3K27ac_24R,na.rm=TRUE),
K27ac_144R=mean(H3K27ac_144R, na.rm=TRUE),
n_K27ac_peaks = dplyr::n(),
cluster=dplyr::first(cluster),
.groups="drop") %>%
tidyr::replace_na(list(cluster = "NA"))
K9me3_rmid_lfc <- data_frame(RM_id=common_LTR_RMs) %>%
left_join(.,(LTR_overlap_df_H3K9me3 %>%
dplyr::filter(RM_id %in% common_LTR_RMs) %>%
distinct(RM_id,Peakid, .keep_all = TRUE) %>%
mutate(K9me3_Peakid=Peakid) %>%
dplyr::select(RM_id, K9me3_Peakid))) %>%
left_join(K9me3_lfctable, by =c("K9me3_Peakid"="genes")) %>%
group_by(RM_id) %>%
summarize(K9me3_24T=mean(H3K9me3_24T, na.rm=TRUE),
K9me3_24R=mean(H3K9me3_24R,na.rm=TRUE),
K9me3_144R=mean(H3K9me3_144R, na.rm=TRUE),
n_K9me3_peaks = dplyr::n(),
.groups="drop")
LTR_RM_lfc_concordance <- tibble(RM_id = common_LTR_RMs) %>%
left_join(K27ac_rmid_lfc, by = "RM_id") %>%
left_join(K9me3_rmid_lfc, by = "RM_id")
Now to try to visualize this concordance. I am specifically looking at TEs that up in one and down in another.
LTR_RM_lfc_concordance %>%
ggplot(., aes(x=K27ac_24T, y=K9me3_24T, color=cluster))+
geom_point(, alpha=0.2, size=2)+
geom_density_2d(color= "black")+
# sm_statCorr(corr_method="spearman")+
geom_hline(yintercept = 0, linetype = "dashed", color="red") +
geom_vline(xintercept = 0, linetype = "dashed", color="red") +
labs(
x = "H3K27ac logFC (24T)",
y = "H3K9me3 logFC (24T)",
title = "Concordance of chromatin changes at shared LTRs for 24T"
) +
theme_classic()

LTR_RM_lfc_concordance %>%
ggplot(., aes(x=K27ac_24R, y=K9me3_24R, color=cluster))+
geom_point(, alpha=0.2, size=2)+
geom_density_2d(color= "black")+
# sm_statCorr(corr_method="spearman")+
geom_hline(yintercept = 0, linetype = "dashed", color="red") +
geom_vline(xintercept = 0, linetype = "dashed", color="red") +
labs(
x = "H3K27ac logFC (24R)",
y = "H3K9me3 logFC (24R)",
title = "Concordance of chromatin changes at shared LTRs for 24R"
) +
theme_classic()

LTR_RM_lfc_concordance %>%
ggplot(., aes(x=K27ac_144R, y=K9me3_144R, color=cluster))+
geom_point(, alpha=0.2, size=2)+
geom_density_2d(color= "black")+
# sm_statCorr(corr_method="spearman")+
geom_hline(yintercept = 0, linetype = "dashed", color="red") +
geom_vline(xintercept = 0, linetype = "dashed", color="red") +
labs(
x = "H3K27ac logFC (144R)",
y = "H3K9me3 logFC (144R)",
title = "Concordance of chromatin changes at shared LTRs for 144R"
) +
theme_classic()

K27ac_unfiltered_long <- K27ac_lfctable %>%
left_join(H3K27ac_lookup, by = c("genes" = "Peakid")) %>%
tidyr::replace_na(list(cluster = "NA")) %>%
dplyr::filter(cluster != "NA") %>%
pivot_longer(
cols = c("H3K27ac_24T", "H3K27ac_24R", "H3K27ac_144R"),
names_to = "group",
values_to = "LFC") %>%
mutate(group = factor(group, levels = c("H3K27ac_24T", "H3K27ac_24R", "H3K27ac_144R")))
K9me3_unfiltered_long <- K9me3_lfctable %>%
left_join(H3K9me3_lookup, by = c("genes" = "Peakid")) %>%
tidyr::replace_na(list(cluster = "NA")) %>%
dplyr::filter(cluster != "NA") %>%
pivot_longer(
cols = c("H3K9me3_24T", "H3K9me3_24R", "H3K9me3_144R"),
names_to = "group",
values_to = "LFC") %>%
mutate(group = factor(group, levels = c("H3K9me3_24T", "H3K9me3_24R", "H3K9me3_144R")))
K27ac_median_unfilt_lfc <- K27ac_unfiltered_long %>%
group_by(cluster, group) %>%
summarise(median_abs_LFC = median(abs(LFC), na.rm = TRUE),
.groups = "drop")%>%
mutate(time=str_remove(group,"H3K27ac"))%>%
mutate(time=factor(time, levels=c("_24T","_24R","_144R")))
K9me3_median_unfilt_lfc <- K9me3_unfiltered_long %>%
group_by(cluster, group) %>%
summarise(median_abs_LFC = median(abs(LFC), na.rm = TRUE),
.groups = "drop")%>%
mutate(time=str_remove(group,"H3K9me3")) %>%
mutate(time=factor(time, levels=c("_24T","_24R","_144R")))
K9me3_median_unfilt_lfc %>%
ggplot(., aes(x=group, y=median_abs_LFC, group=cluster, color=cluster))+
geom_point(size=4)+
geom_line(aes(alpha = 0.8, linewidth = 4))+
theme_bw()+
ggtitle("LFC across time for H3K27ac sets")

K27ac_median_LTR_lfc <- K27ac_unfiltered_long %>%
dplyr::filter(genes %in% H3K27ac_LTR_peakid$Peakid) %>%
group_by(cluster, group) %>%
summarise(median_abs_LFC = median(abs(LFC), na.rm = TRUE),
.groups = "drop") %>%
mutate(time=str_remove(group,"H3K27ac"))%>%
mutate(time=factor(time, levels=c("_24T","_24R","_144R")))
K9me3_median_LTR_lfc <- K9me3_unfiltered_long %>%
dplyr::filter(genes %in% H3K9me3_LTR_peakid$Peakid) %>%
group_by(cluster, group) %>%
summarise(median_abs_LFC = median(abs(LFC), na.rm = TRUE),
.groups = "drop") %>%
mutate(time=str_remove(group,"H3K9me3"))%>%
mutate(time=factor(time, levels=c("_24T","_24R","_144R")))
K9me3_median_unfilt_lfc %>%
ggplot(., aes(x=time, y=median_abs_LFC, group=cluster, color=cluster))+
geom_point(size=4)+
geom_line(aes(alpha = 0.8, linewidth = 4))+
geom_line(data=K27ac_median_unfilt_lfc, aes(x=time,y=median_abs_LFC, group=cluster,color=cluster), linetype=2, size = 1)+
geom_point(data=K27ac_median_unfilt_lfc, aes(x=time,y=median_abs_LFC, group=cluster,color=cluster), linetype=2, size = 1)+
theme_bw()+
ggtitle("H3K9me3 unfiltered solid line\nH3K27ac dotted line absolute LFC All regions")

K9me3_median_LTR_lfc %>%
ggplot(., aes(x=time, y=median_abs_LFC, group=cluster, color=cluster))+
geom_point(size=4)+
geom_line(aes(alpha = 0.8, linewidth = 4))+
geom_line(data=K27ac_median_LTR_lfc, aes(x=time,y=median_abs_LFC, group=cluster,color=cluster), linetype=2, size = 1)+
geom_point(data=K27ac_median_LTR_lfc, aes(x=time,y=median_abs_LFC, group=cluster,color=cluster), linetype=2, size = 1)+
theme_bw()+
ggtitle("H3K9me3 solid line\nH3K27ac dotted line absolute LFC overlapping LTR regions")

sessionInfo()
R version 4.4.2 (2024-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)
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] grid stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] smplot2_0.2.5 ggVennDiagram_1.5.4 ChIPseeker_1.42.1
[4] DT_0.33 ggrepel_0.9.6 rtracklayer_1.66.0
[7] genomation_1.38.0 plyranges_1.26.0 GenomicRanges_1.58.0
[10] GenomeInfoDb_1.42.3 IRanges_2.40.1 S4Vectors_0.44.0
[13] BiocGenerics_0.52.0 lubridate_1.9.4 forcats_1.0.0
[16] stringr_1.5.1 dplyr_1.1.4 purrr_1.1.0
[19] readr_2.1.5 tidyr_1.3.1 tibble_3.3.0
[22] ggplot2_3.5.2 tidyverse_2.0.0 workflowr_1.7.1
loaded via a namespace (and not attached):
[1] splines_4.4.2
[2] later_1.4.2
[3] BiocIO_1.16.0
[4] bitops_1.0-9
[5] ggplotify_0.1.2
[6] R.oo_1.27.1
[7] XML_3.99-0.18
[8] rpart_4.1.24
[9] lifecycle_1.0.4
[10] rstatix_0.7.2
[11] rprojroot_2.1.1
[12] MASS_7.3-65
[13] vroom_1.6.5
[14] processx_3.8.6
[15] lattice_0.22-7
[16] backports_1.5.0
[17] magrittr_2.0.3
[18] Hmisc_5.2-3
[19] sass_0.4.10
[20] rmarkdown_2.29
[21] jquerylib_0.1.4
[22] yaml_2.3.10
[23] plotrix_3.8-4
[24] httpuv_1.6.16
[25] ggtangle_0.0.7
[26] cowplot_1.2.0
[27] DBI_1.2.3
[28] RColorBrewer_1.1-3
[29] abind_1.4-8
[30] zlibbioc_1.52.0
[31] R.utils_2.13.0
[32] RCurl_1.98-1.17
[33] yulab.utils_0.2.1
[34] nnet_7.3-20
[35] rappdirs_0.3.3
[36] git2r_0.36.2
[37] GenomeInfoDbData_1.2.13
[38] enrichplot_1.26.6
[39] tidytree_0.4.6
[40] codetools_0.2-20
[41] DelayedArray_0.32.0
[42] DOSE_4.0.1
[43] tidyselect_1.2.1
[44] aplot_0.2.8
[45] UCSC.utils_1.2.0
[46] farver_2.1.2
[47] matrixStats_1.5.0
[48] base64enc_0.1-3
[49] GenomicAlignments_1.42.0
[50] jsonlite_2.0.0
[51] Formula_1.2-5
[52] tools_4.4.2
[53] treeio_1.30.0
[54] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
[55] Rcpp_1.1.0
[56] glue_1.8.0
[57] gridExtra_2.3
[58] SparseArray_1.6.2
[59] mgcv_1.9-3
[60] xfun_0.52
[61] qvalue_2.38.0
[62] MatrixGenerics_1.18.1
[63] withr_3.0.2
[64] fastmap_1.2.0
[65] boot_1.3-32
[66] callr_3.7.6
[67] caTools_1.18.3
[68] digest_0.6.37
[69] timechange_0.3.0
[70] R6_2.6.1
[71] gridGraphics_0.5-1
[72] seqPattern_1.38.0
[73] colorspace_2.1-1
[74] GO.db_3.20.0
[75] gtools_3.9.5
[76] dichromat_2.0-0.1
[77] RSQLite_2.4.3
[78] R.methodsS3_1.8.2
[79] generics_0.1.4
[80] data.table_1.17.8
[81] httr_1.4.7
[82] htmlwidgets_1.6.4
[83] S4Arrays_1.6.0
[84] whisker_0.4.1
[85] pkgconfig_2.0.3
[86] gtable_0.3.6
[87] blob_1.2.4
[88] impute_1.80.0
[89] XVector_0.46.0
[90] htmltools_0.5.8.1
[91] carData_3.0-5
[92] pwr_1.3-0
[93] fgsea_1.32.4
[94] scales_1.4.0
[95] Biobase_2.66.0
[96] png_0.1-8
[97] ggfun_0.2.0
[98] knitr_1.50
[99] rstudioapi_0.17.1
[100] tzdb_0.5.0
[101] reshape2_1.4.4
[102] rjson_0.2.23
[103] checkmate_2.3.3
[104] nlme_3.1-168
[105] curl_7.0.0
[106] zoo_1.8-14
[107] cachem_1.1.0
[108] KernSmooth_2.23-26
[109] parallel_4.4.2
[110] foreign_0.8-90
[111] AnnotationDbi_1.68.0
[112] restfulr_0.0.16
[113] pillar_1.11.0
[114] vctrs_0.6.5
[115] gplots_3.2.0
[116] ggpubr_0.6.1
[117] promises_1.3.3
[118] car_3.1-3
[119] cluster_2.1.8.1
[120] htmlTable_2.4.3
[121] evaluate_1.0.5
[122] isoband_0.2.7
[123] GenomicFeatures_1.58.0
[124] cli_3.6.5
[125] compiler_4.4.2
[126] Rsamtools_2.22.0
[127] rlang_1.1.6
[128] crayon_1.5.3
[129] ggsignif_0.6.4
[130] labeling_0.4.3
[131] ps_1.9.1
[132] getPass_0.2-4
[133] plyr_1.8.9
[134] fs_1.6.6
[135] stringi_1.8.7
[136] gridBase_0.4-7
[137] BiocParallel_1.40.2
[138] Biostrings_2.74.1
[139] lazyeval_0.2.2
[140] GOSemSim_2.32.0
[141] Matrix_1.7-3
[142] BSgenome_1.74.0
[143] hms_1.1.3
[144] patchwork_1.3.2
[145] bit64_4.6.0-1
[146] KEGGREST_1.46.0
[147] SummarizedExperiment_1.36.0
[148] broom_1.0.9
[149] igraph_2.1.4
[150] memoise_2.0.1
[151] bslib_0.9.0
[152] ggtree_3.14.0
[153] fastmatch_1.1-6
[154] bit_4.6.0
[155] ape_5.8-1