Last updated: 2025-08-10

Checks: 6 1

Knit directory: Paul_CX_2025/

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.


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

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(20250129) 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 5f3b560. 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:    0.1 box.svg
    Ignored:    Rplot04.svg

Untracked files:
    Untracked:  analysis/Figure_S9.Rmd
    Untracked:  volcano_CX_0.1_24.png
    Untracked:  volcano_CX_0.1_3.png
    Untracked:  volcano_CX_0.1_48.png
    Untracked:  volcano_CX_0.5_24.png
    Untracked:  volcano_CX_0.5_3.png
    Untracked:  volcano_CX_0.5_48.png
    Untracked:  volcano_DOX_0.1_24.png
    Untracked:  volcano_DOX_0.1_3.png
    Untracked:  volcano_DOX_0.1_48.png
    Untracked:  volcano_DOX_0.5_24.png
    Untracked:  volcano_DOX_0.5_3.png
    Untracked:  volcano_DOX_0.5_48.png

Unstaged changes:
    Modified:   analysis/index.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.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


📌 Differential Gene Expression Analysis

📌 Load Required Libraries

# Load necessary packages
library(edgeR)
Warning: package 'edgeR' was built under R version 4.3.2
Warning: package 'limma' was built under R version 4.3.1
library(limma)
library(data.table)
Warning: package 'data.table' was built under R version 4.3.3
library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.3.2
Warning: package 'tidyr' was built under R version 4.3.3
Warning: package 'readr' was built under R version 4.3.3
Warning: package 'purrr' was built under R version 4.3.3
Warning: package 'dplyr' was built under R version 4.3.2
Warning: package 'stringr' was built under R version 4.3.2
Warning: package 'lubridate' was built under R version 4.3.3
library(ggplot2)
library(dplyr)
library(scales)
Warning: package 'scales' was built under R version 4.3.2
library(biomaRt)
Warning: package 'biomaRt' was built under R version 4.3.2
library(Homo.sapiens)
Warning: package 'AnnotationDbi' was built under R version 4.3.2
Warning: package 'BiocGenerics' was built under R version 4.3.1
Warning: package 'Biobase' was built under R version 4.3.1
Warning: package 'IRanges' was built under R version 4.3.1
Warning: package 'S4Vectors' was built under R version 4.3.2
Warning: package 'OrganismDbi' was built under R version 4.3.1
Warning: package 'GenomicFeatures' was built under R version 4.3.3
Warning: package 'GenomeInfoDb' was built under R version 4.3.3
Warning: package 'GenomicRanges' was built under R version 4.3.1

📌 Volcano Plots for Differential Expression Analysis

library(ggplot2)

# Function to generate volcano plot with counts in legend
generate_volcano_plot <- function(toptable, title) {
  
  # Annotate significance
  toptable$Significance <- "Not Significant"
  toptable$Significance[toptable$logFC > 0 & toptable$adj.P.Val < 0.05] <- "Upregulated"
  toptable$Significance[toptable$logFC < 0 & toptable$adj.P.Val < 0.05] <- "Downregulated"
  
  # Count per category
  count_table <- table(toptable$Significance)
  up_count <- count_table["Upregulated"]
  down_count <- count_table["Downregulated"]
  ns_count <- count_table["Not Significant"]
  
  # Handle missing counts
  if (is.na(up_count)) up_count <- 0
  if (is.na(down_count)) down_count <- 0
  if (is.na(ns_count)) ns_count <- 0
  
  # Labels with counts
  custom_labels <- c(
    paste0("Downregulated (", down_count, ")"),
    paste0("Not Significant (", ns_count, ")"),
    paste0("Upregulated (", up_count, ")")
  )
  names(custom_labels) <- c("Downregulated", "Not Significant", "Upregulated")
  
  # Plot
  ggplot(toptable, aes(x = logFC, y = -log10(P.Value), color = Significance)) +
    geom_point(alpha = 0.4, size = 2) +
    scale_color_manual(
      values = c(
        "Downregulated" = "red",
        "Upregulated" = "blue",
        "Not Significant" = "gray"
      ),
      labels = custom_labels
    ) +
    xlim(-5, 5) +
    labs(
      title = title,
      x = "log2 Fold Change",
      y = "-log10 P-value",
      color = "Gene Status"
    ) +
    theme_bw() +
    theme(
      legend.position = "right",
      plot.title = element_text(size = rel(1.5), hjust = 0.5),
      axis.title = element_text(size = rel(1.25)),
      legend.title = element_text(size = 11, face = "bold"),
      legend.text = element_text(size = 10)
    )
}

# Load all Toptable CSV files
deg_files <- list.files("data/DEGs/", pattern = "^Toptable_.*\\.csv$", full.names = TRUE)

