Last updated: 2021-10-01

Checks: 7 0

Knit directory: Multispectral HCC/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20210728) 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 d134fc2. 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:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    analysis/figure/
    Ignored:    code/
    Ignored:    data/
    Ignored:    old/
    Ignored:    output/.DS_Store
    Ignored:    output/tumor.hc.nmf.rank.1.rds
    Ignored:    output/tumor.hc.nmf.rank.10.rds
    Ignored:    output/tumor.hc.nmf.rank.5.rds
    Ignored:    output/tumor.hc.umap.rds

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 13f7fb5 Jovan Tanevski 2021-10-01 leave only nmf
html 438a57b Jovan Tanevski 2021-09-18 Build site.
Rmd 421ce3c Jovan Tanevski 2021-09-18 add caching, bump cores to 10%
html cfc1900 Jovan Tanevski 2021-09-17 Build site.
Rmd 410dc90 Jovan Tanevski 2021-09-17 fix issue with low number of examples
Rmd 201876f Jovan Tanevski 2021-09-17 work with normalized data for profiles and de
html c85e3e6 Jovan Tanevski 2021-09-17 Build site.
Rmd b8745a8 Jovan Tanevski 2021-09-17 fix typos
html ae61865 Jovan Tanevski 2021-09-16 Build site.
Rmd 9c11427 Jovan Tanevski 2021-09-16 fix difference calculation
html 9a18eda Jovan Tanevski 2021-09-16 Build site.
Rmd 17fc915 Jovan Tanevski 2021-09-16 update hclust
Rmd 47928d9 Jovan Tanevski 2021-09-16 add silhouette based differential expression analysis, repeat nmf
html e7709fe Jovan Tanevski 2021-08-03 Build site.
html f791e00 Jovan Tanevski 2021-08-03 Build site.
Rmd e464694 Jovan Tanevski 2021-08-03 fix seed, stabilize nmf
html 51e2651 Jovan Tanevski 2021-08-03 Build site.
Rmd 7d62e48 Jovan Tanevski 2021-08-03 hclust and leiden on quantile normalized data
html 55fb7fc Jovan Tanevski 2021-08-02 Build site.
Rmd a152862 Jovan Tanevski 2021-08-02 add NMF based analysis
html c25dcca Jovan Tanevski 2021-08-02 Build site.
Rmd 21cf743 Jovan Tanevski 2021-08-02 rank normalization, leiden analysis, diff exp
html a386eaa Jovan Tanevski 2021-07-28 Build site.
Rmd 9ab4acc Jovan Tanevski 2021-07-28 Build site.
Rmd bd05dbf Jovan Tanevski 2021-07-28 add expression profiles
html e45bf1d Jovan Tanevski 2021-07-28 Build site.
Rmd dcab1bf Jovan Tanevski 2021-07-28 set figure output to svg
html 33e71a0 Jovan Tanevski 2021-07-28 Build site.
Rmd bb998b8 Jovan Tanevski 2021-07-28 hclust with factoextra
html 1cb80af Jovan Tanevski 2021-07-28 Build site.
Rmd d0b6e0f Jovan Tanevski 2021-07-28 add pca to tcga analysis
html d73f586 Jovan Tanevski 2021-07-28 Build site.
Rmd c4324f5 Jovan Tanevski 2021-07-28 add umap
html 0bfae68 Jovan Tanevski 2021-07-28 Build site.
Rmd 82e3712 Jovan Tanevski 2021-07-28 add basic hclust

Setup

Load required libraries.

library(tidyverse)
library(skimr)
library(uwot)
library(factoextra)
library(cowplot)
library(limma)
library(NMF)
library(pheatmap)

Read filtered TCGA RRPA data and display summary statistics.

tcga.raw <- read_csv("data/TCGA-RPPA-LIHC_selected.csv", col_types = cols()) %>%
  select(-TumorType) %>%
  column_to_rownames("SampleID")

