Last updated: 2025-07-02

Checks: 7 0

Knit directory: WardLab/

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 2902c7e. 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/

Untracked files:
    Untracked:  data/multiqc_data_trim/
    Untracked:  data/sample_info.tsv

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/multiQC_cut_tag.Rmd) and HTML (docs/multiQC_cut_tag.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 40eefb9 infurnoheat 2025-07-02 Build site.
html 88a419f infurnoheat 2025-07-02 Build site.
Rmd ca7a59c infurnoheat 2025-07-02 wflow_publish("analysis/multiQC_cut_tag.Rmd")
html 0644589 infurnoheat 2025-07-02 Build site.
Rmd 59eb78f infurnoheat 2025-07-02 wflow_publish("analysis/multiQC_cut_tag.Rmd")

Cut And Tag QC

Bioconductor

if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install()

Loading Packages

library(tidyverse)
library(readr)
library(kableExtra)
library(DT)
library(edgeR)
library(ComplexHeatmap)
library(data.table)
library(genomation)
library(GenomicRanges)

Data Initialization

sampleinfo <- read_delim("data/sample_info.tsv", delim = "\t")
multiqc_gene_stats_trim <- read_delim("data/multiqc_data_trim/multiqc_general_stats.txt",delim = "\t")
multiqc_fastqc_trim <- read_delim("data/multiqc_data_trim/multiqc_fastqc.txt",delim = "\t")

Functions

drug_pal <- c("#8B006D","#DF707E","#F1B72B", "#3386DD","#707031","#41B333")
pca_plot <-
  function(df,
           col_var = NULL,
           shape_var = NULL,
           title = "") {
    ggplot(df) + geom_point(aes_string(
      x = "PC1",
      y = "PC2",
      color = col_var,
      shape = shape_var
    ),
    size = 5) +
      labs(title = title, x = "PC 1", y = "PC 2") +
      scale_color_manual(values = c(
        "#8B006D",
        "#DF707E",
        "#F1B72B",
        "#3386DD",
        "#707031",
        "#41B333"
      ))
  }
pca_var_plot <- function(pca) {
  # x: class == prcomp
  pca.var <- pca$sdev ^ 2
  pca.prop <- pca.var / sum(pca.var)
  var.plot <-
    qplot(PC, prop, data = data.frame(PC = 1:length(pca.prop),
                                      prop = pca.prop)) +
    labs(title = 'Variance contributed by each PC',
         x = 'PC', y = 'Proportion of variance')
  plot(var.plot)
}

calc_pca <- function(x) {
  # Performs principal components analysis with prcomp
  # x: a sample-by-gene numeric matrix
  prcomp(x, scale. = TRUE, retx = TRUE)
}

get_regr_pval <- function(mod) {
  # Returns the p-value for the Fstatistic of a linear model
  # mod: class lm
  stopifnot(class(mod) == "lm")
  fstat <- summary(mod)$fstatistic
  pval <- 1 - pf(fstat[1], fstat[2], fstat[3])
  return(pval)
}

plot_versus_pc <- function(df, pc_num, fac) {
  # df: data.frame
  # pc_num: numeric, specific PC for plotting
  # fac: column name of df for plotting against PC
  pc_char <- paste0("PC", pc_num)
  # Calculate F-statistic p-value for linear model
  pval <- get_regr_pval(lm(df[, pc_char] ~ df[, fac]))
  if (is.numeric(df[, f])) {
    ggplot(df, aes_string(x = f, y = pc_char)) + geom_point() +
      geom_smooth(method = "lm") + labs(title = sprintf("p-val: %.2f", pval))
  } else {
    ggplot(df, aes_string(x = f, y = pc_char)) + geom_boxplot() +
      labs(title = sprintf("p-val: %.2f", pval))
  }
}
x_axis_labels = function(labels, every_nth = 1, ...) {
  axis(side = 1,
       at = seq_along(labels),
       labels = F)
  text(
    x = (seq_along(labels))[seq_len(every_nth) == 1],
    y = par("usr")[3] - 0.075 * (par("usr")[4] - par("usr")[3]),
    labels = labels[seq_len(every_nth) == 1],
    xpd = TRUE,
    ...
  )
}

Analysis

Data Processing

combo_trim_df <- multiqc_fastqc_trim %>% 
 extract(., Sample, into = c("prefix","read"), regex= "(.+)_R(\\d+)", remove=FALSE) %>% 
  mutate(read = paste0("R", read)) %>% 
  left_join(., sampleinfo, by =c("prefix"="Library ID")) %>% 
  left_join(., multiqc_gene_stats_trim, by = c("Sample" = "Sample")) %>% 
  mutate(ind=factor(Individual, levels = c("1","2","3","4","5"))) %>% 
  mutate(trt=factor(Treatment, levels = c("VEH","5FU","DOX"))) %>% 
  mutate(time=factor(Timepoint, levels=c("24T","24R","144R")))
combo_trim_df <- combo_trim_df[(!combo_trim_df$trt %in% "5FU"),]

Data Visualization

combo_trim_df %>% 
  dplyr::filter(read=="R1") %>% 
  group_by(trt, time, Histone_Mark) %>% 
  tally() %>% 
  ggplot(., aes(x = time, y= n))+
  geom_col(position="dodge",aes(fill=trt)) + 
  facet_wrap(~Histone_Mark)+
  theme(axis.text.x=element_text(angle=90))+
  ylab("number of samples")+
  ggtitle("Breakdown of samples by mark and trt-time")

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  dplyr::filter(read=="R1") %>% 
  group_by(trt,time,Histone_Mark) %>% 
  tally() %>% 
  pivot_wider(., id_cols=c(trt,time), names_from = Histone_Mark, values_from = n) %>% 
  kable(.,caption = ("Sample counts")) %>% 
  kable_paper("striped", full_width = FALSE) %>%
  kable_styling(full_width = FALSE,font_size = 16) %>%
  scroll_box(width = "100%", height = "500px")
Sample counts
trt time H3K27ac H3K27me3 H3K36me3 H3K9me3
VEH 24T 4 5 4 5
VEH 24R 6 5 5 5
VEH 144R 5 5 5 5
DOX 24T 5 5 4 5
DOX 24R 5 5 5 4
DOX 144R 5 4 5 5

Visualization of Counts

combo_trim_df %>% 
  dplyr::filter(read=="R1") %>% 
  ggplot(., aes(x = Sample, y= `Total Sequences`))+
  geom_col(aes(fill=Histone_Mark)) + 
  theme(axis.text.x=element_text(vjust = .2,angle=90))+
  ylab("sequene count")+
  ggtitle("Read counts by sample and histone mark trimmed adapters")+
  scale_y_continuous( expand = expansion(mult = c(0, .1)))

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  dplyr::filter(read=="R1") %>% 
   ggplot(., aes(x = Histone_Mark, y= `Total Sequences`))+
geom_boxplot(aes(fill=Histone_Mark)) + 
    geom_point(aes(color=ind))+
  facet_wrap(trt~time)+
  ylab("count")+
  theme(axis.text.x=element_text(vjust = .2,angle=90))+
  ggtitle("Sequence count by trt and time trimmed adapter")

Version Author Date
0644589 infurnoheat 2025-07-02

Trim Info

combo_trim_df %>% 
  ggplot(., aes(x = read, y= avg_sequence_length))+
geom_boxplot(aes(fill=read))

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  ggplot(., aes(x = read, y= avg_sequence_length))+
geom_boxplot(aes(fill=Histone_Mark)) +
  ggtitle("Boxplot of trim read length across histone marks")

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  datatable(., options = list(scrollX = TRUE, 
                              scrollY = "400px",
                              scrollCollapse = TRUE,
                              fixedColumns = list(leftColumns =2),
                              fixedHeader= TRUE),
            extensions = c("FixedColumns","Scroller"),
            class = "display")
combo_trim_df %>% 
  dplyr::filter(read=="R1") %>% 
  ggplot(., aes(x = Sample, y= avg_sequence_length))+
geom_col(aes(fill=Histone_Mark)) +
  geom_hline( yintercept = 75)+
  theme_classic()+
  ggtitle("Graph of average read length across R1 samples")+ theme(axis.text.x=element_text(vjust = .2,angle=90))+
  scale_y_continuous( expand = expansion(mult = c(0, .1)))

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  dplyr::filter(read=="R2") %>% 
  ggplot(., aes(x = Sample, y= avg_sequence_length))+
geom_col(aes(fill=Histone_Mark)) +
  geom_hline( yintercept = 75)+
  theme_classic()+
  ggtitle("Graph of average read length across R2 samples")+ theme(axis.text.x=element_text(vjust = .2,angle=90))+
  scale_y_continuous( expand = expansion(mult = c(0, .1)))

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  dplyr::filter(read=="R1") %>% 
  ggplot(., aes(x = Sample, y= `%GC`))+
  geom_col(aes(fill=Histone_Mark)) +
  theme_classic()+
  ggtitle("Graph of %GC for R1 trimmed")+ 
  theme(axis.text.x=element_text(vjust = .2,angle=90))+
  scale_y_continuous( expand = expansion(mult = c(0, .1)))

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  dplyr::filter(read=="R2") %>% 
  ggplot(., aes(x = Sample, y= `%GC`))+
  geom_col(aes(fill=Histone_Mark)) +
  theme_classic()+
  ggtitle("Graph of %GC for R2 trimmed")+ 
  theme(axis.text.x=element_text(vjust = .2,angle=90))+
  scale_y_continuous( expand = expansion(mult = c(0, .1)))

Version Author Date
0644589 infurnoheat 2025-07-02

Duplication Info

combo_trim_df %>% 
  dplyr::filter(read=="R1") %>% 
  ggplot(., aes(x = Histone_Mark, y= `FastQC_mqc-generalstats-fastqc-percent_duplicates`))+
  geom_boxplot(aes(fill=Histone_Mark)) + 
    geom_point(aes(color=ind))+
  facet_wrap(trt~time)+
  ylab("percent duplication")+
  theme(axis.text.x=element_text(angle=90))+
  ggtitle("Duplication percentage (R1 trimmed)")

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  dplyr::filter(read=="R1") %>% 
  ggplot(., aes(x = interaction(time,trt), y= `FastQC_mqc-generalstats-fastqc-percent_duplicates`))+
  geom_boxplot(aes(fill=Histone_Mark)) + 
  geom_point(aes(color=ind))+
facet_wrap(~Histone_Mark)+
  ylab("percent duplication")+
  theme(axis.text.x=element_text(angle=90))+
  ggtitle("Duplication percentage (R1 trimmed)")

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  dplyr::filter(read=="R1") %>% 
  ggplot(., aes(x = Sample, y= `FastQC_mqc-generalstats-fastqc-percent_duplicates`))+
  geom_col(aes(fill=Histone_Mark)) +
  theme_classic()+
  ggtitle("Graph of percent duplicates for R1 trimmed")+ 
  theme(axis.text.x=element_text(vjust = .2,angle=90))+
  scale_y_continuous( limits = c(0,100),expand = expansion(mult = c(0, .1)))

Version Author Date
0644589 infurnoheat 2025-07-02
combo_trim_df %>% 
  dplyr::filter(read=="R2") %>% 
  ggplot(., aes(x = Sample, y= `FastQC_mqc-generalstats-fastqc-percent_duplicates`))+
  geom_col(aes(fill=Histone_Mark)) +
  theme_classic()+
  ggtitle("Graph of percent duplicates for R2 trimmed")+ 
  theme(axis.text.x=element_text(vjust = .2,angle=90))+
  scale_y_continuous(limits = c(0,100), expand = expansion(mult = c(0, .1)))

Version Author Date
0644589 infurnoheat 2025-07-02

sessionInfo()
R version 4.5.1 (2025-06-13 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)

Matrix products: default
  LAPACK version 3.12.1

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] GenomicRanges_1.60.0  GenomeInfoDb_1.44.0   IRanges_2.42.0       
 [4] S4Vectors_0.46.0      BiocGenerics_0.54.0   generics_0.1.4       
 [7] genomation_1.40.1     data.table_1.17.6     ComplexHeatmap_2.24.1
