Last updated: 2025-08-13

Checks: 7 0

Knit directory: Tutorials/

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(20240905) 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 cd0328c. 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:    .DS_Store
    Ignored:    .RData
    Ignored:    .Rhistory
    Ignored:    data/.DS_Store

Unstaged changes:
    Modified:   output/Table.csv

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/TCGA.Rmd) and HTML (docs/TCGA.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 cd0328c tkcaccia 2025-08-13 Start my new project
html 9cf9cd7 tkcaccia 2025-08-13 Build site.
Rmd 4b3560f tkcaccia 2025-08-13 Start my new project
html 90b4df3 tkcaccia 2025-08-13 Build site.
Rmd 7c69523 tkcaccia 2025-08-13 Start my new project
html 36cba68 tkcaccia 2025-08-13 Build site.
Rmd 182c322 tkcaccia 2025-08-13 Start my new project
html cbadb19 tkcaccia 2025-08-13 Build site.
html 5c88776 tkcaccia 2025-02-18 Build site.
html 5baa04e tkcaccia 2025-02-17 Build site.
html f26aafb tkcaccia 2025-02-17 Build site.
html 1ce3cb4 tkcaccia 2025-02-16 Build site.
html 681ec51 tkcaccia 2025-02-16 Build site.
Rmd fa7cd0a tkcaccia 2024-10-10 updates
html fa7cd0a tkcaccia 2024-10-10 updates
html 9558051 tkcaccia 2024-09-18 update
html a7f82c5 tkcaccia 2024-09-18 Build site.
Rmd cbb2736 tkcaccia 2024-09-18 Start my new project

RNAseq Analysis:

Analysing RNAseq Gene Expression Data from a Colerectal Adenocarcinoma Cohort:

# install.packages("readxl")
library(readxl)
library(KODAMA)

Prepare Clinical Data:

# Read in Clinical Data:
coad=read.csv("../Data/TCGA/COAD.clin.merged.picked.txt",sep="\t",check.names = FALSE, row.names = 1)

coad <- as.data.frame(coad) 

# Clean column names: replace dots with dashes & convert to uppercase
colnames(coad) = toupper(colnames(coad))

 # Transpose the dataframe so that rows become columns and vice versa
coad = t(coad) 

Prepare RNA-seq expression data:

# Read RNA-seq expression data:
r = read.csv("../Data/TCGA/COAD.rnaseqv2__illuminaga_rnaseqv2__unc_edu__Level_3__RSEM_genes_normalized__data.data.txt", sep = "\t", check.names = FALSE, row.names = 1)
# Remove the first row:
r = r[-1,]
# Convert expression data to numeric matrix format
temp = matrix(as.numeric(as.matrix(r)), ncol=ncol(r))
colnames(temp) = colnames(r)  
rownames(temp) = rownames(r)  
RNA = temp  

# Transpose the matrix so that genes are rows and samples are columns
RNA = t(RNA)  

Extract patient and tissue information from column names:

tcgaID = list()
 # Extract sample ID
tcgaID$sample.ID <- substr(colnames(r), 1, 16)
# Extract patient ID
tcgaID$patient <- substr(colnames(r), 1, 12)  
# Extract tissue type
tcgaID$tissue <- substr(colnames(r), 14, 16)  

tcgaID = as.data.frame(tcgaID)  

Select Primary Solid Tumor tissue data (“01A”):

sel=tcgaID$tissue == "01A"
tcgaID.sel = tcgaID[sel, ]

# Subset the RNA expression data to match selected samples
RNA.sel = RNA[sel, ]

Intersect patient IDs between clinical and RNA data:

sel = intersect(tcgaID.sel$patient, rownames(coad))
# Subset the clinical data to include only selected patients:
coad.sel = coad[sel, ]
# Assign patient IDs as row names to the RNA data:
rownames(RNA.sel) = tcgaID.sel$patient
# Subset the RNA data to include only selected patients
RNA.sel = RNA.sel[sel, ]

Prepare labels for pathology stages:

  • Classify stages t1, t2, & t3 as “low”

  • Classify stages t4, t4a, & t4b as “high”

  • Convert any tis stages to NA

labels = coad.sel[, "pathology_T_stage"]
labels[labels %in% c("t1", "t2", "t3", "tis")] = "low"
labels[labels %in% c("t4", "t4a", "t4b")] = "high"

Log Transform the expression data for our selected gene CXCL2:

CXCL2 <- log(1 + RNA.sel[, "CXCL2|2920"])
LCN2 <- log(1 + RNA.sel[,"LCN2|3934" ])

Boxplot to visualize the distribution of log transformed gene expression by pathology stage:

colors=c("#0073c2bb","#efc000bb","#868686bb","#cd534cbb","#7aabdcbb","#003c67bb")

library(ggpubr)
Loading required package: ggplot2
df=data.frame(variable=CXCL2,labels=labels)

my_comparisons=list()
my_comparisons[[1]]=c(1,2)

Nplot1=ggboxplot(df, x = "labels", y = "variable",fill="labels",
                 width = 0.8,
                 palette=colors,
                 add = "jitter",            
                 add.params = list(size = 2, jitter = 0.2,fill=3, shape=10))+  
  ylab("CXCL2 gene expression (FPKM)")+ xlab("")+
  stat_compare_means(comparisons = my_comparisons,method="wilcox.test")

Nplot1

Version Author Date
a7f82c5 tkcaccia 2024-09-18

Enrichment analysis

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

BiocManager::install("GSVA")
install.packages("GSA")

The downloaded binary packages are in
    /var/folders/p9/7vjxs6dd7p70vybzdhy_0hw00000gn/T//RtmpdzmAYO/downloaded_packages
library("GSVA")
library("GSA")
library("KODAMA")

genes=t(RNA.sel)
t=unlist(lapply(strsplit(rownames(genes),"\\|"),function(x) x[1]))
selt=ave(1:length(t), t, FUN = length)
genes=genes[selt==1,]
rownames(genes)=t[selt==1]
geneset=GSA.read.gmt("../Data/Genesets/msigdb_v2023.2.Hs_GMTs/c2.cp.kegg_legacy.v2023.2.Hs.symbols.gmt")
names(geneset$genesets)=geneset$geneset.names
geneset=geneset$genesets

#gsva_TCGA <- gsva(genes, geneset,min.sz = 5)
gsvapar = gsvaParam(genes,geneset)
gsva_TCGA=gsva(gsvapar)
ma=multi_analysis(t(gsva_TCGA),CXCL2,FUN="correlation.test",method="spearman")
ma=ma[order(as.numeric(ma$`p-value`)),]
ma[1:10,]
                                                            Feature   rho
109                        KEGG_NOD_LIKE_RECEPTOR_SIGNALING_PATHWAY  0.43
171                                             KEGG_TIGHT_JUNCTION -0.32
99                                               KEGG_MELANOGENESIS -0.31
186                                      KEGG_WNT_SIGNALING_PATHWAY -0.31
3                                            KEGG_ADHERENS_JUNCTION -0.29
182                   KEGG_VASOPRESSIN_REGULATED_WATER_REABSORPTION -0.29
133                                     KEGG_PPAR_SIGNALING_PATHWAY -0.28
153                      KEGG_RIG_I_LIKE_RECEPTOR_SIGNALING_PATHWAY  0.27
22                                        KEGG_BASAL_CELL_CARCINOMA -0.27
51  KEGG_EPITHELIAL_CELL_SIGNALING_IN_HELICOBACTER_PYLORI_INFECTION  0.27
     p-value      FDR
109 6.72e-10 1.25e-07
171 6.09e-06 5.66e-04
99  1.12e-05 6.93e-04
186 1.71e-05 7.97e-04
3   5.45e-05 1.87e-03
182 6.02e-05 1.87e-03
133 1.05e-04 2.79e-03
153 1.54e-04 3.58e-03
22  1.99e-04 4.03e-03
51  2.17e-04 4.03e-03
ma=multi_analysis(t(gsva_TCGA),LCN2,FUN="correlation.test",method="spearman")
ma=ma[order(as.numeric(ma$`p-value`)),]
ma[1:10,]
                                              Feature   rho  p-value      FDR
153        KEGG_RIG_I_LIKE_RECEPTOR_SIGNALING_PATHWAY  0.35 8.04e-07 1.46e-04
42                 KEGG_CYTOSOLIC_DNA_SENSING_PATHWAY  0.34 2.23e-06 1.46e-04
41        KEGG_CYTOKINE_CYTOKINE_RECEPTOR_INTERACTION  0.34 2.36e-06 1.46e-04
87  KEGG_INTESTINAL_IMMUNE_NETWORK_FOR_IGA_PRODUCTION  0.33 3.61e-06 1.49e-04
135                     KEGG_PRIMARY_IMMUNODEFICIENCY  0.33 4.01e-06 1.49e-04
109          KEGG_NOD_LIKE_RECEPTOR_SIGNALING_PATHWAY  0.32 5.46e-06 1.69e-04
14                                     KEGG_APOPTOSIS  0.32 6.49e-06 1.72e-04
172         KEGG_TOLL_LIKE_RECEPTOR_SIGNALING_PATHWAY  0.30 2.19e-05 5.10e-04
3                              KEGG_ADHERENS_JUNCTION -0.30 3.31e-05 6.84e-04
186                        KEGG_WNT_SIGNALING_PATHWAY -0.29 3.74e-05 6.96e-04

sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Africa/Johannesburg
tzcode source: internal

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

other attached packages:
 [1] GSA_1.03.3          GSVA_1.50.5         BiocManager_1.30.25
 [4] ggpubr_0.6.0        ggplot2_3.5.2       KODAMA_3.0         
 [7] Matrix_1.6-5        umap_0.2.10.0       Rtsne_0.17         
[10] minerva_1.5.10      readxl_1.4.5        workflowr_1.7.1    

loaded via a namespace (and not attached):
  [1] DBI_1.2.3                   bitops_1.0-9               
  [3] GSEABase_1.64.0             rlang_1.1.6                
  [5] magrittr_2.0.3              git2r_0.36.2               
  [7] matrixStats_1.5.0           compiler_4.3.3             
  [9] RSQLite_2.3.9               DelayedMatrixStats_1.24.0  
 [11] getPass_0.2-4               png_0.1-8                  
 [13] callr_3.7.6                 vctrs_0.6.5                
 [15] stringr_1.5.1               pkgconfig_2.0.3            
 [17] crayon_1.5.3                fastmap_1.2.0              
 [19] backports_1.5.0             XVector_0.42.0             
 [21] labeling_0.4.3              promises_1.3.2             
 [23] rmarkdown_2.29              graph_1.80.0               
 [25] ps_1.9.0                    purrr_1.0.4                
 [27] bit_4.6.0                   xfun_0.52                  
 [29] beachmat_2.18.1             zlibbioc_1.48.2            
 [31] cachem_1.1.0                GenomeInfoDb_1.38.8        
 [33] jsonlite_2.0.0              blob_1.2.4                 
 [35] later_1.4.1                 rhdf5filters_1.14.1        
 [37] DelayedArray_0.28.0         Rhdf5lib_1.24.2            
 [39] BiocParallel_1.36.0         irlba_2.3.5.1              
 [41] broom_1.0.8                 parallel_4.3.3             
 [43] R6_2.6.1                    bslib_0.9.0                
 [45] stringi_1.8.7               RColorBrewer_1.1-3         
 [47] reticulate_1.42.0           car_3.1-3                  
 [49] GenomicRanges_1.54.1        jquerylib_0.1.4            
 [51] cellranger_1.1.0            SummarizedExperiment_1.32.0
 [53] Rcpp_1.1.0                  knitr_1.50                 
 [55] IRanges_2.36.0              httpuv_1.6.15              
 [57] tidyselect_1.2.1            rstudioapi_0.17.1          
 [59] abind_1.4-8                 yaml_2.3.10                
 [61] codetools_0.2-20            processx_3.8.6             
 [63] lattice_0.22-6              tibble_3.3.0               
 [65] Biobase_2.62.0              withr_3.0.2                
 [67] KEGGREST_1.42.0             askpass_1.2.1              
 [69] evaluate_1.0.3              Biostrings_2.70.3          
 [71] pillar_1.11.0               MatrixGenerics_1.14.0      
 [73] carData_3.0-5               whisker_0.4.1              
 [75] stats4_4.3.3                generics_0.1.4             
 [77] rprojroot_2.0.4             RCurl_1.98-1.17            
 [79] S4Vectors_0.40.2            sparseMatrixStats_1.14.0   
 [81] scales_1.4.0                xtable_1.8-4               
 [83] glue_1.8.0                  tools_4.3.3                
 [85] ScaledMatrix_1.10.0         RSpectra_0.16-2            
 [87] annotate_1.80.0             ggsignif_0.6.4             
 [89] fs_1.6.6                    XML_3.99-0.18              
 [91] rhdf5_2.46.1                grid_4.3.3                 
 [93] tidyr_1.3.1                 SingleCellExperiment_1.24.0
 [95] AnnotationDbi_1.64.1        GenomeInfoDbData_1.2.11    
 [97] BiocSingular_1.18.0         HDF5Array_1.30.1           
 [99] rsvd_1.0.5                  Formula_1.2-5              
[101] cli_3.6.5                   S4Arrays_1.2.1             
[103] dplyr_1.1.4                 gtable_0.3.6               
[105] rstatix_0.7.2               sass_0.4.9                 
[107] digest_0.6.37               BiocGenerics_0.48.1        
[109] SparseArray_1.2.4           farver_2.1.2               
[111] memoise_2.0.1               htmltools_0.5.8.1          
[113] lifecycle_1.0.4             httr_1.4.7                 
[115] openssl_2.3.2               bit64_4.6.0-1