• Load packages
    • Process network and save as adj files
  • Generating the regulon object for CNV
  • Run Viper on CNV Data

Last updated: 2024-06-20

Checks: 6 1

Knit directory: PPP/

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(20240521) 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 f0809ae. 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:    analysis/.DS_Store
    Ignored:    analysis/.RData
    Ignored:    analysis/.Rhistory
    Ignored:    code/.DS_Store
    Ignored:    code/TieDIE-devel/.DS_Store
    Ignored:    code/TieDIE-devel/examples/.DS_Store
    Ignored:    code/TieDIE-devel/examples/hnsc/.DS_Store
    Ignored:    code/TieDIE-tiedie2/.DS_Store
    Ignored:    code/TieDIE-tiedie2/examples/.DS_Store
    Ignored:    data/.DS_Store
    Ignored:    data/Phosphoproteome_BCM_GENCODE_v34_harmonized_v1/.DS_Store
    Ignored:    data/Phosphoproteome_BCM_GENCODE_v34_harmonized_v1/README/.DS_Store
    Ignored:    data/Proteome_BCM_GENCODE_v34_harmonized_v1/.DS_Store
    Ignored:    data/Proteome_BCM_GENCODE_v34_harmonized_v1/README/.DS_Store
    Ignored:    output/.DS_Store
    Ignored:    output/expr/.DS_Store
    Ignored:    output/pho/.DS_Store
    Ignored:    output/regulon/.DS_Store
    Ignored:    temp/.DS_Store

Untracked files:
    Untracked:  analysis/Differentially_CNV.Rmd
    Untracked:  analysis/Identify_CNV_Regulators.Rmd
    Untracked:  analysis/PCA.Rmd
    Untracked:  output/MUT/
    Untracked:  output/cnv/
    Untracked:  output/regulon/CNV_hnsc.adj
    Untracked:  output/regulon/CNV_kirc.adj
    Untracked:  output/regulon/CNV_luad.adj
    Untracked:  output/regulon/CNV_lusc.adj
    Untracked:  output/regulon/CNV_paad.adj

Unstaged changes:
    Modified:   analysis/Differentially_Gene.Rmd
    Modified:   analysis/KSEA.Rmd
    Modified:   analysis/index.Rmd
    Modified:   data/omics_regulon_pairs.csv
    Modified:   output/pho/hnsc/KSEA.csv
    Modified:   output/pho/kirc/KSEA.csv
    Modified:   output/pho/luad/KSEA.csv
    Modified:   output/pho/lusc/KSEA.csv
    Modified:   output/pho/paad/KSEA.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.


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


Load packages

library(viper)
library(EnsDb.Hsapiens.v86)
library(foreach)
library(doParallel)
cluster <- makeCluster(5)
registerDoParallel(cluster)
dir.create("output/regulon/",showWarnings = FALSE)
set.seed(0)

Process network and save as adj files

for (name in c("kirc", "hnsc", "lusc", "luad", "paad")) {
    df <- read.csv(paste("output/MUT/", name, "_fc.csv", sep = ""))
    df$ID <- paste(df$SYMBOL, "_R", sep = "")
    # Group by Regulator and concatenate elements of each group into
    # strings
    df$SYMBOL <- paste(df$SYMBOL, "1",sep = "\t")
    result <- aggregate(ID ~ SYMBOL, data = df, FUN = function(x) paste(x,
        collapse = "\t"))
    # Print the result
    file <- file(paste("output/regulon/CNV_", name, ".adj", sep = ""))
    writeLines(paste(result$ID, result$SYMBOL, sep = "\t"), file)
    close(file)
}

Generating the regulon object for CNV

