R/homer_master.R

Defines functions homer_master

homer_master <- function(
  motifs = universalmotif::read_homer("/Users/TedCCLeung/Documents/Projects/Packages/all.8.motif"),
  dir = "/Users/TedCCLeung/Documents/Projects/Photoperiod/2_analysis/2_pipeline/PhotoperiodMotif/homer_08/"
){

  df_summary <- input_homer(dir)
  utils::write.table(df_summary, paste0(dir, "summary_table.tsv"), sep = "\t", quote = FALSE, row.names = FALSE)

  heatmap_list <- process_homer_matrix(
    dir = "/Users/TedCCLeung/Documents/Projects/Photoperiod/2_analysis/2_pipeline/PhotoperiodMotif/homer_08/",
    df_result = df_summary,
    motifs = motifs,
    pval_threshold = 1e-4,
    cutree_height = 0.5
  )

  grDevices::pdf(paste0(dir, "heatmap_PVAL.pdf"))
  ComplexHeatmap::draw(heatmap_list$heatmap_PVAL)
  grDevices::dev.off()

  grDevices::pdf(paste0(dir, "heatmap_FDR.pdf"))
  ComplexHeatmap::draw(heatmap_list$heatmap_FDR)
  grDevices::dev.off()

  grDevices::pdf(paste0(dir, "heatmap_FC.pdf"))
  ComplexHeatmap::draw(heatmap_list$heatmap_FC)
  grDevices::dev.off()
}
TedCCLeung/PhotoperiodMotif documentation built on April 27, 2022, 9:01 p.m.