Last updated: 2019-05-17

Checks: 6 0

Knit directory: transcriptome_cll/

This reproducible R Markdown analysis was created with workflowr (version 1.3.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! 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

Untracked files:
    Untracked:  data/c2.cp.kegg.v6.0.symbols.gmt
    Untracked:  data/ddsrnaCLL_150218.RData
    Untracked:  docs/figure/SF3B1.Rmd/
    Untracked:  docs/figure/del11q22.Rmd/
    Untracked:  output/diff_genes/
    Untracked:  output/diff_meth.rds
    Untracked:  output/diff_meth_IGHV.rds
    Untracked:  output/figures/

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 5de142b aluetge 2019-05-17 Add more variants

BRAF signature

Differentially expressed genes

1. Differential expression analysis

load packages

library(DESeq2)
library(tidyverse)
library(ggsci)
library(matrixStats)
library(piano)
library(reshape2)
library(genefilter)
library(Biobase)
library(ComplexHeatmap)
library(ggplot2)
library(gtable)
library(grid)
library(circlize)
library(gridExtra)
library(ggpubr)
library(RColorBrewer)
library(here)

load 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"))

variant <- "BRAF"
#filter for patients without NA in variant
ddsCLL <- ddsCLL[, !is.na(colData(ddsCLL)[,variant])]

#differentially expressed genes between BRAF groups (see differential expression.html)
diff_all <- read.csv(file=paste0(output_dir, "/diff_genes/", variant, "_diffGenes.csv"))


rownames(diff_all) <- diff_all$X
diff_all <- diff_all[which(diff_all$padj < 0.01 ),-1]
diff <- diff_all[which(abs(diff_all$log2FoldChange) > 2 & diff_all$stat > 6),]


mutStatus <- data.frame(colData(ddsCLL)) %>% arrange(BRAF)
colnames(ddsCLL) <-colData(ddsCLL)$PatID
ddsCLL <- ddsCLL[, mutStatus$PatID]

#expression data
ddsCLL <- estimateSizeFactors(ddsCLL)
RNAnorm <- varianceStabilizingTransformation(ddsCLL, blind = T)

Expression matrix

#filter for sign. genes in variant
exprMat <- assay(RNAnorm)
exprVariant <- exprMat[rownames(diff),]
colnames(exprVariant) <- colData(ddsCLL)$PatID
exprVariant.new <- log2(exprVariant)
exprVariant.new <- t(scale(t(exprVariant.new)))
exprVariant.new[exprVariant.new > 4] <- 4
exprVariant.new[exprVariant.new < -4] <- -4
rownames(exprVariant.new) <- rowData(RNAnorm[rownames(diff),])$symbol

Expression signature

#colors
colors = colorRamp2(c(-4,-2,0,2,4), c("#2166ac","#4393c3", "#f7f7f7", "#d6604d","#b2182b"))
annocol <- get_palette("jco", 10)
annocolor <- list(BRAF = c("1" = annocol[8], "0" = annocol[9]))
rowcolors <-colorRampPalette(brewer.pal(5, "Set1"))(5)
rowcolors[6] <- "white"


feature <- as.data.frame(colData(ddsCLL)[,c(variant)])
colnames(feature) <- c(variant)  

ha_col <- HeatmapAnnotation(feature, col = annocolor, annotation_height = unit(c(rep(1.9, 1)), "cm"), annotation_legend_param = list(title_gp = gpar(fontsize = 50), labels_gp = gpar(fontsize = 45),  grid_height = unit(1.9, "cm"), grid_width = unit(1.9, "cm")))


h1 <- Heatmap(exprVariant.new ,                                                     
              km = 2,
              gap = unit(0.5, "cm"),
              cluster_columns = F,
              clustering_distance_rows = "pearson",
              clustering_method_rows = "ward.D2",
              column_title = paste0("Gene signature: ", variant),                      
              col = colors,
              column_title_gp = gpar(fontsize = 60, fontface = "bold"), 
              heatmap_legend_param = list(title = "expr", 
                                          title_gp = gpar(fontsize = 50), 
                                          grid_height = unit(1.9, "cm"), 
                                          grid_width = unit(1.9, "cm"), 
                                          gap = unit(2, "cm"), 
                                          labels_gp = gpar(fontsize = 45)), 
              column_dend_height = unit(2.5, "cm"),
              show_row_dend = FALSE, 
              show_column_names = FALSE , 
              show_row_names = TRUE, 
              row_names_gp = gpar(fontsize = 40),
              top_annotation = ha_col)


#svg(filename=paste0(figure_dir, "/", variant, "_gene_expr.svg"), width=30, height=45)
#pdf(file=paste0(figure_dir, "/", variant, "_gene_expr.pdf"), width=22, height=25)

draw(h1) 

#dev.off()

#draw(h1)

Sample and gene specific expression - top genes

#function to create stripchart plots for specific genes
gene_count <- function(gene_nam){
  geneEnsID <- rownames(ddsCLL)[which(rowData(ddsCLL)$symbol %in% gene_nam)]
  geneNum <- counts(ddsCLL)[geneEnsID,]
  mutPat <- as.data.frame(colData(ddsCLL)[, c(variant)])
  colnames(mutPat) <- c("genotype")
  geneDat <- cbind(mutPat, geneNum)
  colnames(geneDat) <- c("genotype", "counts")
  
  p <- ggstripchart(geneDat, x = "genotype", y = "counts",
          color = "genotype",
          palette = "jco",
          add = "mean_sd",
          title = paste(gene_nam),
          font.x = 18, font.y = 18, font.legend = 16, 
          ylab = "normalized counts") + font("xy.text", size = 15) + font("title", size = 20, face = "bold")
  #ggsave(file=paste0(figure_dir, "/tri12/genetic_interaction_", gene_nam, ".svg"), plot=p, width=6, height=5)
  p
}

geneList <- diff$Symbol[1:20]
geneList <- geneList[-which(geneList %in% "")]


lapply(geneList, gene_count)
[[1]]


[[2]]


[[3]]


[[4]]


[[5]]


[[6]]


[[7]]


[[8]]


[[9]]


[[10]]


[[11]]


[[12]]


[[13]]


[[14]]


[[15]]


[[16]]


[[17]]


[[18]]


[[19]]

Gene set enrichment analysis

Gene sets

#load gene set collection
#Hallmark
gsc <- loadGSC("/home/almut/Dokumente/masterarbeit/data/h.all.v6.0.symbols.gmt", type="gmt")
#Kegg
gsc_Kegg <- loadGSC("/home/almut/Dokumente/masterarbeit/data/c2.cp.kegg.v6.0.symbols.gmt", type="gmt")

Run piano

gmtFile <- gsc_Kegg

diff_res <- diff_all
diff_res <- diff_res[-which(diff_res$Symbol %in% c("", NA)),]

geneNam <- diff_res$Symbol 
pVal <- diff_res$padj
logFold <- diff_res$log2FoldChange
stat <- diff_res$stat
gsTab <- data.frame(gene = geneNam, stat = stat, logFold = logFold)
gsaTab <- data.frame(row.names = gsTab$gene, stat = gsTab$stat)
res <- runGSA(geneLevelStats = gsaTab,
                    geneSetStat = "gsea",
                    adjMethod = "fdr", gsc=gmtFile,
                    signifMethod = "geneSampling",
                    nPerm = 50000,
                    gsSizeLim=c(1, Inf))
Running gene set analysis:
Checking arguments...done!
*** Please note that running the GSEA-method may take a substantial amount of time! ***
Final gene/gene-set association: 48 genes and 60 gene sets
  Details:
  Calculating gene set statistics from 48 out of 225 gene-level statistics
  Using all 225 gene-level statistics for significance estimation
  Removed 5218 genes from GSC due to lack of matching gene statistics
  Removed 126 gene sets containing no genes after gene removal
  Removed additionally 0 gene sets not matching the size limits
  Loaded additional information for 60 gene sets
Calculating gene set statistics...done!
Calculating gene set significance...done!
Adjusting for multiple testing...done!
Res_up <- arrange(GSAsummaryTable(res), `p adj (dist.dir.up)`)            
Res_dn <- arrange(GSAsummaryTable(res), `p adj (dist.dir.dn)`)
  

#Plot
resPlot <- Res_up[, c(1:3,5,8,9)]
resPlot_dn <- Res_dn[, c(1:3,7,8,9)]
colnames(resPlot) <- c("pathway", "gene_number", "stat", "p.adj","genes_up" , "genes_dn")
colnames(resPlot_dn) <- c("pathway", "gene_number", "stat", "p.adj","genes_up" , "genes_dn")


enrichPlot <- resPlot_dn[c(1:6),] %>% mutate(log10Padj = -log10(p.adj)) 

#plot
p <- ggbarplot(enrichPlot, x = "pathway", y = "log10Padj",
          fill = "gene_number",         
          color = "white",            
          palette =  "gsea",            
          sort.val = "asc",         
          sort.by.groups = FALSE,     
          ylab = "-log10(padj)",
          legend.title = "#diff.genes",
          rotate = TRUE,
          font.x = 20, font.y = 20, font.legend = 20, legend = "right", 
          title = "BRAF - Kegg",
          ggtheme = theme_pubr()) + 
  font("xy.text", size = 16) + 
  font("title", size = 20, face = "bold")
  
#ggsave(file=paste0(figure_dir,"/GSEA_", variant, "_Kegg.svg"), plot=p, width=14, height=7)
  p


sessionInfo()
R version 3.5.3 (2019-03-11)
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] bindrcpp_0.2.2              here_0.1                   
 [3] RColorBrewer_1.1-2          ggpubr_0.2                 
 [5] magrittr_1.5                gridExtra_2.3              
 [7] circlize_0.4.5              gtable_0.2.0               
 [9] ComplexHeatmap_1.20.0       genefilter_1.64.0          