set.seed(0)
for (name in c("kirc", "hnsc", "lusc", "luad", "paad")) {
    adjfile <- paste("output/regulon/regulon", name, ".adj", sep = "")
    cnv_normal <- readRDS(paste("output/cnv/count_matrix_", name, "_normal.RDS",
        sep = ""))
    meta <- read.csv(paste("output/MUT/", name, "_fc_0.01.csv",sep = ""))
    cnv_normal <- cnv_normal[rownames(cnv_normal) %in% meta$SYMBOL,]
    
    gex_normal <- readRDS(paste("output/expr/count_matrix_", name, "_normal.RDS",
        sep = ""))
    
    cnv_tumor <- readRDS(paste("output/cnv/count_matrix_", name, "_tumor.RDS",
        sep = ""))
    cnv_tumor <- cnv_tumor[rownames(cnv_tumor) %in% meta$SYMBOL,]
    gex_tumor <- readRDS(paste("output/expr/count_matrix_", name, "_tumor.RDS",
        sep = ""))
    
    cnv <- merge(cnv_normal, cnv_tumor, by = "row.names", all = FALSE)
    gex <- merge(gex_normal, gex_tumor, by = "row.names", all = FALSE)
    
    nor_sam <- colnames(gex)[1:ncol(gex_normal)]
    tur_sam <- colnames(gex)[(ncol(gex_normal)+1):ncol(gex)]
    
    rownames(cnv) <- paste(cnv$Row.names,"_P", sep = "")
    cnv$Row.names <- NULL
    
    rownames(gex) <- gex$Row.names
    gex$Row.names <- NULL
    
    common_terms <- intersect(colnames(gex),colnames(cnv))
    
    cnv <- cnv[,common_terms]
    gex <- gex[,common_terms]
    expr <- rbind(gex,cnv)

    signature <- c(rep("normal", sum(common_terms %in% nor_sam)), rep("tumor", sum(common_terms %in% tur_sam)))
    dset <- ExpressionSet(assayData = as.matrix(expr))
    dset$description <- factor(signature)
    regul <- aracne2regulon(adjfile, dset, verbose = TRUE)
    saveRDS(dset, paste("output/cnv/dset_", name, ".RDS", sep = ""))
    saveRDS(regul, paste("output/cnv/regul_", name, ".RDS", sep = ""))
}

Run Viper on CNV Data

foreach(name = c("kirc", "hnsc", "lusc", "luad", "paad")) %dopar% {
    library(viper)
    dset <- readRDS(paste("output/cnv/dset_", name, ".RDS",
        sep = ""))
    regulon <- readRDS(paste("output/cnv/regul_", name, ".RDS", sep = ""))
    signature <- rowTtest(dset, "description", "tumor", "normal")
    signature <- (qnorm(signature$p.value/2, lower.tail = FALSE) * sign(signature$statistic))[,
        1]

    # NULL model by sample permutations
    nullmodel <- ttestNull(dset, "description", "tumor", "normal", per = 1000,
        repos = TRUE, verbose = FALSE)
    ## Normalized Enrichment Score (NES)
    mrs <- msviper(signature, regulon, nullmodel, verbose = FALSE)
    temp <- summary(mrs, length(mrs$regulon))
    temp$Sign <- ifelse(temp$NES > 0, "+", "-")
    temp <- temp[temp$FDR < 0.1, ]
    temp <- temp[, c("Regulon", "NES", "Sign")]
    temp$NES <- abs(temp$NES)
    dir.create(paste("output/cnv/",
        name, "/", sep = ""),showWarnings = F)
    write.table(temp, paste("output/cnv/",
        name, "/cnv_regulators.txt", sep = ""), quote = F, sep = "\t", row.names = F,
        col.names = F)
}
[[1]]
NULL

[[2]]
NULL

[[3]]
NULL

[[4]]
NULL

[[5]]
NULL

sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.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: America/New_York
tzcode source: internal

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

other attached packages:
 [1] doParallel_1.0.17         iterators_1.0.14         
 [3] foreach_1.5.2             EnsDb.Hsapiens.v86_2.99.0
 [5] ensembldb_2.28.0          AnnotationFilter_1.28.0  
 [7] GenomicFeatures_1.56.0    AnnotationDbi_1.66.0     
 [9] GenomicRanges_1.56.1      GenomeInfoDb_1.40.1      
