Last updated: 2019-11-17

Checks: 7 0

Knit directory: transcriptome_cll/

This reproducible R Markdown analysis was created with workflowr (version 1.4.0). 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(20190511) 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 version displayed above was the version of the Git repository at the time these results were generated.

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:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  data/2018-03-05_IGHV.RData
    Untracked:  data/patmeta_170324.RData
    Untracked:  output/IGHV1_69.svg
    Untracked:  output/cluster1000exprgenes.pdf
    Untracked:  output/cluster500exprgenes.pdf
    Untracked:  output/desRes_15112019.RData
    Untracked:  output/figures/hist_mutations.svg
    Untracked:  output/figures/overview_mutations.pdf
    Untracked:  output/figures/r_objects/
    Untracked:  output/figures/sum_diffGenes_0.05_2.pdf
    Untracked:  output/figures/sum_diffGenes_noTsig.pdf
    Untracked:  output/figures/sum_diffGenes_noTsig_IGHVTri12.pdf

Unstaged changes:
    Modified:   analysis/index.Rmd
    Modified:   output/diff_genes/ATM_diffGenes.csv
    Modified:   output/diff_genes/BRAF_diffGenes.csv
    Modified:   output/diff_genes/MED12_diffGenes.csv
    Modified:   output/diff_genes/NOTCH1_diffGenes.csv
    Modified:   output/diff_genes/SF3B1_diffGenes.csv
    Modified:   output/diff_genes/TP53_diffGenes.csv
    Modified:   output/diff_genes/del11q22.3_diffGenes.csv
    Modified:   output/diff_genes/del13q14_diffGenes.csv
    Modified:   output/diff_genes/del17p13_diffGenes.csv
    Modified:   output/diff_genes/del8p12_diffGenes.csv
    Modified:   output/diff_genes/gain8q24_diffGenes.csv
    Modified:   output/diff_genes/trisomy12_diffGenes.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 R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
Rmd 6c5aabc aluetge 2019-11-17 wflow_publish(“analysis/general_eda.Rmd”)

Hierarchical structure

Find variables that explain the data#s structure in ansupervised way using hierarchical clustering and Principal component analysis

suppressPackageStartupMessages({
  library(DESeq2)
  library(dplyr)
  library(ggplot2)
  library(tidyverse)
  library(ComplexHeatmap)
  library(ggpubr)
  library(RColorBrewer)
  library(circlize)
  library(here)
})

Data

data_dir <- here("data")
output_dir <- here("output")
figure_dir <- here("output/figures")

#dds data set. gene expression data + patmetadata
load(paste0(data_dir, "/ddsrnaCLL_150218.RData"))

#load meta data including genotyping info
load(paste0(data_dir, "/patmeta_170324.RData"))

normalize data

#Variance stabilization transformation of the raw data
ddsCLL <- estimateSizeFactors(ddsCLL)
RNAnorm <- varianceStabilizingTransformation(ddsCLL, blind=T)

Filter genes

exprMat <- assay(RNAnorm)

# filter IG genes
filtered <- as_tibble(rowData(ddsCLL)) %>% mutate(geneID = rownames(ddsCLL)) %>% filter(!grepl("IGH",symbol)) %>% filter(!grepl("IGK",symbol)) %>% filter(!grepl("IGL",symbol))  

exprMat <- exprMat[filtered$geneID,]

#top 500 most variant genes
sds <- rowSds(exprMat)
exprMat <- exprMat[order(sds, decreasing = T)[1:500],]
colnames(exprMat) <- colData(ddsCLL)$PatID
exprMat.new <- log2(exprMat)
exprMat.new <- t(scale(t(exprMat.new)))
exprMat.new[exprMat.new > 4] <- 4
exprMat.new[exprMat.new < -4] <- -4
rownames(exprMat.new) <- rowData(RNAnorm[rownames(exprMat),])$symbol

Hierarchical clustering - heatmap