skim(tcga.raw)
Data summary
Name tcga.raw
Number of rows 184
Number of columns 12
_______________________
Column type frequency:
numeric 12
________________________
Group variables None

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
P53 0 1 -1.13 0.46 -2.54 -1.40 -0.96 -0.76 -0.51 ▁▂▂▅▇
AKT_pS473 0 1 -0.63 0.71 -2.76 -1.02 -0.41 -0.15 0.96 ▁▂▃▇▁
AKT_pT308 0 1 0.07 0.42 -1.16 -0.07 0.09 0.22 1.72 ▁▃▇▁▁
BETACATENIN 0 1 1.50 0.72 -1.30 1.08 1.51 1.87 3.70 ▁▁▇▅▁
JNK_pT183Y185 0 1 -0.21 0.29 -1.14 -0.36 -0.17 -0.04 0.48 ▁▂▇▇▂
MEK1_pS217S221 0 1 -0.17 0.36 -0.82 -0.35 -0.23 -0.10 2.58 ▇▃▁▁▁
P38_pT180Y182 0 1 0.49 0.57 -1.45 0.31 0.50 0.72 2.95 ▁▂▇▁▁
P70S6K_pT389 0 1 -1.21 0.75 -3.22 -1.58 -0.95 -0.65 1.09 ▂▃▇▃▁
PDK1_pS241 0 1 0.40 0.31 -0.56 0.23 0.37 0.55 1.62 ▁▇▇▂▁
S6_pS235S236 0 1 -0.72 0.75 -3.53 -1.06 -0.67 -0.36 1.12 ▁▁▅▇▂
YAP_pS127 0 1 2.21 0.61 0.68 1.78 2.10 2.54 4.05 ▁▇▇▂▁
TRANSGLUTAMINASE 0 1 -0.42 0.56 -1.24 -0.83 -0.59 -0.20 2.72 ▇▃▁▁▁

Quantile normalization and rank normalization for NMF as suggested in https://gdac.broadinstitute.org/runs/analyses__2016_01_28/reports/cancer/LIHC/RPPA_Clustering_CNMF/nozzle.html

tcga.norm <- normalizeQuantiles(tcga.raw)

skim(tcga.norm)
Data summary
Name tcga.norm
Number of rows 184
Number of columns 12
_______________________
Column type frequency:
numeric 12
________________________
Group variables None

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
P53 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
AKT_pS473 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
AKT_pT308 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
BETACATENIN 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
JNK_pT183Y185 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
MEK1_pS217S221 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
P38_pT180Y182 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
P70S6K_pT389 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
PDK1_pS241 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
S6_pS235S236 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
YAP_pS127 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
TRANSGLUTAMINASE 0 1 0.01 0.52 -1.59 -0.27 0.05 0.3 1.87 ▁▃▇▂▁
tcga.rank <- mutate_all(tcga.raw, rank)

Dimensionality reduction

tcga.pca <- prcomp(tcga.norm)
summary(tcga.pca)
Importance of components:
                         PC1    PC2    PC3     PC4     PC5     PC6     PC7
Standard deviation     1.052 0.6800 0.5864 0.53531 0.50548 0.47429 0.40905
Proportion of Variance 0.340 0.1421 0.1057 0.08809 0.07855 0.06915 0.05144
Cumulative Proportion  0.340 0.4821 0.5878 0.67594 0.75449 0.82364 0.87508
                           PC8     PC9    PC10    PC11    PC12
Standard deviation     0.35923 0.34052 0.28251 0.23710 0.15913
Proportion of Variance 0.03967 0.03565 0.02454 0.01728 0.00778
Cumulative Proportion  0.91475 0.95040 0.97493 0.99222 1.00000
set.seed(42)
tcga.umap <- umap(tcga.norm, n_neighbors = 10, n_epochs = 1000)

Consensus NMF clustering

For this analysis 3 clusters were selected based on the consensus cophenetic correlation coefficient.

tcga.nmf.rank <- nmfEstimateRank(as.matrix(t(tcga.rank)), seq(2,10), nrun = 20, seed = 42)

plot(tcga.nmf.rank)