[11] IRanges_2.38.0            S4Vectors_0.42.0         
[13] viper_1.38.0              Biobase_2.64.0           
[15] BiocGenerics_0.50.0      

loaded via a namespace (and not attached):
  [1] DBI_1.2.3                   bitops_1.0-7               
  [3] rlang_1.1.4                 magrittr_2.0.3             
  [5] git2r_0.33.0                matrixStats_1.3.0          
  [7] e1071_1.7-14                compiler_4.4.0             
  [9] RSQLite_2.3.7               png_0.1-8                  
 [11] vctrs_0.6.5                 ProtGenerics_1.36.0        
 [13] stringr_1.5.1               pkgconfig_2.0.3            
 [15] crayon_1.5.2                fastmap_1.2.0              
 [17] XVector_0.44.0              utf8_1.2.4                 
 [19] Rsamtools_2.20.0            promises_1.3.0             
 [21] rmarkdown_2.27              UCSC.utils_1.0.0           
 [23] purrr_1.0.2                 bit_4.0.5                  
 [25] xfun_0.45                   zlibbioc_1.50.0            
 [27] cachem_1.1.0                jsonlite_1.8.8             
 [29] blob_1.2.4                  later_1.3.2                
 [31] DelayedArray_0.30.1         BiocParallel_1.38.0        
 [33] R6_2.5.1                    bslib_0.7.0                
 [35] stringi_1.8.4               rtracklayer_1.64.0         
 [37] jquerylib_0.1.4             SummarizedExperiment_1.34.0
 [39] Rcpp_1.0.12                 knitr_1.47                 
 [41] mixtools_2.0.0              httpuv_1.6.15              
 [43] Matrix_1.7-0                splines_4.4.0              
 [45] tidyselect_1.2.1            abind_1.4-5                
 [47] rstudioapi_0.16.0           yaml_2.3.8                 
 [49] codetools_0.2-20            curl_5.2.1                 
 [51] lattice_0.22-6              tibble_3.2.1               
 [53] KEGGREST_1.44.0             evaluate_0.24.0            
 [55] survival_3.7-0              proxy_0.4-27               
 [57] kernlab_0.9-32              Biostrings_2.72.1          
 [59] pillar_1.9.0                MatrixGenerics_1.16.0      
 [61] KernSmooth_2.23-24          plotly_4.10.4              
 [63] generics_0.1.3              rprojroot_2.0.4            
 [65] RCurl_1.98-1.14             ggplot2_3.5.1              
 [67] munsell_0.5.1               scales_1.3.0               
 [69] class_7.3-22                glue_1.7.0                 
 [71] lazyeval_0.2.2              tools_4.4.0                
 [73] BiocIO_1.14.0               data.table_1.15.4          
 [75] GenomicAlignments_1.40.0    fs_1.6.4                   
 [77] XML_3.99-0.16.1             grid_4.4.0                 
 [79] tidyr_1.3.1                 colorspace_2.1-0           
 [81] nlme_3.1-165                GenomeInfoDbData_1.2.12    
 [83] restfulr_0.0.15             cli_3.6.2                  
 [85] workflowr_1.7.1             fansi_1.0.6                
 [87] S4Arrays_1.4.1              segmented_2.1-0            
 [89] viridisLite_0.4.2           dplyr_1.1.4                
 [91] gtable_0.3.5                sass_0.4.9                 
 [93] digest_0.6.35               SparseArray_1.4.8          
 [95] rjson_0.2.21                htmlwidgets_1.6.4          
 [97] memoise_2.0.1               htmltools_0.5.8.1          
 [99] lifecycle_1.0.4             httr_1.4.7                 
[101] bit64_4.0.5                 MASS_7.3-61