Contents

0.1 Instalation

if (!require("BiocManager"))
  install.packages("BiocManager")
BiocManager::install("glmSparseNet")

1 Required Packages

library(dplyr)
library(ggplot2)
library(survival)
library(loose.rock)
library(futile.logger)
library(curatedTCGAData)
library(TCGAutils)
#
library(glmSparseNet)
#
# Some general options for futile.logger the debugging package
.Last.value <- flog.layout(layout.format('[~l] ~m'))
.Last.value <- loose.rock::show.message(FALSE)
# Setting ggplot2 default theme as minimal
theme_set(ggplot2::theme_minimal())

2 Load data

The data is loaded from an online curated dataset downloaded from TCGA using curatedTCGAData bioconductor package and processed.

To accelerate the process we use a very reduced dataset down to 107 variables only (genes), which is stored as a data object in this package. However, the procedure to obtain the data manually is described in the following chunk.

brca <- curatedTCGAData(diseaseCode = "BRCA", assays = "RNASeq2GeneNorm",
                        version = "1.1.38", dry.run = FALSE
)
brca <- curatedTCGAData(diseaseCode = "BRCA", assays = "RNASeq2GeneNorm",
                        version = "1.1.38", dry.run = FALSE)
brca <- TCGAutils::TCGAsplitAssays(brca, c('01','11'))
xdata.raw <- t(cbind(assay(brca[[1]]), assay(brca[[2]])))

# Get matches between survival and assay data
class.v        <- TCGAbiospec(rownames(xdata.raw))$sample_definition %>% factor
names(class.v) <- rownames(xdata.raw)

# keep features with standard deviation > 0
xdata.raw <- xdata.raw %>% 
  { (apply(., 2, sd) != 0) } %>% 
  { xdata.raw[, .] } %>%
  scale

set.seed(params$seed)
small.subset <- c('CD5', 'CSF2RB', 'HSF1', 'IRGC', 'LRRC37A6P', 'NEUROG2', 
                  'NLRC4', 'PDE11A', 'PIK3CB', 'QARS', 'RPGRIP1L', 'SDC1', 
                  'TMEM31', 'YME1L1', 'ZBTB11', 
                  sample(colnames(xdata.raw), 100))

xdata <- xdata.raw[, small.subset[small.subset %in% colnames(xdata.raw)]]
ydata <- class.v

3 Fit models

Fit model model penalizing by the hubs using the cross-validation function by cv.glmHub.

fitted <- cv.glmHub(xdata, ydata, 
                    family  = 'binomial',
                    network = 'correlation', 
                    nlambda = 1000,
                    network.options = networkOptions(cutoff = .6, 
                                                     min.degree = .2))

4 Results of Cross Validation

Shows the results of 1000 different parameters used to find the optimal value in 10-fold cross-validation. The two vertical dotted lines represent the best model and a model with less variables selected (genes), but within a standard error distance from the best.

plot(fitted)

4.1 Coefficients of selected model from Cross-Validation

Taking the best model described by lambda.min

coefs.v <- coef(fitted, s = 'lambda.min')[,1] %>% { .[. != 0]}
coefs.v %>% { 
  data.frame(ensembl.id  = names(.), 
             gene.name   = geneNames(names(.))$external_gene_name, 
             coefficient = .,
             stringsAsFactors = FALSE)
  } %>%
  arrange(gene.name) %>%
  knitr::kable()
ensembl.id gene.name coefficient
(Intercept) (Intercept) (Intercept) -6.8189811
CD5 CD5 AMOTL1 -1.1200445
NLRC4 NLRC4 ATR -1.4434577
PIK3CB PIK3CB B3GALT2 -0.3880002
ZBTB11 ZBTB11 BAG2 -0.3325728
ATR ATR C16orf82 1.2498303
IL2 IL2 CD5 0.6327083
GDF11 GDF11 CIITA -0.2676642
DCP1A DCP1A DCP1A 0.2994599
AMOTL1 AMOTL1 FAM86B1 0.4430643
BAG2 BAG2 FNIP2 -0.1841676
C16orf82 C16orf82 GDF11 0.0396368
FAM86B1 FAM86B1 GNG11 0.2025462
FNIP2 FNIP2 GREM2 0.6101758
MS4A4A MS4A4A GZMB 1.1614778
B3GALT2 B3GALT2 HAX1 -0.0867011
GNG11 GNG11 IL2 3.0659065
NDRG2 NDRG2 MMP28 1.1142519
HAX1 HAX1 MS4A4A -0.1516836
GREM2 GREM2 NDRG2 -0.2014884
CIITA CIITA NLRC4 0.4256103
GZMB GZMB PIK3CB -2.7663573
MMP28 MMP28 ZBTB11 -0.8438023

4.2 Hallmarks of Cancer

geneNames(names(coefs.v)) %>% { hallmarks(.$external_gene_name)$heatmap }

4.3 Accuracy

## [INFO] Misclassified (11)
## [INFO]   * False primary solid tumour: 7
## [INFO]   * False normal              : 4

Histogram of predicted response

ROC curve

## Setting levels: control = Primary Solid Tumor, case = Solid Tissue Normal
## Setting direction: controls < cases