[10] edgeR_4.6.2           limma_3.64.1          DT_0.33              
[13] kableExtra_1.4.0      lubridate_1.9.4       forcats_1.0.0        
[16] stringr_1.5.1         dplyr_1.1.4           purrr_1.0.4          
[19] readr_2.1.5           tidyr_1.3.1           tibble_3.3.0         
[22] ggplot2_3.5.2         tidyverse_2.0.0       BiocManager_1.30.26  
[25] workflowr_1.7.1      

loaded via a namespace (and not attached):
  [1] bitops_1.0-9                rlang_1.1.6                
  [3] magrittr_2.0.3              gridBase_0.4-7             
  [5] clue_0.3-66                 GetoptLong_1.0.5           
  [7] git2r_0.36.2                matrixStats_1.5.0          
  [9] compiler_4.5.1              getPass_0.2-4              
 [11] reshape2_1.4.4              png_0.1-8                  
 [13] systemfonts_1.2.3           callr_3.7.6                
 [15] vctrs_0.6.5                 pkgconfig_2.0.3            
 [17] shape_1.4.6.1               crayon_1.5.3               
 [19] fastmap_1.2.0               XVector_0.48.0             
 [21] labeling_0.4.3              Rsamtools_2.24.0           
 [23] promises_1.3.3              rmarkdown_2.29             
 [25] tzdb_0.5.0                  UCSC.utils_1.4.0           
 [27] ps_1.9.1                    bit_4.6.0                  
 [29] xfun_0.52                   cachem_1.1.0               
 [31] jsonlite_2.0.0              later_1.4.2                
 [33] DelayedArray_0.34.1         BiocParallel_1.42.1        
 [35] parallel_4.5.1              cluster_2.1.8.1            
 [37] R6_2.6.1                    bslib_0.9.0                
 [39] stringi_1.8.7               RColorBrewer_1.1-3         
 [41] rtracklayer_1.68.0          jquerylib_0.1.4            
 [43] SummarizedExperiment_1.38.1 Rcpp_1.0.14                
 [45] iterators_1.0.14            knitr_1.50                 
 [47] Matrix_1.7-3                httpuv_1.6.16              
 [49] timechange_0.3.0            tidyselect_1.2.1           
 [51] seqPattern_1.40.0           abind_1.4-8                
 [53] rstudioapi_0.17.1           yaml_2.3.10                
 [55] doParallel_1.0.17           codetools_0.2-20           
 [57] curl_6.4.0                  processx_3.8.6             
 [59] plyr_1.8.9                  lattice_0.22-7             
 [61] Biobase_2.68.0              withr_3.0.2                
 [63] evaluate_1.0.4              xml2_1.3.8                 
 [65] circlize_0.4.16             Biostrings_2.76.0          
 [67] pillar_1.10.2               MatrixGenerics_1.20.0      
 [69] KernSmooth_2.23-26          whisker_0.4.1              
 [71] foreach_1.5.2               vroom_1.6.5                
 [73] RCurl_1.98-1.17             rprojroot_2.0.4            
 [75] hms_1.1.3                   scales_1.4.0               
 [77] glue_1.8.0                  tools_4.5.1                
 [79] BiocIO_1.18.0               GenomicAlignments_1.44.0   
 [81] BSgenome_1.76.0             locfit_1.5-9.12            
 [83] fs_1.6.6                    XML_3.99-0.18              
 [85] plotrix_3.8-4               impute_1.82.0              
 [87] crosstalk_1.2.1             colorspace_2.1-1           
 [89] GenomeInfoDbData_1.2.14     restfulr_0.0.16            
 [91] cli_3.6.5                   textshaping_1.0.1          
 [93] S4Arrays_1.8.1              viridisLite_0.4.2          
 [95] svglite_2.2.1               gtable_0.3.6               
 [97] sass_0.4.10                 digest_0.6.37              
 [99] SparseArray_1.8.0           rjson_0.2.23               
[101] htmlwidgets_1.6.4           farver_2.1.2               
[103] htmltools_0.5.8.1           lifecycle_1.0.4            
[105] httr_1.4.7                  GlobalOptions_0.1.2        
[107] statmod_1.5.0               bit64_4.6.0-1