#colors
colors = colorRamp2(c(-4,-1.5,0,1.5,4), c("#2166ac","#4393c3", "#f7f7f7", "#d6604d","#b2182b"))
annocol <- get_palette("jco", 10)
annocolor <- list(IGHV = c("M" = annocol[1], "U" = annocol[2]) , 
                  trisomy12 = c( "1" = annocol[8], "0" = annocol[4]), 
                  Methylation = c("IP" = annocol[5], "LP" = annocol[6], "HP" =  annocol[7]))


# Annotations
#Top annotations
ha_top = HeatmapAnnotation(df = data.frame(colData(RNAnorm)[, c("IGHV", "trisomy12", "Methylation")]), 
                           col = annocolor, annotation_width = unit(c(rep(4, 3)), "cm"), 
                           show_legend = FALSE, 
                           simple_anno_size = unit(1.3, "cm"),
                           annotation_name_gp = gpar(fontsize = 35),
                           annotation_legend_param = list(title_gp = gpar(fontsize = 70), 
                                                          labels_gp = gpar(fontsize = 55),  
                                                          grid_height = unit(3, "cm"), 
                                                          grid_width = unit(1.5, "cm"), 
                                                          gap = unit(2, "cm")))

# Annotration legend
anno_legend_list = lapply(ha_top@anno_list[c("IGHV", "trisomy12", "Methylation")], function(anno){
  color_mapping_legend(anno@color_mapping, plot = FALSE,
                       title_gp = gpar(fontsize = 45, fontface = "bold"),
                       grid_height = unit(1.5, "cm"),
                       grid_width = unit(0.5, "cm"),
                       labels_gp = gpar(fontsize = 35))
  })

#Annotate known genes from litertaure
marker_genes <- c("ADAM29", "ATM", "CLLU1", "DMD", "GLO1", "HCSL1", "KIAA0977", 
                  "LPL", "MGC9913", "PCDH9", "PEG10", "SEPT10", "TCF7", "TCL1", 
                  "TP53", "VIM", "ZAP70", "CD38")

geneIDs <- which(rownames(exprMat.new) %in% marker_genes)
labels <- rownames(exprMat.new)[geneIDs]
ha_genes <- rowAnnotation(link = row_anno_link(at = geneIDs, 
                                               labels = labels, 
                                               labels_gp = gpar(fontsize = 30)), 
                          width = unit(2.5, "cm"))
Warning: anno_link() is deprecated, please use anno_mark() instead.
h1 <- Heatmap(exprMat.new ,                                                     
              km = 3,
              gap = unit(0.5, "cm"),
              clustering_distance_columns = "euclidean",
              clustering_method_columns = "ward.D2",
              clustering_distance_rows = "pearson",
              clustering_method_rows = "ward.D2",                    
              col = colors,
              column_title_gp = gpar(fontsize = 60, fontface = "bold"), 
              column_dend_height = unit(2.5, "cm"),
              show_row_dend = FALSE, 
              show_column_names = FALSE , 
              show_row_names = FALSE, 
              row_names_gp = gpar(fontsize = 45),
              show_heatmap_legend = FALSE,
              top_annotation = ha_top, 
              right_annotation = ha_genes)

heatmap_legend = color_mapping_legend(h1@matrix_color_mapping, plot = FALSE, 
                                      title = "Expr", title_gp = gpar(fontsize = 45, fontface = "bold"),
                                      grid_height = unit(1.5, "cm"),
                                      grid_width = unit(0.5, "cm"),
                                      labels_gp = gpar(fontsize = 35))


# arrange annotations 
pd = packLegend(anno_legend_list[[1]], anno_legend_list[[2]], anno_legend_list[[3]], heatmap_legend, max_height = unit(20, "cm"), 
    column_gap = unit(1, "cm"))

pdf(file=paste0(output_dir, "/cluster500exprgenes.pdf"), width=20, height=20)
draw(h1 + ha_genes, heatmap_legend_list = pd)
dev.off()
png 
  2 
p1 <- draw(h1, heatmap_legend_list = pd)

#save to create figure using cowplot 
saveRDS(p1, paste0(output_dir, "/figures/r_objects/heatmap_top500genes.rds"))

Principal component analysis