tcga.nmf <- tcga.nmf <- tcga.nmf.rank$fit[["3"]]

Extract basis of NMF (signature of cluster)

basismap(tcga.nmf)

Extract coefficients of NMF (soft clustering of samples)

coefmap(tcga.nmf)

Check for signs of overfitting

consensusmap(tcga.nmf)

Assign clusters

nmf.clusters <- apply(tcga.nmf@fit@H, 2, which.max)

Plot in 2D PCA and UMAP

fviz_pca_ind(tcga.pca, geom = "point", col.ind = as.factor(nmf.clusters)) +
  theme_classic()

tcga.umap.clus <-
  tcga.umap %>%
  cbind(nmf.clusters) %>%
  `colnames<-`(c("U1", "U2", "Cluster")) %>%
  as_tibble() %>%
  mutate_at("Cluster", as.factor)

ggplot(tcga.umap.clus, aes(x = U1, y = U2, color = Cluster)) +
  geom_point() +
  theme_classic()

Expression profiles per cluster

tcga.clustered.nmf <- tcga.norm %>%
  mutate(Cluster = as.factor(nmf.clusters)) %>%
  pivot_longer(names_to = "Marker", values_to = "Norm.value", -Cluster)

profiles <- seq_len(max(nmf.clusters)) %>% map(~
ggplot(
  tcga.clustered.nmf %>% filter(Cluster == .x),
  aes(x = Marker, y = Norm.value, color = Marker)
) +
  stat_summary(fun.data = mean_sdl, show.legend = FALSE) +
  ylim(-3, 3) +
  theme_classic() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)))

plot_grid(plotlist = profiles, labels = paste("Cluster", seq_len(max(nmf.clusters))))

Differential expression analysis (limma)

design <- model.matrix(~0 + as.factor(nmf.clusters))
colnames(design) <- paste0("Cluster", seq_len(max(nmf.clusters)))

tcga.nmf.limma <- lmFit(t(tcga.norm), design = design)

tcga.nmf.eb <- eBayes(tcga.nmf.limma)

topTable(tcga.nmf.eb)
Cluster1 Cluster2 Cluster3 AveExpr F P.Value adj.P.Val
P53 -0.4414233 -0.4485783 0.2956533 0.0140382 49.62915 0e+00 0e+00
AKT_pS473 -0.5334368 -0.3138352 0.2904909 0.0140382 49.52718 0e+00 0e+00
P70S6K_pT389 -0.3765563 -0.4171258 0.2649090 0.0140382 35.36002 0e+00 0e+00
MEK1_pS217S221 0.5545074 -0.3643842 -0.0679547 0.0140382 29.63664 0e+00 0e+00
JNK_pT183Y185 -0.0595382 -0.5230228 0.1852520 0.0140382 20.60883 0e+00 0e+00
BETACATENIN -0.3085174 0.5078866 -0.0099059 0.0140382 18.98657 0e+00 0e+00
PDK1_pS241 0.2734628 0.4012811 -0.1799376 0.0140863 18.75428 0e+00 0e+00
S6_pS235S236 0.0790752 -0.5132934 0.1351859 0.0140382 16.62621 0e+00 0e+00
AKT_pT308 -0.2971225 -0.2369574 0.1887412 0.0140382 14.32245 0e+00 0e+00
YAP_pS127 0.0589849 0.4566955 -0.1217100 0.0140382 12.63077 1e-07 1e-07
tests.nmf <- decideTests(tcga.nmf.eb)

tests.nmf@.Data
                 Cluster1 Cluster2 Cluster3
P53                    -1       -1        1
AKT_pS473              -1       -1        1
AKT_pT308              -1       -1        1
BETACATENIN            -1        1        0
JNK_pT183Y185           0       -1        1
MEK1_pS217S221          1       -1        0
P38_pT180Y182           0       -1        1
P70S6K_pT389           -1       -1        1
PDK1_pS241              1        1       -1
S6_pS235S236            0       -1        1
YAP_pS127               0        1       -1
TRANSGLUTAMINASE        1        0        0
summary(tests.nmf)
       Cluster1 Cluster2 Cluster3