# Loop through files and show plots
for (file in deg_files) {
  df <- read.csv(file)
  plot_title <- gsub("^Toptable_|\\.csv$", "", basename(file))
  p <- generate_volcano_plot(df, paste("Volcano Plot:", plot_title))
  print(p)
}

Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 34 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 28 rows containing missing values or values outside the scale range
(`geom_point()`).

Warning: Removed 24 rows containing missing values or values outside the scale range
(`geom_point()`).


sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 26100)

Matrix products: default


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

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
 [1] Homo.sapiens_1.3.1                     
 [2] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
 [3] org.Hs.eg.db_3.18.0                    
 [4] GO.db_3.18.0                           
 [5] OrganismDbi_1.44.0                     
 [6] GenomicFeatures_1.54.4                 
 [7] GenomicRanges_1.54.1                   
 [8] GenomeInfoDb_1.38.8                    
 [9] AnnotationDbi_1.64.1                   
[10] IRanges_2.36.0                         
[11] S4Vectors_0.40.2                       
[12] Biobase_2.62.0                         
[13] BiocGenerics_0.48.1                    
[14] biomaRt_2.58.2                         
[15] scales_1.3.0                           
[16] lubridate_1.9.4                        
[17] forcats_1.0.0                          
[18] stringr_1.5.1                          
[19] dplyr_1.1.4                            
[20] purrr_1.0.4                            
[21] readr_2.1.5                            
[22] tidyr_1.3.1                            
[23] tibble_3.2.1                           
[24] ggplot2_3.5.2                          
[25] tidyverse_2.0.0                        
[26] data.table_1.17.0                      
[27] edgeR_4.0.16                           
[28] limma_3.58.1                           

loaded via a namespace (and not attached):
 [1] DBI_1.2.3                   bitops_1.0-9               
 [3] RBGL_1.78.0                 rlang_1.1.3                
 [5] magrittr_2.0.3              git2r_0.36.2               
 [7] matrixStats_1.5.0           compiler_4.3.0             
 [9] RSQLite_2.3.9               png_0.1-8                  
[11] vctrs_0.6.5                 pkgconfig_2.0.3            
[13] crayon_1.5.3                fastmap_1.2.0              
[15] dbplyr_2.5.0                XVector_0.42.0             
[17] labeling_0.4.3              Rsamtools_2.18.0           
[19] promises_1.3.2              rmarkdown_2.29             
[21] tzdb_0.5.0                  graph_1.80.0               
[23] bit_4.6.0                   xfun_0.52                  
[25] zlibbioc_1.48.2             cachem_1.1.0               
[27] jsonlite_2.0.0              progress_1.2.3             
[29] blob_1.2.4                  later_1.3.2                
[31] DelayedArray_0.28.0         BiocParallel_1.36.0        
[33] parallel_4.3.0              prettyunits_1.2.0          
[35] R6_2.6.1                    bslib_0.9.0                
[37] stringi_1.8.3               rtracklayer_1.62.0         
[39] jquerylib_0.1.4             Rcpp_1.0.12                
[41] SummarizedExperiment_1.32.0 knitr_1.50                 
[43] Matrix_1.6-1.1              httpuv_1.6.15              
[45] timechange_0.3.0            tidyselect_1.2.1           
[47] abind_1.4-8                 rstudioapi_0.17.1          
[49] yaml_2.3.10                 codetools_0.2-20           
[51] curl_6.2.2                  lattice_0.22-7             
[53] withr_3.0.2                 KEGGREST_1.42.0            
[55] evaluate_1.0.3              BiocFileCache_2.10.2       
[57] xml2_1.3.8                  Biostrings_2.70.3          
[59] BiocManager_1.30.25         pillar_1.10.2              
[61] filelock_1.0.3              MatrixGenerics_1.14.0      
[63] generics_0.1.3              rprojroot_2.0.4            
[65] RCurl_1.98-1.17             hms_1.1.3                  
[67] munsell_0.5.1               glue_1.7.0                 
[69] tools_4.3.0                 BiocIO_1.12.0              
[71] locfit_1.5-9.12             GenomicAlignments_1.38.2   
[73] fs_1.6.3                    XML_3.99-0.18              
[75] grid_4.3.0                  colorspace_2.1-0           
[77] GenomeInfoDbData_1.2.11     restfulr_0.0.15            
[79] cli_3.6.1                   rappdirs_0.3.3             
[81] workflowr_1.7.1             S4Arrays_1.2.1             
[83] gtable_0.3.6                sass_0.4.10                
[85] digest_0.6.34               SparseArray_1.2.4          
[87] farver_2.1.2                rjson_0.2.23               
[89] memoise_2.0.1               htmltools_0.5.8.1          
[91] lifecycle_1.0.4             httr_1.4.7                 
[93] statmod_1.5.0               bit64_4.6.0-1