#Plot PCA
exprMat <- assay(RNAnorm)

#top 5000 most variant genes
sds <- rowSds(exprMat)
na_ids <- which(is.na(ddsCLL$IGHV) | is.na(ddsCLL$trisomy12) | is.na(ddsCLL$Methylation))
exprMat <- exprMat[order(sds, decreasing = T)[1:500], -na_ids]


#Calculate PCA
pcaRes <- prcomp(t(exprMat), scale =T)
varExp <- (pcaRes$sdev^2 / sum(pcaRes$sdev^2)) * 100
pcaTab <- data.frame(pcaRes$x[,c(1:10)])
names(varExp) <- colnames(pcaRes$x)

#add background information
pcaTab <- cbind(pcaTab, data.frame(colData(RNAnorm)[-na_ids, ]))

#IGHV
p <- ggscatter(pcaTab, x = "PC1", y = "PC2", color = "IGHV", palette = "jco", size = 3,
  ylab = sprintf("PC2 (%2.1f%%)",varExp[2]), xlab = sprintf("PC1 (%2.1f%%)",varExp[1]), 
  legend = "right", main = "PCA IGHV status", 
  font.legend = c(23, "plain", "black"), 
  font.tickslab = c(23, "plain", "black"), 
  font.main = 25, font.submain = 28, font.caption = 28, font.x = 28, font.y= 28) + 
  coord_fixed()

p

#Tri12
p1 <- ggscatter(pcaTab, x = "PC1", y = "PC2", color = "trisomy12", size = 3,
  ylab = sprintf("PC2 (%2.1f%%)",varExp[2]), xlab = sprintf("PC1 (%2.1f%%)",varExp[1]), 
  legend = "right", main = "PCA trisomy12", 
  font.legend = c(23, "plain", "black"), 
  font.tickslab = c(23, "plain", "black"), 
  font.main = 25, font.submain = 28, font.caption = 28, font.x = 28, font.y= 28) + 
  coord_fixed() + 
  scale_colour_manual(values = c(annocol[4], annocol[8]))

p1

#Methylation
p2 <- ggscatter(pcaTab, x = "PC1", y = "PC2", color = "Methylation", size = 3,
  ylab = sprintf("PC2 (%2.1f%%)",varExp[2]), xlab = sprintf("PC1 (%2.1f%%)",varExp[1]), 
  legend = "right", main = "PCA Methylation - top 500 genes", 
  font.legend = c(23, "plain", "black"), 
  font.tickslab = c(23, "plain", "black"), 
  font.main = 25, font.submain = 28, font.caption = 28, font.x = 28, font.y= 28) + 
  coord_fixed() + 
  scale_colour_manual(values = c(annocol[7], annocol[5], annocol[6]))

p2

#Methylation reduced gene number
#change gene number only 300 top variant genes
#Plot PCA
exprMat <- assay(RNAnorm)

#top 5000 most variant genes
sds <- rowSds(exprMat)
na_ids <- which(is.na(ddsCLL$Methylation))
exprMat <- exprMat[order(sds, decreasing = T)[1:300], -na_ids]


#Calculate PCA
pcaRes <- prcomp(t(exprMat), scale =T)
varExp <- (pcaRes$sdev^2 / sum(pcaRes$sdev^2)) * 100
pcaTab <- data.frame(pcaRes$x[,c(1:10)])
names(varExp) <- colnames(pcaRes$x)

#add background information
pcaTab <- cbind(pcaTab, data.frame(colData(RNAnorm)[-na_ids, ]))

p3 <- ggscatter(pcaTab, x = "PC1", y = "PC2", color = "Methylation", size = 3,
  ylab = sprintf("PC2 (%2.1f%%)",varExp[2]), xlab = sprintf("PC1 (%2.1f%%)",varExp[1]), 
  legend = "right", main = "PCA Methylation - top 300 genes", 
  font.legend = c(23, "plain", "black"), 
  font.tickslab = c(23, "plain", "black"), 
  font.main = 25, font.submain = 28, font.caption = 28, font.x = 28, font.y= 28) + 
  coord_fixed() + 
  scale_colour_manual(values = c(annocol[7], annocol[5], annocol[6]))