Down          5        8        2
NotSig        4        1        3
Up            3        3        7

Differential expression analysis (silhouette)

Calculate the similarity of samples using the expression and the silhouette scores based on the assigned clusters.

silhouette.nmf <- silhouette(nmf.clusters, dist(tcga.norm))
fviz_silhouette(silhouette.nmf)
  cluster size ave.sil.width
1       1   39         -0.04
2       2   31          0.15
3       3  114          0.33

Select only the samples with positive silhouette scores as “core samples”

core.samples <- which(silhouette.nmf[,3] > 0)
tcga.core.samples <- tcga.norm %>% add_column(Cluster = nmf.clusters) %>% 
  slice(core.samples)

Calculate difference in means (mean(cluster) - mean(other)), one-vs-all t-test per marker and correct for FDR. Filter q <= 0.05. Plot the differences.

de.table <- unique(tcga.core.samples$Cluster) %>% map_dfr(\(c){
  tcga.core.samples %>% 
    summarize(across(-Cluster, ~t.test(.x ~ (Cluster==c))$p.value)) %>%
    pivot_longer(names_to = "Marker", values_to = "p", everything()) %>% 
    mutate(Cluster = c, Difference = tcga.core.samples %>% 
             group_by(Cluster == c) %>% 
             select(-Cluster) %>% 
             group_split(.keep = FALSE) %>% map(colMeans) %>% reduce(`-`))
 }) %>% 
  mutate(q = p.adjust(p, method = "fdr"), Difference = -Difference)

de.table %>%
  filter(q <= 0.05) %>%
  arrange(q)
Marker p Cluster Difference q
P53 0.0000000 3 0.8261853 0.0000000
P70S6K_pT389 0.0000000 3 0.7636210 0.0000000
AKT_pS473 0.0000000 3 0.8341263 0.0000000
JNK_pT183Y185 0.0000000 2 -0.7426361 0.0000000
P53 0.0000000 2 -0.7245959 0.0000000
AKT_pS473 0.0000000 2 -0.6138768 0.0000000
P70S6K_pT389 0.0000000 2 -0.6583089 0.0000000
S6_pS235S236 0.0000000 2 -0.7278831 0.0000000
BETACATENIN 0.0000000 2 0.6267117 0.0000000
PDK1_pS241 0.0000001 2 0.5861173 0.0000004
MEK1_pS217S221 0.0000007 1 0.9512471 0.0000022
P38_pT180Y182 0.0000011 3 0.5284230 0.0000032
AKT_pT308 0.0000020 3 0.5371256 0.0000054
P38_pT180Y182 0.0000027 2 -0.5664680 0.0000069
JNK_pT183Y185 0.0000049 3 0.5255499 0.0000118
PDK1_pS241 0.0000081 3 -0.5210833 0.0000181
AKT_pS473 0.0000109 1 -1.0376493 0.0000230
P70S6K_pT389 0.0000241 1 -0.7212306 0.0000482
YAP_pS127 0.0000988 3 -0.5056444 0.0001872
P53 0.0001748 1 -0.7509946 0.0003146
YAP_pS127 0.0002097 2 0.5573314 0.0003595
AKT_pT308 0.0003973 2 -0.4833504 0.0006247
BETACATENIN 0.0003991 1 -0.8469248 0.0006247
S6_pS235S236 0.0004766 3 0.4551491 0.0007149
MEK1_pS217S221 0.0007290 2 -0.3592819 0.0010497
TRANSGLUTAMINASE 0.0072461 1 0.6227038 0.0100330
AKT_pT308 0.0122702 1 -0.4591054 0.0163602
de.table %>%
  pivot_wider(names_from = "Cluster", values_from = "Difference", -c(p, q)) %>%
  column_to_rownames("Marker") %>%
  as.matrix() %>%
  pheatmap(scale = "none")


sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] RColorBrewer_1.1-2  doParallel_1.0.16   iterators_1.0.13   
 [4] foreach_1.5.1       pheatmap_1.0.12     NMF_0.23.0         
 [7] synchronicity_1.3.5 bigmemory_4.5.36    Biobase_2.52.0     
[10] BiocGenerics_0.38.0 cluster_2.1.2       rngtools_1.5.2     
[13] pkgmaker_0.32.2     registry_0.5-1      limma_3.48.3       
[16] cowplot_1.1.1       factoextra_1.0.7    uwot_0.1.10        
[19] Matrix_1.3-4        skimr_2.1.3         forcats_0.5.1      
[22] stringr_1.4.0       dplyr_1.0.7         purrr_0.3.4        
[25] readr_2.0.2         tidyr_1.1.4         tibble_3.1.4       
[28] ggplot2_3.3.5       tidyverse_1.3.1     workflowr_1.6.2    

loaded via a namespace (and not attached):
  [1] bigmemory.sri_0.1.3 colorspace_2.0-2    ggsignif_0.6.3     
  [4] rio_0.5.27          ellipsis_0.3.2      rprojroot_2.0.2    
  [7] htmlTable_2.2.1     base64enc_0.1-3     fs_1.5.0           
 [10] rstudioapi_0.13     ggpubr_0.4.0        farver_2.1.0       
 [13] ggrepel_0.9.1       bit64_4.0.5         RSpectra_0.16-0    
 [16] fansi_0.5.0         lubridate_1.7.10    xml2_1.3.2         
 [19] splines_4.1.1       codetools_0.2-18    knitr_1.36         
 [22] Formula_1.2-4       jsonlite_1.7.2      broom_0.7.9        
 [25] gridBase_0.4-7      dbplyr_2.1.1        png_0.1-7          
 [28] compiler_4.1.1      httr_1.4.2          backports_1.2.1    
 [31] assertthat_0.2.1    fastmap_1.1.0       cli_3.0.1          
 [34] later_1.3.0         htmltools_0.5.2     tools_4.1.1        
 [37] gtable_0.3.0        glue_1.4.2          reshape2_1.4.4     
 [40] Rcpp_1.0.7          carData_3.0-4       cellranger_1.1.0   
 [43] jquerylib_0.1.4     vctrs_0.3.8         xfun_0.26          
 [46] openxlsx_4.2.4      rvest_1.0.1         lifecycle_1.0.1    
 [49] rstatix_0.7.0       scales_1.1.1        vroom_1.5.5        
 [52] hms_1.1.1           promises_1.2.0.1    curl_4.3.2         
 [55] yaml_2.2.1          gridExtra_2.3       sass_0.4.0         
 [58] rpart_4.1-15        latticeExtra_0.6-29 stringi_1.7.4      
 [61] highr_0.9           checkmate_2.0.0     zip_2.2.0          
 [64] repr_1.1.3          rlang_0.4.11        pkgconfig_2.0.3    
 [67] evaluate_0.14       lattice_0.20-45     htmlwidgets_1.5.4  
 [70] labeling_0.4.2      bit_4.0.4           tidyselect_1.1.1   
 [73] plyr_1.8.6          magrittr_2.0.1      R6_2.5.1           
 [76] Hmisc_4.5-0         generics_0.1.0      DBI_1.1.1          
 [79] foreign_0.8-81      pillar_1.6.3        haven_2.4.3        
 [82] whisker_0.4         withr_2.4.2         nnet_7.3-16        
 [85] survival_3.2-13     abind_1.4-5         modelr_0.1.8       
 [88] crayon_1.4.1        car_3.0-11          uuid_0.1-4         
 [91] utf8_1.2.2          tzdb_0.1.2          rmarkdown_2.11     
 [94] jpeg_0.1-9          grid_4.1.1          readxl_1.3.1       
 [97] data.table_1.14.2   FNN_1.1.3           git2r_0.28.0       
[100] reprex_2.0.1        digest_0.6.28       xtable_1.8-4       
[103] httpuv_1.6.3        munsell_0.5.0       bslib_0.3.0