Last updated: 2025-05-01

Checks: 7 0

Knit directory: ATAC_learning/

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(20231016) 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 cfc813a. 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:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/ACresp_SNP_table.csv
    Ignored:    data/ARR_SNP_table.csv
    Ignored:    data/All_merged_peaks.tsv
    Ignored:    data/CAD_gwas_dataframe.RDS
    Ignored:    data/CTX_SNP_table.csv
    Ignored:    data/Collapsed_expressed_NG_peak_table.csv
    Ignored:    data/DEG_toplist_sep_n45.RDS
    Ignored:    data/FRiP_first_run.txt
    Ignored:    data/Final_four_data/
    Ignored:    data/Frip_1_reads.csv
    Ignored:    data/Frip_2_reads.csv
    Ignored:    data/Frip_3_reads.csv
    Ignored:    data/Frip_4_reads.csv
    Ignored:    data/Frip_5_reads.csv
    Ignored:    data/Frip_6_reads.csv
    Ignored:    data/GO_KEGG_analysis/
    Ignored:    data/HF_SNP_table.csv
    Ignored:    data/Ind1_75DA24h_dedup_peaks.csv
    Ignored:    data/Ind1_TSS_peaks.RDS
    Ignored:    data/Ind1_firstfragment_files.txt
    Ignored:    data/Ind1_fragment_files.txt
    Ignored:    data/Ind1_peaks_list.RDS
    Ignored:    data/Ind1_summary.txt
    Ignored:    data/Ind2_TSS_peaks.RDS
    Ignored:    data/Ind2_fragment_files.txt
    Ignored:    data/Ind2_peaks_list.RDS
    Ignored:    data/Ind2_summary.txt
    Ignored:    data/Ind3_TSS_peaks.RDS
    Ignored:    data/Ind3_fragment_files.txt
    Ignored:    data/Ind3_peaks_list.RDS
    Ignored:    data/Ind3_summary.txt
    Ignored:    data/Ind4_79B24h_dedup_peaks.csv
    Ignored:    data/Ind4_TSS_peaks.RDS
    Ignored:    data/Ind4_V24h_fraglength.txt
    Ignored:    data/Ind4_fragment_files.txt
    Ignored:    data/Ind4_fragment_filesN.txt
    Ignored:    data/Ind4_peaks_list.RDS
    Ignored:    data/Ind4_summary.txt
    Ignored:    data/Ind5_TSS_peaks.RDS
    Ignored:    data/Ind5_fragment_files.txt
    Ignored:    data/Ind5_fragment_filesN.txt
    Ignored:    data/Ind5_peaks_list.RDS
    Ignored:    data/Ind5_summary.txt
    Ignored:    data/Ind6_TSS_peaks.RDS
    Ignored:    data/Ind6_fragment_files.txt
    Ignored:    data/Ind6_peaks_list.RDS
    Ignored:    data/Ind6_summary.txt
    Ignored:    data/Knowles_4.RDS
    Ignored:    data/Knowles_5.RDS
    Ignored:    data/Knowles_6.RDS
    Ignored:    data/LiSiLTDNRe_TE_df.RDS
    Ignored:    data/MI_gwas.RDS
    Ignored:    data/SNP_GWAS_PEAK_MRC_id
    Ignored:    data/SNP_GWAS_PEAK_MRC_id.csv
    Ignored:    data/SNP_gene_cat_list.tsv
    Ignored:    data/SNP_supp_schneider.RDS
    Ignored:    data/TE_info/
    Ignored:    data/TFmapnames.RDS
    Ignored:    data/all_TSSE_scores.RDS
    Ignored:    data/all_four_filtered_counts.txt
    Ignored:    data/aln_run1_results.txt
    Ignored:    data/anno_ind1_DA24h.RDS
    Ignored:    data/anno_ind4_V24h.RDS
    Ignored:    data/annotated_gwas_SNPS.csv
    Ignored:    data/background_n45_he_peaks.RDS
    Ignored:    data/cardiac_muscle_FRIP.csv
    Ignored:    data/cardiomyocyte_FRIP.csv
    Ignored:    data/col_ng_peak.csv
    Ignored:    data/cormotif_full_4_run.RDS
    Ignored:    data/cormotif_full_4_run_he.RDS
    Ignored:    data/cormotif_full_6_run.RDS
    Ignored:    data/cormotif_full_6_run_he.RDS
    Ignored:    data/cormotif_probability_45_list.csv
    Ignored:    data/cormotif_probability_45_list_he.csv
    Ignored:    data/cormotif_probability_all_6_list.csv
    Ignored:    data/cormotif_probability_all_6_list_he.csv
    Ignored:    data/datasave.RDS
    Ignored:    data/embryo_heart_FRIP.csv
    Ignored:    data/enhancer_list_ENCFF126UHK.bed
    Ignored:    data/enhancerdata/
    Ignored:    data/filt_Peaks_efit2.RDS
    Ignored:    data/filt_Peaks_efit2_bl.RDS
    Ignored:    data/filt_Peaks_efit2_n45.RDS
    Ignored:    data/first_Peaksummarycounts.csv
    Ignored:    data/first_run_frag_counts.txt
    Ignored:    data/full_bedfiles/
    Ignored:    data/gene_ref.csv
    Ignored:    data/gwas_1_dataframe.RDS
    Ignored:    data/gwas_2_dataframe.RDS
    Ignored:    data/gwas_3_dataframe.RDS
    Ignored:    data/gwas_4_dataframe.RDS
    Ignored:    data/gwas_5_dataframe.RDS
    Ignored:    data/high_conf_peak_counts.csv
    Ignored:    data/high_conf_peak_counts.txt
    Ignored:    data/high_conf_peaks_bl_counts.txt
    Ignored:    data/high_conf_peaks_counts.txt
    Ignored:    data/hits_files/
    Ignored:    data/hyper_files/
    Ignored:    data/hypo_files/
    Ignored:    data/ind1_DA24hpeaks.RDS
    Ignored:    data/ind1_TSSE.RDS
    Ignored:    data/ind2_TSSE.RDS
    Ignored:    data/ind3_TSSE.RDS
    Ignored:    data/ind4_TSSE.RDS
    Ignored:    data/ind4_V24hpeaks.RDS
    Ignored:    data/ind5_TSSE.RDS
    Ignored:    data/ind6_TSSE.RDS
    Ignored:    data/initial_complete_stats_run1.txt
    Ignored:    data/left_ventricle_FRIP.csv
    Ignored:    data/median_24_lfc.RDS
    Ignored:    data/median_3_lfc.RDS
    Ignored:    data/mergedPeads.gff
    Ignored:    data/mergedPeaks.gff
    Ignored:    data/motif_list_full
    Ignored:    data/motif_list_n45
    Ignored:    data/motif_list_n45.RDS
    Ignored:    data/multiqc_fastqc_run1.txt
    Ignored:    data/multiqc_fastqc_run2.txt
    Ignored:    data/multiqc_genestat_run1.txt
    Ignored:    data/multiqc_genestat_run2.txt
    Ignored:    data/my_hc_filt_counts.RDS
    Ignored:    data/my_hc_filt_counts_n45.RDS
    Ignored:    data/n45_bedfiles/
    Ignored:    data/n45_files
    Ignored:    data/other_papers/
    Ignored:    data/peakAnnoList_1.RDS
    Ignored:    data/peakAnnoList_2.RDS
    Ignored:    data/peakAnnoList_24_full.RDS
    Ignored:    data/peakAnnoList_24_n45.RDS
    Ignored:    data/peakAnnoList_3.RDS
    Ignored:    data/peakAnnoList_3_full.RDS
    Ignored:    data/peakAnnoList_3_n45.RDS
    Ignored:    data/peakAnnoList_4.RDS
    Ignored:    data/peakAnnoList_5.RDS
    Ignored:    data/peakAnnoList_6.RDS
    Ignored:    data/peakAnnoList_Eight.RDS
    Ignored:    data/peakAnnoList_full_motif.RDS
    Ignored:    data/peakAnnoList_n45_motif.RDS
    Ignored:    data/siglist_full.RDS
    Ignored:    data/siglist_n45.RDS
    Ignored:    data/summarized_peaks_dataframe.txt
    Ignored:    data/summary_peakIDandReHeat.csv
    Ignored:    data/test.list.RDS
    Ignored:    data/testnames.txt
    Ignored:    data/toplist_6.RDS
    Ignored:    data/toplist_full.RDS
    Ignored:    data/toplist_full_DAR_6.RDS
    Ignored:    data/toplist_n45.RDS
    Ignored:    data/trimmed_seq_length.csv
    Ignored:    data/unclassified_full_set_peaks.RDS
    Ignored:    data/unclassified_n45_set_peaks.RDS
    Ignored:    data/xstreme/