p3

saveRDS(list("IGHV" = p, "trisomy12" = p1, "Methylation" = p2, "Methylation_red_genes" = p3), 
        file = paste0(output_dir, "/figures/r_objects/pca_top500genes.rds"))

sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=de_DE.UTF-8    
 [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=de_DE.UTF-8   
 [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] here_0.1                    circlize_0.4.6             
 [3] RColorBrewer_1.1-2          ggpubr_0.2                 
 [5] magrittr_1.5                ComplexHeatmap_2.0.0       
 [7] forcats_0.4.0               stringr_1.4.0              
 [9] purrr_0.3.2                 readr_1.3.1                
[11] tidyr_0.8.3                 tibble_2.1.3               
[13] tidyverse_1.2.1             ggplot2_3.1.1              
[15] dplyr_0.8.1                 DESeq2_1.24.0              
[17] SummarizedExperiment_1.14.0 DelayedArray_0.10.0        
[19] BiocParallel_1.18.0         matrixStats_0.54.0         
[21] Biobase_2.44.0              GenomicRanges_1.36.0       
[23] GenomeInfoDb_1.20.0         IRanges_2.18.1             
[25] S4Vectors_0.22.0            BiocGenerics_0.30.0        

loaded via a namespace (and not attached):
 [1] colorspace_1.4-1       rjson_0.2.20           rprojroot_1.3-2       
 [4] htmlTable_1.13.1       XVector_0.24.0         GlobalOptions_0.1.0   
 [7] base64enc_0.1-3        fs_1.3.1               clue_0.3-57           
[10] rstudioapi_0.10        bit64_0.9-7            AnnotationDbi_1.46.0  
[13] lubridate_1.7.4        xml2_1.2.0             splines_3.6.0         
[16] geneplotter_1.62.0     knitr_1.23             Formula_1.2-3         
[19] jsonlite_1.6           workflowr_1.4.0        broom_0.5.2           
[22] annotate_1.62.0        cluster_2.1.0          png_0.1-7             
[25] compiler_3.6.0         httr_1.4.0             backports_1.1.4       
[28] assertthat_0.2.1       Matrix_1.2-17          lazyeval_0.2.2        
[31] cli_1.1.0              acepack_1.4.1          htmltools_0.3.6       
[34] tools_3.6.0            gtable_0.3.0           glue_1.3.1            
[37] GenomeInfoDbData_1.2.1 Rcpp_1.0.1             cellranger_1.1.0      
[40] nlme_3.1-140           xfun_0.7               rvest_0.3.4           
[43] XML_3.98-1.20          zlibbioc_1.30.0        scales_1.0.0          
[46] hms_0.4.2              yaml_2.2.0             memoise_1.1.0         
[49] gridExtra_2.3          rpart_4.1-15           latticeExtra_0.6-28   
[52] stringi_1.4.3          RSQLite_2.1.1          genefilter_1.66.0     
[55] checkmate_1.9.3        shape_1.4.4            rlang_0.3.4           
[58] pkgconfig_2.0.2        bitops_1.0-6           evaluate_0.14         
[61] lattice_0.20-38        labeling_0.3           htmlwidgets_1.3       
[64] bit_1.1-14             tidyselect_0.2.5       ggsci_2.9             
[67] plyr_1.8.4             R6_2.4.0               generics_0.0.2        
[70] Hmisc_4.2-0            DBI_1.0.0              pillar_1.4.1          
[73] haven_2.1.0            whisker_0.3-2          foreign_0.8-71        
[76] withr_2.1.2            survival_2.44-1.1      RCurl_1.95-4.12       
[79] nnet_7.3-12            modelr_0.1.4           crayon_1.3.4          
[82] rmarkdown_1.13         GetoptLong_0.1.7       locfit_1.5-9.1        
[85] readxl_1.3.1           data.table_1.12.2      blob_1.1.1            
[88] git2r_0.25.2           digest_0.6.19          xtable_1.8-4          
[91] munsell_0.5.0