5 Session Info

sessionInfo()
## R version 4.1.1 (2021-08-10)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.14-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] glmSparseNet_1.12.0         glmnet_4.1-2               
##  [3] Matrix_1.3-4                TCGAutils_1.14.0           
##  [5] curatedTCGAData_1.15.1      MultiAssayExperiment_1.20.0
##  [7] SummarizedExperiment_1.24.0 Biobase_2.54.0             
##  [9] GenomicRanges_1.46.0        GenomeInfoDb_1.30.0        
## [11] IRanges_2.28.0              S4Vectors_0.32.0           
## [13] BiocGenerics_0.40.0         MatrixGenerics_1.6.0       
## [15] matrixStats_0.61.0          futile.logger_1.4.3        
## [17] loose.rock_1.2.0            survival_3.2-13            
## [19] ggplot2_3.3.5               dplyr_1.0.7                
## [21] BiocStyle_2.22.0           
## 
## loaded via a namespace (and not attached):
##   [1] colorspace_2.0-2              rjson_0.2.20                 
##   [3] ellipsis_0.3.2                XVector_0.34.0               
##   [5] farver_2.1.0                  sparsebnUtils_0.0.8          
##   [7] bit64_4.0.5                   interactiveDisplayBase_1.32.0
##   [9] AnnotationDbi_1.56.0          fansi_0.5.0                  
##  [11] xml2_1.3.2                    codetools_0.2-18             
##  [13] splines_4.1.1                 cachem_1.0.6                 
##  [15] knitr_1.36                    jsonlite_1.7.2               
##  [17] pROC_1.18.0                   Rsamtools_2.10.0             
##  [19] ccdrAlgorithm_0.0.5           dbplyr_2.1.1                 
##  [21] png_0.1-7                     shiny_1.7.1                  
##  [23] BiocManager_1.30.16           readr_2.0.2                  
##  [25] compiler_4.1.1                httr_1.4.2                   
##  [27] assertthat_0.2.1              fastmap_1.1.0                
##  [29] later_1.3.0                   formatR_1.11                 
##  [31] htmltools_0.5.2               prettyunits_1.1.1            
##  [33] tools_4.1.1                   gtable_0.3.0                 
##  [35] glue_1.4.2                    GenomeInfoDbData_1.2.7       
##  [37] reshape2_1.4.4                rappdirs_0.3.3               
##  [39] Rcpp_1.0.7                    jquerylib_0.1.4              
##  [41] vctrs_0.3.8                   Biostrings_2.62.0            
##  [43] ExperimentHub_2.2.0           rtracklayer_1.54.0           
##  [45] iterators_1.0.13              xfun_0.27                    
##  [47] stringr_1.4.0                 rvest_1.0.2                  
##  [49] mime_0.12                     lifecycle_1.0.1              
##  [51] restfulr_0.0.13               XML_3.99-0.8                 
##  [53] AnnotationHub_3.2.0           zlibbioc_1.40.0              
##  [55] scales_1.1.1                  hms_1.1.1                    
##  [57] promises_1.2.0.1              parallel_4.1.1               
##  [59] lambda.r_1.2.4                yaml_2.2.1                   
##  [61] curl_4.3.2                    memoise_2.0.0                
##  [63] sass_0.4.0                    biomaRt_2.50.0               
##  [65] stringi_1.7.5                 RSQLite_2.2.8                
##  [67] highr_0.9                     BiocVersion_3.14.0           
##  [69] BiocIO_1.4.0                  GenomicDataCommons_1.18.0    
##  [71] foreach_1.5.1                 GenomicFeatures_1.46.0       
##  [73] filelock_1.0.2                BiocParallel_1.28.0          
##  [75] discretecdAlgorithm_0.0.7     shape_1.4.6                  
##  [77] rlang_0.4.12                  pkgconfig_2.0.3              
##  [79] bitops_1.0-7                  evaluate_0.14                
##  [81] lattice_0.20-45               purrr_0.3.4                  
##  [83] labeling_0.4.2                GenomicAlignments_1.30.0     
##  [85] bit_4.0.4                     tidyselect_1.1.1             
##  [87] plyr_1.8.6                    magrittr_2.0.1               
##  [89] bookdown_0.24                 R6_2.5.1                     
##  [91] magick_2.7.3                  generics_0.1.1               
##  [93] DelayedArray_0.20.0           DBI_1.1.1                    
##  [95] pillar_1.6.4                  withr_2.4.2                  
##  [97] KEGGREST_1.34.0               RCurl_1.98-1.5               
##  [99] tibble_3.1.5                  crayon_1.4.1                 
## [101] futile.options_1.0.1          utf8_1.2.2                   
## [103] BiocFileCache_2.2.0           tzdb_0.1.2                   
## [105] rmarkdown_2.11                progress_1.2.2               
## [107] grid_4.1.1                    blob_1.2.2                   
## [109] forcats_0.5.1                 digest_0.6.28                
## [111] xtable_1.8-4                  httpuv_1.6.3                 
## [113] munsell_0.5.0                 sparsebn_0.1.2               
## [115] bslib_0.3.1