Untracked files:
    Untracked:  analysis/Expressed_RNA_associations.Rmd
    Untracked:  analysis/LFC_corr.Rmd
    Untracked:  analysis/SVA.Rmd
    Untracked:  analysis/Tan2020.Rmd
    Untracked:  analysis/my_hc_filt_counts.csv
    Untracked:  code/IGV_snapshot_code.R
    Untracked:  code/LongDARlist.R
    Untracked:  code/just_for_Fun.R
    Untracked:  output/cormotif_probability_45_list.csv
    Untracked:  output/cormotif_probability_all_6_list.csv
    Untracked:  setup.RData

Unstaged changes:
    Modified:   ATAC_learning.Rproj
    Modified:   analysis/Correlation_of_SNPnPEAK.Rmd
    Modified:   analysis/GO_KEGG_analysis.Rmd
    Modified:   analysis/Raodah_mycount.Rmd
    Modified:   analysis/TE_analysis_ff.Rmd
    Modified:   analysis/final_plot_attempt.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/Figure_2.Rmd) and HTML (docs/Figure_2.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
html b735dc1 E. Renee Matthews 2025-02-24 Build site.
Rmd d88843c E. Renee Matthews 2025-02-24 wflow_publish("analysis/Figure_2.Rmd")
Rmd 8161256 E. Renee Matthews 2025-02-21 next figure

package loading
library(tidyverse)
library(kableExtra)
library(broom)
library(RColorBrewer)
library("TxDb.Hsapiens.UCSC.hg38.knownGene")
library("org.Hs.eg.db")
library(rtracklayer)
library(ggfortify)
library(readr)
library(BiocGenerics)
library(gridExtra)
library(scales)
library(BiocParallel)
library(ggpubr)
# library(edgeR)
library(genomation)
library(ggsignif)
library(plyranges)
library(ggrepel)
library(ComplexHeatmap)
library(cowplot)
library(smplot2)
library(readxl)
library(circlize)
library(epitools)

Figure 2

knitr::include_graphics("assets/Figure\ 2.png", error=FALSE)

Version Author Date
50f3de9 E. Renee Matthews 2025-02-21
knitr::include_graphics("docs/assets/Figure\ 2.png",error = FALSE)

Figure 2.A. Transposable elements:

repeatmasker
repeatmasker <- read.delim("data/other_papers/repeatmasker.tsv")
# TSS_NG_data <- read_delim("data/Final_four_data/TSS_assigned_NG.txt", 
#     delim = "\t", escape_double = FALSE, 
#     trim_ws = TRUE)
Collapsed_peaks <- read_delim("data/Final_four_data/collapsed_new_peaks.txt",
                              delim = "\t", 
                              escape_double = FALSE, 
                              trim_ws = TRUE)

reClass_list <- repeatmasker %>% 
  distinct(repClass)

Line_repeats <- repeatmasker %>% 
  dplyr::filter(repClass == "LINE") %>% 
 makeGRangesFromDataFrame(., keep.extra.columns = TRUE, seqnames.field = "genoName", start.field = "genoStart", end.field = "genoEnd",starts.in.df.are.0based=TRUE)

Sine_repeats <- repeatmasker %>% 
  dplyr::filter(repClass == "SINE") %>% 
 makeGRangesFromDataFrame(., keep.extra.columns = TRUE, seqnames.field = "genoName", start.field = "genoStart", end.field = "genoEnd",starts.in.df.are.0based=TRUE)

LTR_repeats <- repeatmasker %>% 
  dplyr::filter(repClass == "LTR") %>% 
 makeGRangesFromDataFrame(., keep.extra.columns = TRUE, seqnames.field = "genoName", start.field = "genoStart", end.field = "genoEnd",starts.in.df.are.0based=TRUE)

DNA_repeats <- repeatmasker %>% 
  dplyr::filter(repClass == "DNA") %>% 
 makeGRangesFromDataFrame(., keep.extra.columns = TRUE, seqnames.field = "genoName", start.field = "genoStart", end.field = "genoEnd",starts.in.df.are.0based=TRUE)

retroposon_repeats <- repeatmasker %>% 
  dplyr::filter(repClass == "Retroposon") %>% 
 makeGRangesFromDataFrame(., keep.extra.columns = TRUE, seqnames.field = "genoName", start.field = "genoStart", end.field = "genoEnd",starts.in.df.are.0based=TRUE)


all_TEs_gr <- repeatmasker %>% 
 makeGRangesFromDataFrame(., keep.extra.columns = TRUE, seqnames.field = "genoName", start.field = "genoStart", end.field = "genoEnd",starts.in.df.are.0based=TRUE)

Nine_group_list <- readRDS("data/Final_four_data/Nine_group_list.RDS")
list2env(Nine_group_list, envir = .GlobalEnv)
<environment: R_GlobalEnv>
peakAnnoList_ff_motif <- readRDS("data/Final_four_data/peakAnnoList_ff_motif.RDS")

background_peaks <- as.data.frame(peakAnnoList_ff_motif$background) 

Col_TSS_data_gr <- Collapsed_peaks %>% 
  dplyr::filter(chr != "chrY") %>%
  dplyr::filter(Peakid %in% background_peaks$Peakid) %>% 
  GRanges()

all_TEs_gr$TE_width <- width(all_TEs_gr)
Col_TSS_data_gr$peak_width <- width(Col_TSS_data_gr)
Col_fullDF_overlap <- join_overlap_intersect(Col_TSS_data_gr,all_TEs_gr)


cpgislands_df <- read.delim("data/other_papers/cpg_islands.tsv")

cpg_island_gr <- cpgislands_df %>% 
 makeGRangesFromDataFrame(., keep.extra.columns = TRUE, seqnames.field = "chrom", start.field = "chromStart", end.field = "chromEnd",starts.in.df.are.0based=TRUE)
Col_TSS_data_gr$peak_width <- width(Col_TSS_data_gr)
cpg_island_gr$cpg_width <- width(cpg_island_gr)

txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene
transcripts <- transcripts(txdb)
tss <- resize(transcripts, width = 1, fix = "start")

overlaps <- findOverlaps(Col_TSS_data_gr,tss)
overlapping_regions <- Col_TSS_data_gr[queryHits(overlaps)]
TSS_overlap_list <- overlapping_regions %>% as.data.frame() %>% 
  distinct(Peakid)

Col_fullDF_cug_overlap <- join_overlap_intersect(Col_TSS_data_gr,cpg_island_gr)
Col_fullDF_cug_overlap <-Col_fullDF_cug_overlap %>% 
  as.data.frame %>% 
  mutate(per_ol=width/cpg_width)
Nine_te_df <-
Col_TSS_data_gr %>% 
  as.data.frame %>%
  distinct(Peakid) %>%
  left_join(.,(Col_fullDF_overlap %>% as.data.frame)) %>%
  dplyr::select(Peakid, repName:repFamily,TE_width,width) %>% 
    mutate(mrc = case_when(
    Peakid %in% EAR_open$Peakid ~ "EAR_open",
    Peakid %in% EAR_close$Peakid ~ "EAR_close",
    Peakid %in% ESR_open$Peakid ~ "ESR_open",
    Peakid %in% ESR_close$Peakid ~ "ESR_close",
    Peakid %in% ESR_opcl$Peakid ~ "ESR_opcl",
    Peakid %in% LR_open$Peakid ~ "LR_open",
    Peakid %in% LR_close$Peakid ~ "LR_close",
    Peakid %in% NR$Peakid ~ "NR",
    Peakid %in% ESR_clop$Peakid ~ "ESR_clop",
    TRUE ~ "not_mrc"
  )) %>%  
    mutate(per_ol= width/TE_width) %>% 
    mutate(TEstatus=if_else(is.na(repClass),"not_TE_peak","TE_peak")) %>% 
    mutate(repClass_org=repClass) %>% 
    mutate(repClass=factor(repClass)) %>% 
    mutate(repClass=if_else(repClass_org=="LINE", repClass_org,
          if_else(repClass_org=="SINE",repClass_org,
            if_else(repClass_org=="LTR", repClass_org, 
              if_else(repClass_org=="DNA", repClass_org, 
                  if_else(repClass_org=="Retroposon",repClass_org,"Other")))))) %>% 
   mutate(Sine_status = if_else(is.na(repClass),"not_sine",
                               if_else(repClass=="SINE","sine_peak", "not_sine"))) %>% 
   mutate(Line_status = if_else(is.na(repClass),"not_line",
                                if_else(repClass=="LINE","line_peak", "not_line"))) %>%
   mutate(LTR_status = if_else(is.na(repClass),"not_LTR",
                               if_else(repClass=="LTR","LTR_peak", "not_LTR"))) %>% 
   mutate(DNA_status = if_else(is.na(repClass),"not_DNA",
                                if_else(repClass=="DNA","DNA_peak", "not_DNA"))) %>% 
   mutate(Retro_status = if_else(is.na(repClass)&is.na(per_ol),"not_Retro",
                                if_else(repClass=="Retroposon","Retro_peak", "not_Retro"))) %>% 
    mutate(TEstatus=factor(TEstatus, levels = c("TE_peak","not_TE_peak")))%>% 
    mutate(Sine_status=factor(Sine_status, levels = c("sine_peak","not_sine")),
       Line_status=factor(Line_status, levels =c("line_peak","not_line")),
       LTR_status=factor(LTR_status, levels =c("LTR_peak","not_LTR")),
       DNA_status=factor(DNA_status, levels =c("DNA_peak","not_DNA")),
       Retro_status=factor(Retro_status, levels =c("Retro_peak","not_Retro"))) 


CUG_mrc_nine_list <-
Col_TSS_data_gr%>% as.data.frame() %>%
  left_join(., (Col_fullDF_cug_overlap %>% 
                  as.data.frame(.)), by=c("seqnames"="seqnames", "start"="start", "end"="end", "Peakid"="Peakid", "NCBI_gene"="NCBI_gene", "dist_to_NG"="dist_to_NG",  "SYMBOL" = "SYMBOL", "peak_width"="peak_width")) %>% 
  dplyr::select(Peakid, name,cpgNum:per_ol) %>% 
  mutate(cugstatus=if_else(is.na(cpgNum),"not_CGi_peak","CGi_peak")) %>% 
  mutate(mrc = case_when(
    Peakid %in% EAR_open$Peakid ~ "EAR_open",
    Peakid %in% EAR_close$Peakid ~ "EAR_close",
    Peakid %in% ESR_open$Peakid ~ "ESR_open",
    Peakid %in% ESR_close$Peakid ~ "ESR_close",
    Peakid %in% ESR_opcl$Peakid ~ "ESR_opcl",
    Peakid %in% LR_open$Peakid ~ "LR_open",
    Peakid %in% LR_close$Peakid ~ "LR_close",
    Peakid %in% NR$Peakid ~ "NR",
    Peakid %in% ESR_clop$Peakid ~ "ESR_clop",
    TRUE ~ "not_mrc"
  )) %>%  
  distinct()

making contingency matrices ##### contingency matrices for TE/TSS/CGI

TE_mat<- Nine_te_df %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(TEstatus, mrc) %>% 
  tally %>% 
  pivot_wider(id_cols = mrc, names_from = TEstatus,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  as.matrix(.)

Sine_mat<- Nine_te_df %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  group_by(Sine_status, mrc) %>% 
  tally %>% 
  
  pivot_wider(id_cols = mrc, names_from = Sine_status,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit(.) %>% 
  as.matrix(.)

Line_mat<- Nine_te_df %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(Line_status, mrc) %>% 
  tally %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  pivot_wider(id_cols = mrc, names_from = Line_status,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit(.) %>% 
  as.matrix(.)

LTR_mat<- Nine_te_df %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(LTR_status, mrc) %>% 
  tally %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  pivot_wider(id_cols = mrc, names_from = LTR_status,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit(.) %>% 
  as.matrix(.)

Retro_mat<- Nine_te_df %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(Retro_status, mrc) %>% 
  tally %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  pivot_wider(id_cols = mrc, names_from = Retro_status,values_from = n) %>% 
  column_to_rownames("mrc") %>%
  na.omit(.) %>% 
  as.matrix(.)

DNA_mat<- Nine_te_df %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(DNA_status, mrc) %>% 
  tally %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  pivot_wider(id_cols = mrc, names_from = DNA_status,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit(.) %>% 
  as.matrix(.)


CUG_mat <- CUG_mrc_nine_list %>% 
  distinct(Peakid,.keep_all = TRUE) %>%
  dplyr::filter(mrc != "not_mrc") %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  group_by(cugstatus, mrc) %>% 
  tally  %>% 
  pivot_wider(id_cols = mrc, names_from = cugstatus,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit() %>% 
  as.matrix(.)


TSS_mat <-Col_TSS_data_gr %>% 
  as.data.frame() %>% 
  dplyr::select(Peakid) %>% 
  mutate(TSS_status= if_else(Peakid %in% TSS_overlap_list$Peakid,"TSS_peak","not_TSS_peak")) %>% 
   mutate(mrc = case_when(
    Peakid %in% EAR_open$Peakid ~ "EAR_open",
    Peakid %in% EAR_close$Peakid ~ "EAR_close",
    Peakid %in% ESR_open$Peakid ~ "ESR_open",
    Peakid %in% ESR_close$Peakid ~ "ESR_close",
    Peakid %in% ESR_opcl$Peakid ~ "ESR_opcl",
    Peakid %in% LR_open$Peakid ~ "LR_open",
    Peakid %in% LR_close$Peakid ~ "LR_close",
    Peakid %in% NR$Peakid ~ "NR",
    Peakid %in% ESR_clop$Peakid ~ "ESR_clop",
    TRUE ~ "not_mrc"
  )) %>%  
  group_by(TSS_status, mrc) %>% 
  dplyr::filter(mrc !="not_mrc") %>% 
  tally  %>% 
  pivot_wider(id_cols = mrc, names_from = TSS_status,values_from = n) %>% 
  column_to_rownames("mrc") %>%
  na.omit(.) %>% 
  as.matrix(.)
odds ratio TE/TSS/CGI
matrix_list <- list("TE"=TE_mat, "Sines"=Sine_mat, "Lines"=Line_mat,"DNA"= DNA_mat,"Retro"= Retro_mat,"LTR"= LTR_mat,"CGI"=CUG_mat,"TSS"=TSS_mat)
results_or <- data.frame(Matrix_Name = character(),
                      Row_Compared = character(),
                      Odds_Ratio = numeric(),
                      Lower_CI = numeric(),
                      Upper_CI = numeric(),
                      P_Value = numeric(),
                      stringsAsFactors = FALSE)

# Loop through each matrix in the list
for (matrix_name in names(matrix_list)) {
  current_matrix <- matrix_list[[matrix_name]]
  n_rows <- nrow(current_matrix)
  
  # Loop through each row of the current matrix (except the last row)
  for (i in 1:(n_rows - 1)) {
    # Perform odds ratio test between row i and the last row using epitools
    test_result <- tryCatch({
      contingency_table <- rbind(current_matrix[i, ], current_matrix[n_rows, ])
      
      # Check if any row in the contingency table contains only zeros
      if (any(rowSums(contingency_table) == 0)) {
        stop("Contingency table contains empty rows.")
      }
      
      oddsratio_result <- oddsratio(contingency_table)
       # Ensure the oddsratio result has at least 2 rows
      if (nrow(oddsratio_result$measure) < 2) {
        stop("oddsratio result does not have enough data.")
      }
      
     list(oddsratio = oddsratio_result, p.value = oddsratio_result$p.value[2,"chi.square"])
      
    }, error = function(e) {
      cat("Error in odds ratio test for row", i, "in matrix", matrix_name, ":", e$message, "\n")
      return(NULL)
    })
    
    # Only store the result if test_result is valid (i.e., not NULL)
    if (!is.null(test_result)) {
      or_value <- test_result$oddsratio$measure[2, "estimate"]
      lower_ci <- test_result$oddsratio$measure[2, "lower"]
      upper_ci <- test_result$oddsratio$measure[2, "upper"]
      p_value <- test_result$oddsratio$p.value[2,"chi.square"]
      
      # Check if the values are numeric and valid (not NA)
      if (!is.na(or_value) && !is.na(lower_ci) && !is.na(upper_ci) && !is.na(p_value)) {
        # Store the results in the dataframe
        results_or <- rbind(results_or, data.frame(Matrix_Name = matrix_name,
                                             Row_Compared = rownames(current_matrix)[i],
                                             Odds_Ratio = or_value,
                                             Lower_CI = lower_ci,
                                             Upper_CI = upper_ci,
                                             P_Value = p_value))
      }
    }
  }
}


results_or <- results_or %>% 
  mutate(Matrix_Name=factor(Matrix_Name, levels=c("TE","Sines","Lines", "DNA","LTR","Retro","CGI","TSS"))) %>% 
    mutate(Row_Compared=factor(Row_Compared, levels = c("EAR_open","ESR_open", "LR_open","ESR_opcl", "EAR_close", "ESR_close", "LR_close", "ESR_clop"))) %>% 
  arrange(Matrix_Name,Row_Compared)  


col_fun_OR = colorRamp2(c(0,1,1.5,3,4), c("#BC9BFF","white","lightgreen","green3","green3" ))
sig_mat_OR <- results_or %>% 
  as.data.frame() %>% 
  dplyr::select( Matrix_Name,Row_Compared,P_Value) %>% 
  pivot_wider(., id_cols = Matrix_Name, names_from = Row_Compared, values_from = P_Value) %>% 
  column_to_rownames("Matrix_Name") %>% 
  as.matrix() 


# results_or %>% 
#   as.data.frame() %>% 
#   dplyr::select( Matrix_Name,Row_Compared,Odds_Ratio) %>% 
#   pivot_wider(., id_cols = Matrix_Name, names_from = Row_Compared, values_from = Odds_Ratio) %>% 
#   column_to_rownames("Matrix_Name") %>% 
#   as.matrix() %>% 
#   ComplexHeatmap::Heatmap(. ,col = col_fun_OR, 
#                           cluster_rows=FALSE, 
#                           cluster_columns=FALSE, 
#                           column_names_side = "top", 
#                           column_names_rot = 45,
#                           # na_col = "black",
#                           cell_fun = function(j, i, x, y, width, height, fill) {if (!is.na(sig_mat_OR[i, j]) && sig_mat_OR[i, j] < 0.05)
#             grid.text("*", x, y, gp = gpar(fontsize = 20))})
cRE dataframes
cREs_HLV_46F <- genomation::readBed("data/enhancerdata/ENCFF867HAD_ENCFF152PBB_ENCFF352YYH_ENCFF252IVK.7group.bed")
NR_gr <- NR %>% GRanges()
LR_open_gr <- LR_open %>% GRanges()
LR_close_gr <- LR_close%>% GRanges()
EAR_open_gr <- EAR_open%>% GRanges()
EAR_close_gr <- EAR_close%>% GRanges()
ESR_open_gr <- ESR_open%>% GRanges()
ESR_close_gr <- ESR_close%>% GRanges()
ESR_opcl_gr <- ESR_opcl%>% GRanges()
ESR_clop_gr <- ESR_clop%>% GRanges()
  
NR_cREs <- join_overlap_intersect(NR_gr,cREs_HLV_46F)
LR_open_cREs <- join_overlap_intersect(LR_open_gr,cREs_HLV_46F)
LR_close_cREs <- join_overlap_intersect(LR_close_gr,cREs_HLV_46F)
ESR_open_cREs <- join_overlap_intersect(ESR_open_gr,cREs_HLV_46F)
ESR_close_cREs <- join_overlap_intersect(ESR_close_gr,cREs_HLV_46F)
ESR_opcl_cREs <- join_overlap_intersect(ESR_opcl_gr, cREs_HLV_46F)
ESR_clop_cREs <- join_overlap_intersect(ESR_clop_gr, cREs_HLV_46F)
EAR_open_cREs <- join_overlap_intersect(EAR_open_gr,cREs_HLV_46F)
EAR_close_cREs <- join_overlap_intersect(EAR_close_gr,cREs_HLV_46F)


Whole_peaks <- join_overlap_intersect(Col_TSS_data_gr, cREs_HLV_46F)
keep_cRE_names <- c("CTCF-only,CTCF-bound" ,"PLS,CTCF-bound","PLS","dELS,CTCF-bound", "pELS","pELS,CTCF-bound","dELS")
is_cRE <- Whole_peaks %>% 
  as.data.frame() %>% 
  dplyr::filter(blockCount %in% keep_cRE_names) %>% 
  distinct(Peakid,blockCount) 

is_CTCF <- Whole_peaks %>% 
  as.data.frame() %>% 
  dplyr::filter(blockCount == "CTCF-only,CTCF-bound") %>% 
  distinct(Peakid,blockCount) 

is_dELS <- Whole_peaks %>% 
  as.data.frame() %>% 
  dplyr::filter(blockCount == "dELS,CTCF-bound"|blockCount == "dELS") %>% 
  distinct(Peakid,blockCount) 
is_pELS <- Whole_peaks %>% 
  as.data.frame() %>% 
  dplyr::filter(blockCount == "pELS,CTCF-bound"|blockCount == "pELS") %>% 
  distinct(Peakid,blockCount) 
is_PLS <- Whole_peaks %>% 
  as.data.frame() %>% 
  dplyr::filter(blockCount == "PLS,CTCF-bound"|blockCount == "PLS") %>% 
  distinct(Peakid,blockCount)

CRE_summary <- Collapsed_peaks %>% 
   mutate(cRE_status=if_else(Peakid %in% is_cRE$Peakid,"cRE_peak","not_cRE_peak")) %>% 
   mutate(CTCF_status=if_else(Peakid %in% is_CTCF$Peakid,"CTCF_peak","not_CTCF_peak")) %>% 
    mutate(dELS_status=if_else(Peakid %in% is_dELS$Peakid,"dELS_peak","not_dELS_peak")) %>% 
    mutate(pELS_status=if_else(Peakid %in% is_pELS$Peakid,"pELS_peak","not_pELS_peak")) %>% 
    mutate(PLS_status=if_else(Peakid %in% is_PLS$Peakid,"PLS_peak","not_PLS_peak")) %>% 
   mutate(mrc = case_when(
    Peakid %in% EAR_open$Peakid ~ "EAR_open",
    Peakid %in% EAR_close$Peakid ~ "EAR_close",
    Peakid %in% ESR_open$Peakid ~ "ESR_open",
    Peakid %in% ESR_close$Peakid ~ "ESR_close",
    Peakid %in% ESR_opcl$Peakid ~ "ESR_opcl",
    Peakid %in% LR_open$Peakid ~ "LR_open",
    Peakid %in% LR_close$Peakid ~ "LR_close",
    Peakid %in% NR$Peakid ~ "NR",
    Peakid %in% ESR_clop$Peakid ~ "ESR_clop",
    TRUE ~ "not_mrc"
  )) 
cRE contingency matricies
cRE_mat<- CRE_summary %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(cRE_status, mrc) %>% 
  tally %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  pivot_wider(id_cols = mrc, names_from = cRE_status,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit(.) %>% 
  as.matrix(.)

CTCF_mat<- CRE_summary %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(CTCF_status, mrc) %>% 
  tally %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  pivot_wider(id_cols = mrc, names_from = CTCF_status,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit(.) %>% 
  as.matrix(.)

dELS_mat<- CRE_summary %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(dELS_status, mrc) %>% 
  tally %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  pivot_wider(id_cols = mrc, names_from = dELS_status,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit(.) %>% 
  as.matrix(.)

pELS_mat<- CRE_summary %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(pELS_status, mrc) %>% 
  tally %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  pivot_wider(id_cols = mrc, names_from = pELS_status,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit(.) %>% 
  as.matrix(.)

PLS_mat<- CRE_summary %>% 
 dplyr::filter(mrc != "not_mrc") %>% 
  group_by(PLS_status, mrc) %>% 
  tally %>% 
  mutate(mrc= factor(mrc, levels = c("EAR_open","EAR_close","ESR_open", "ESR_close", "ESR_opcl", "ESR_clop","LR_open","LR_close","NR"))) %>% 
  pivot_wider(id_cols = mrc, names_from = PLS_status,values_from = n) %>% 
  column_to_rownames("mrc") %>% 
  na.omit(.) %>% 
  as.matrix(.)
cRE odds ratio
matrix_list_cre <- list("PLS"=PLS_mat, "dELS"=dELS_mat, "pELS"=pELS_mat,"CTCF"= CTCF_mat,"All cREs"= cRE_mat)

results_or_cre <- data.frame(Matrix_Name = character(),
                      Row_Compared = character(),
                      Odds_Ratio = numeric(),
                      Lower_CI = numeric(),
                      Upper_CI = numeric(),
                      P_Value = numeric(),
                      stringsAsFactors = FALSE)

# Loop through each matrix in the list
for (matrix_name in names(matrix_list_cre)) {
  current_matrix <- matrix_list_cre[[matrix_name]]
  n_rows <- nrow(current_matrix)
  
  # Loop through each row of the current matrix (except the last row)
  for (i in 1:(n_rows - 1)) {
    # Perform odds ratio test between row i and the last row using epitools
    test_result <- tryCatch({
      contingency_table <- rbind(current_matrix[i, ], current_matrix[n_rows, ])
      
      # Check if any row in the contingency table contains only zeros
      if (any(rowSums(contingency_table) == 0)) {
        stop("Contingency table contains empty rows.")
      }
      
      oddsratio_result <- oddsratio(contingency_table)
       # Ensure the oddsratio result has at least 2 rows
      if (nrow(oddsratio_result$measure) < 2) {
        stop("oddsratio result does not have enough data.")
      }
      
     
      
      list(oddsratio = oddsratio_result, p.value = oddsratio_result$p.value[2,"chi.square"])
      
    }, error = function(e) {
      cat("Error in odds ratio test for row", i, "in matrix", matrix_name, ":", e$message, "\n")
      return(NULL)
    })
    
    # Only store the result if test_result is valid (i.e., not NULL)
    if (!is.null(test_result)) {
      or_value <- test_result$oddsratio$measure[2, "estimate"]
      lower_ci <- test_result$oddsratio$measure[2, "lower"]
      upper_ci <- test_result$oddsratio$measure[2, "upper"]
      p_value <- test_result$oddsratio$p.value[2,"chi.square"]
      
      # Check if the values are numeric and valid (not NA)
      if (!is.na(or_value) && !is.na(lower_ci) && !is.na(upper_ci) && !is.na(p_value)) {
        # Store the results in the dataframe
        results_or_cre <- rbind(results_or_cre, data.frame(Matrix_Name = matrix_name,
                                             Row_Compared = rownames(current_matrix)[i],
                                             Odds_Ratio = or_value,
                                             Lower_CI = lower_ci,
                                             Upper_CI = upper_ci,
                                             P_Value = p_value))
      }
    }
  }
}

results_or_cre <- results_or_cre %>% 
  mutate(Matrix_Name=factor(Matrix_Name, levels=c("All cREs","PLS","dELS", "pELS","CTCF"))) %>% 
    mutate(Row_Compared=factor(Row_Compared, levels = c("EAR_open","ESR_open", "LR_open","ESR_opcl", "EAR_close", "ESR_close", "LR_close", "ESR_clop"))) %>% 
  arrange(Matrix_Name,Row_Compared)  

 


col_fun_cre =  colorRamp2(c(0,1,1.5,3,4), c("#BC9BFF","white","lightgreen","green3","green3" ))
sig_mat_cre <- results_or_cre %>% 
  as.data.frame() %>% 
  dplyr::select( Matrix_Name,Row_Compared,P_Value) %>% 
  pivot_wider(., id_cols = Matrix_Name, names_from = Row_Compared, values_from = P_Value) %>% 
  column_to_rownames("Matrix_Name") %>% 
  as.matrix() 


# results_or_cre %>% 
#   as.data.frame() %>% 
#   dplyr::select( Matrix_Name,Row_Compared,Odds_Ratio) %>% 
#   pivot_wider(., id_cols = Matrix_Name, names_from = Row_Compared, values_from = Odds_Ratio) %>% 
#   column_to_rownames("Matrix_Name") %>% 
#   as.matrix() %>% 
#   ComplexHeatmap::Heatmap(. ,col = col_fun_cre, 
#                           cluster_rows=FALSE, 
#                           cluster_columns=FALSE, 
#                           column_names_side = "top", 
#                           column_names_rot = 45,
#                           cell_fun = function(j, i, x, y, width, height, fill) {if (!is.na(sig_mat_cre[i, j]) && sig_mat_cre[i, j] < 0.05)
#             grid.text("*", x, y, gp = gpar(fontsize = 20))})

Now to adjust P-values BH style:

bot_df <- results_or_cre
top_df <- results_or


results_order <- top_df %>%
  rbind(bot_df) %>%
  mutate(Matrix_Name=factor(Matrix_Name,
                            levels=c("TE",
                                     "Sines",
                                     "Lines",
                                     "DNA","LTR",
                                     "Retro","CGI",
                                     "TSS","All cREs",
                                     "PLS","dELS","pELS",
                                     "CTCF"))) %>%
  arrange(Matrix_Name) %>%
  group_by(Row_Compared) %>%
  mutate(rank_val=rank(P_Value, ties.method = "first")) %>%
  mutate(BH_correction= p.adjust(P_Value,method= "BH")) %>%
  mutate(sig=P_Value<BH_correction) %>%
  mutate(Row_Compared=factor(Row_Compared,levels = c("EAR_open", "ESR_open", "LR_open","ESR_opcl",
                                                     "EAR_close","ESR_close","LR_close","ESR_clop")))

critical_value <- max(results_order$P_Value[results_order$sig])

col_fun_OR = colorRamp2(c(0,1,1.5,3,4), c("#BC9BFF","white","lightgreen","green3","green3" ))
sig_mat_OR <- results_order %>%
  as.data.frame() %>%
  dplyr::select( Matrix_Name,Row_Compared,BH_correction) %>%
  arrange(Matrix_Name) %>%
  pivot_wider(., id_cols = Matrix_Name, names_from = Row_Compared, values_from = BH_correction) %>%
  dplyr::select(Matrix_Name,EAR_open,ESR_open,LR_open,ESR_opcl,EAR_close,ESR_close,LR_close,ESR_clop) %>%
  column_to_rownames("Matrix_Name") %>%
  as.matrix()


results_mat <- results_order %>%
  as.data.frame() %>%
  dplyr::select( Matrix_Name,Row_Compared,Odds_Ratio) %>%
  arrange(Matrix_Name) %>%
  pivot_wider(., id_cols = Matrix_Name, names_from = Row_Compared, values_from = Odds_Ratio) %>%
  dplyr::select(Matrix_Name,EAR_open,ESR_open,LR_open,ESR_opcl,EAR_close,ESR_close,LR_close,ESR_clop) %>%
  column_to_rownames("Matrix_Name") %>%
  as.matrix()


#%>%
  ComplexHeatmap::Heatmap(results_mat ,col = col_fun_OR,
                          cluster_rows=FALSE,
                          cluster_columns=FALSE,
                          column_names_side = "top",
                          column_names_rot = 45,
                          # na_col = "black",
                          cell_fun = function(j, i, x, y, width, height, fill) {
                            if (!is.na(sig_mat_OR[i, j]) && sig_mat_OR[i, j] <0.05) {
                              grid.text("*", x, y, gp = gpar(fontsize = 20))  # Add star if significant
                            } })

Version Author Date
b735dc1 E. Renee Matthews 2025-02-24

Figure 2.B: SVAs (Retrotransposons in repeatmasker)

retroposon_repeats <- repeatmasker %>% 
  dplyr::filter(repClass == "Retroposon") %>% 
 makeGRangesFromDataFrame(., keep.extra.columns = TRUE, seqnames.field = "genoName", start.field = "genoStart", end.field = "genoEnd",starts.in.df.are.0based=TRUE)
retroposon_df <- retroposon_repeats %>% 
  as.data.frame() %>% 
  mutate(repName=factor(repName))

scale_fill_retroposons <-  function(...){
  ggplot2:::manual_scale(
    'fill', 
    values = setNames(c( "#8DD3C7",
                         "#FFFFB3",
                         "#BEBADA" ,
                         "#FB8072",
                         "#80B1D3",
                         "#FDB462",
                         "#B3DE69",
                         "#FCCDE5",
                         "#D9D9D9",
                         "#BC80BD",
                         "#CCEBC5",
                         "pink4",
                         "cornflowerblue",
                         "chocolate",
                         "brown",
                         "green",
                         "yellow4",
                         "purple",
                         "darkorchid4",
                         "coral4",
                         "darkolivegreen4",
                         "darkorange"), unique(retroposon_df$repName)), 
    ...
  )
}
h.genome_df <- repeatmasker %>% 
  mutate(repClass_org = repClass) %>% #copy repClass for storage
  mutate(repClass=if_else(##relable repClass with other
    repClass_org=="LINE", repClass_org,if_else(repClass_org=="SINE",repClass_org,if_else(repClass_org=="LTR", repClass_org, if_else(repClass_org=="DNA", repClass_org, if_else(repClass_org=="Retroposon",repClass_org,"Other")))))) %>% 
  mutate(Peakid=paste0(rownames(.),"_TE")) %>% 
  dplyr::select(Peakid,repName,repClass, repFamily,repClass_org) %>%
   mutate(TEstatus ="TE_peak", mrc="h.genome",per_ol = "NA", width="NA")

ggretroposon_df <-Nine_te_df %>%
  dplyr::filter(repClass=="Retroposon") %>%
  distinct(Peakid, TEstatus,repClass,.keep_all = TRUE) %>% 
  mutate(mrc="all_peaks")

h.genome_SVA <-h.genome_df %>%
  dplyr::filter(repClass=="Retroposon") %>% 
  rbind(., (ggretroposon_df %>% dplyr::select(Peakid:repFamily,width, mrc, per_ol,TEstatus,repClass_org))) %>% 
  rbind(., (Nine_te_df %>% 
  dplyr::filter(repClass=="Retroposon") %>% 
    dplyr::select(Peakid:repFamily,width, mrc, per_ol,TEstatus,repClass_org) %>% 
  dplyr::filter(mrc != "not_mrc")))%>% 
  mutate(repName=factor(repName)) %>% 
mutate(mrc=factor(mrc, levels = c("h.genome", "all_peaks", "EAR_open","ESR_open","LR_open","ESR_opcl", "EAR_close","ESR_close","LR_close","ESR_clop","NR"))) 


h.genome_SVA %>% 
  dplyr::filter(TEstatus=="TE_peak") %>% 
  ggplot(., aes(x=mrc, fill= repName))+
  geom_bar(position="fill", col="black")+
  theme_bw()+
  ggtitle("Repeat breakdown across response classes")+
  scale_fill_retroposons()

Version Author Date
b735dc1 E. Renee Matthews 2025-02-24

Figure 2.C: Gene elements distribution

# mylist_new <- list("EAR_open"=EAR_open_gr,
# "EAR_close"=EAR_close_gr,
# "ESR_open"=ESR_open_gr, 
# "ESR_close"=ESR_close_gr,
# "ESR_opcl"=ESR_opcl_gr,
# "ESR_clop"=ESR_clop_gr, 
# "LR_open"=LR_open_gr, 
# "LR_close"=LR_close_gr,
# "NR"=NR_gr, 
# "background"=background_gr)
#
# peakAnnoList<- lapply(mylist_new, annotatePeak, tssRegion =c(-2000,2000), TxDb= txdb)
# names(peakAnnoList) <- c("EAR_open", "EAR_close","ESR_open", "ESR_close","ESR_opcl","ESR_clop", "LR_open", "LR_close","NR","background")
# saveRDS(peakAnnoList, "data/Final_four_data/peakAnnoList_ff_9motif.RDS")
peakAnnoList_9_motif <- readRDS("data/Final_four_data/peakAnnoList_ff_9motif.RDS")


plotAnnoBar(peakAnnoList_9_motif[c(1,3,7,5,2,4,8,6,9)])+
  ggtitle ("Genomic Feature Distribution, nine groups")

Version Author Date
b735dc1 E. Renee Matthews 2025-02-24

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] grid      stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] ChIPseeker_1.42.1                       
 [2] epitools_0.5-10.1                       
 [3] circlize_0.4.16                         
 [4] readxl_1.4.5                            
 [5] smplot2_0.2.5                           
 [6] cowplot_1.1.3                           
 [7] ComplexHeatmap_2.22.0                   
 [8] ggrepel_0.9.6                           
 [9] plyranges_1.26.0                        
[10] ggsignif_0.6.4                          
[11] genomation_1.38.0                       
[12] ggpubr_0.6.0                            
[13] BiocParallel_1.40.0                     
[14] scales_1.3.0                            
[15] gridExtra_2.3                           
[16] ggfortify_0.4.17                        
[17] rtracklayer_1.66.0                      
[18] org.Hs.eg.db_3.20.0                     
[19] TxDb.Hsapiens.UCSC.hg38.knownGene_3.20.0
[20] GenomicFeatures_1.58.0                  
[21] AnnotationDbi_1.68.0                    
[22] Biobase_2.66.0                          
[23] GenomicRanges_1.58.0                    
[24] GenomeInfoDb_1.42.3                     
[25] IRanges_2.40.1                          
[26] S4Vectors_0.44.0                        
[27] BiocGenerics_0.52.0                     
[28] RColorBrewer_1.1-3                      
[29] broom_1.0.7                             
[30] kableExtra_1.4.0                        
[31] lubridate_1.9.4                         
[32] forcats_1.0.0                           
[33] stringr_1.5.1                           
[34] dplyr_1.1.4                             
[35] purrr_1.0.4                             
[36] readr_2.1.5                             
[37] tidyr_1.3.1                             
[38] tibble_3.2.1                            
[39] ggplot2_3.5.1                           
[40] tidyverse_2.0.0                         
[41] workflowr_1.7.1                         

loaded via a namespace (and not attached):
  [1] fs_1.6.5                               
  [2] matrixStats_1.5.0                      
  [3] bitops_1.0-9                           
  [4] enrichplot_1.26.6                      
  [5] httr_1.4.7                             
  [6] doParallel_1.0.17                      
  [7] tools_4.4.2                            
  [8] backports_1.5.0                        
  [9] R6_2.6.1                               
 [10] lazyeval_0.2.2                         
 [11] GetoptLong_1.0.5                       
 [12] withr_3.0.2                            
 [13] cli_3.6.4                              
 [14] labeling_0.4.3                         
 [15] sass_0.4.9                             
 [16] Rsamtools_2.22.0                       
 [17] systemfonts_1.2.1                      
 [18] yulab.utils_0.2.0                      
 [19] foreign_0.8-88                         
 [20] DOSE_4.0.0                             
 [21] svglite_2.1.3                          
 [22] R.utils_2.13.0                         
 [23] plotrix_3.8-4                          
 [24] BSgenome_1.74.0                        
 [25] pwr_1.3-0                              
 [26] rstudioapi_0.17.1                      
 [27] impute_1.80.0                          
 [28] RSQLite_2.3.9                          
 [29] generics_0.1.3                         
 [30] gridGraphics_0.5-1                     
 [31] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
 [32] shape_1.4.6.1                          
 [33] BiocIO_1.16.0                          
 [34] gtools_3.9.5                           
 [35] vroom_1.6.5                            
 [36] car_3.1-3                              
 [37] GO.db_3.20.0                           
 [38] Matrix_1.7-3                           
 [39] abind_1.4-8                            
 [40] R.methodsS3_1.8.2                      
 [41] lifecycle_1.0.4                        
 [42] whisker_0.4.1                          
 [43] yaml_2.3.10                            
 [44] carData_3.0-5                          
 [45] SummarizedExperiment_1.36.0            
 [46] gplots_3.2.0                           
 [47] qvalue_2.38.0                          
 [48] SparseArray_1.6.2                      
 [49] blob_1.2.4                             
 [50] promises_1.3.2                         
 [51] crayon_1.5.3                           
 [52] ggtangle_0.0.6                         
 [53] lattice_0.22-6                         
 [54] KEGGREST_1.46.0                        
 [55] magick_2.8.5                           
 [56] pillar_1.10.1                          
 [57] knitr_1.49                             
 [58] fgsea_1.32.2                           
 [59] rjson_0.2.23                           
 [60] boot_1.3-31                            
 [61] codetools_0.2-20                       
 [62] fastmatch_1.1-6                        
 [63] glue_1.8.0                             
 [64] getPass_0.2-4                          
 [65] ggfun_0.1.8                            
 [66] data.table_1.17.0                      
 [67] vctrs_0.6.5                            
 [68] png_0.1-8                              
 [69] treeio_1.30.0                          
 [70] cellranger_1.1.0                       
 [71] gtable_0.3.6                           
 [72] cachem_1.1.0                           
 [73] xfun_0.51                              
 [74] S4Arrays_1.6.0                         
 [75] iterators_1.0.14                       
 [76] nlme_3.1-167                           
 [77] ggtree_3.14.0                          
 [78] bit64_4.6.0-1                          
 [79] rprojroot_2.0.4                        
 [80] bslib_0.9.0                            
 [81] KernSmooth_2.23-26                     
 [82] rpart_4.1.24                           
 [83] colorspace_2.1-1                       
 [84] DBI_1.2.3                              
 [85] Hmisc_5.2-2                            
 [86] seqPattern_1.38.0                      
 [87] nnet_7.3-20                            
 [88] tidyselect_1.2.1                       
 [89] processx_3.8.6                         
 [90] bit_4.6.0                              
 [91] compiler_4.4.2                         
 [92] curl_6.2.1                             
 [93] git2r_0.35.0                           
 [94] htmlTable_2.4.3                        
 [95] xml2_1.3.7                             
 [96] DelayedArray_0.32.0                    
 [97] caTools_1.18.3                         
 [98] checkmate_2.3.2                        
 [99] callr_3.7.6                            
[100] digest_0.6.37                          
[101] rmarkdown_2.29                         
[102] XVector_0.46.0                         
[103] htmltools_0.5.8.1                      
[104] pkgconfig_2.0.3                        
[105] base64enc_0.1-3                        
[106] MatrixGenerics_1.18.1                  
[107] fastmap_1.2.0                          
[108] rlang_1.1.5                            
[109] GlobalOptions_0.1.2                    
[110] htmlwidgets_1.6.4                      
[111] UCSC.utils_1.2.0                       
[112] farver_2.1.2                           
[113] jquerylib_0.1.4                        
[114] zoo_1.8-13                             
[115] jsonlite_1.9.1                         
[116] GOSemSim_2.32.0                        
[117] R.oo_1.27.0                            
[118] RCurl_1.98-1.16                        
[119] magrittr_2.0.3                         
[120] Formula_1.2-5                          
[121] GenomeInfoDbData_1.2.13                
[122] ggplotify_0.1.2                        
[123] patchwork_1.3.0                        
[124] munsell_0.5.1                          
[125] Rcpp_1.0.14                            
[126] ape_5.8-1                              
[127] stringi_1.8.4                          
[128] zlibbioc_1.52.0                        
[129] plyr_1.8.9                             
[130] parallel_4.4.2                         
[131] Biostrings_2.74.1                      
[132] splines_4.4.2                          
[133] hms_1.1.3                              
[134] ps_1.9.0                               
[135] igraph_2.1.4                           
[136] reshape2_1.4.4                         
[137] XML_3.99-0.18                          
[138] evaluate_1.0.3                         
[139] tzdb_0.4.0                             
[140] foreach_1.5.2                          
[141] httpuv_1.6.15                          
[142] clue_0.3-66                            
[143] gridBase_0.4-7                         
[144] restfulr_0.0.15                        
[145] tidytree_0.4.6                         
[146] rstatix_0.7.2                          
[147] later_1.4.1                            
[148] viridisLite_0.4.2                      
[149] aplot_0.2.5                            
[150] memoise_2.0.1                          
[151] GenomicAlignments_1.42.0               
[152] cluster_2.1.8.1                        
[153] timechange_0.3.0