[11] reshape2_1.4.3              piano_1.22.0               
[13] ggsci_2.9                   forcats_0.3.0              
[15] stringr_1.3.1               dplyr_0.7.8                
[17] purrr_0.2.5                 readr_1.3.1                
[19] tidyr_0.8.2                 tibble_2.0.0               
[21] ggplot2_3.1.0               tidyverse_1.2.1            
[23] DESeq2_1.22.2               SummarizedExperiment_1.12.0
[25] DelayedArray_0.8.0          BiocParallel_1.16.5        
[27] matrixStats_0.54.0          Biobase_2.42.0             
[29] GenomicRanges_1.34.0        GenomeInfoDb_1.18.1        
[31] IRanges_2.16.0              S4Vectors_0.20.1           
[33] BiocGenerics_0.28.0        

loaded via a namespace (and not attached):
 [1] fgsea_1.8.0            colorspace_1.3-2       rjson_0.2.20          
 [4] rprojroot_1.3-2        htmlTable_1.13.1       XVector_0.22.0        
 [7] GlobalOptions_0.1.0    base64enc_0.1-3        fs_1.2.6              
[10] rstudioapi_0.9.0       bit64_0.9-7            AnnotationDbi_1.44.0  
[13] lubridate_1.7.4        xml2_1.2.0             splines_3.5.3         
[16] geneplotter_1.60.0     knitr_1.21             Formula_1.2-3         
[19] jsonlite_1.6           workflowr_1.3.0        broom_0.5.1           
[22] annotate_1.60.0        cluster_2.0.7-1        compiler_3.5.3        
[25] httr_1.4.0             backports_1.1.3        assertthat_0.2.0      
[28] Matrix_1.2-17          lazyeval_0.2.1         limma_3.38.3          
[31] cli_1.0.1              acepack_1.4.1          htmltools_0.3.6       
[34] tools_3.5.3            igraph_1.2.2           glue_1.3.0            
[37] GenomeInfoDbData_1.2.0 fastmatch_1.1-0        Rcpp_1.0.0            
[40] slam_0.1-44            cellranger_1.1.0       gdata_2.18.0          
[43] nlme_3.1-137           xfun_0.4               rvest_0.3.2           
[46] gtools_3.8.1           XML_3.98-1.16          zlibbioc_1.28.0       
[49] scales_1.0.0           relations_0.6-8        hms_0.4.2             
[52] sets_1.0-18            yaml_2.2.0             memoise_1.1.0         
[55] rpart_4.1-13           latticeExtra_0.6-28    stringi_1.2.4         
[58] RSQLite_2.1.1          checkmate_1.9.0        caTools_1.17.1.1      
[61] shape_1.4.4            rlang_0.3.1            pkgconfig_2.0.2       
[64] bitops_1.0-6           evaluate_0.12          lattice_0.20-38       
[67] bindr_0.1.1            labeling_0.3           htmlwidgets_1.3       
[70] bit_1.1-14             tidyselect_0.2.5       plyr_1.8.4            
[73] R6_2.3.0               gplots_3.0.1           generics_0.0.2        
[76] Hmisc_4.1-1            DBI_1.0.0              pillar_1.3.1          
[79] haven_2.0.0            whisker_0.3-2          foreign_0.8-71        
[82] withr_2.1.2            survival_2.43-3        RCurl_1.95-4.11       
[85] nnet_7.3-12            modelr_0.1.2           crayon_1.3.4          
[88] KernSmooth_2.23-15     rmarkdown_1.11         GetoptLong_0.1.7      
[91] locfit_1.5-9.1         readxl_1.2.0           data.table_1.11.8     
[94] marray_1.60.0          blob_1.1.1             git2r_0.25.2          
[97] digest_0.6.18          xtable_1.8-3           munsell_0.5.0