Last updated: 2023-11-01

Checks: 7 0

Knit directory: muse/

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.


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(20200712) 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 3e13eb5. 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:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/cbioportal_cache/
    Ignored:    r_packages_4.3.2/

Untracked files:
    Untracked:  analysis/cell_ranger.Rmd
    Untracked:  analysis/sleuth.Rmd
    Untracked:  analysis/tss_xgboost.Rmd
    Untracked:  code/multiz100way/
    Untracked:  data/HG00702_SH089_CHSTrio.chr1.vcf.gz
    Untracked:  data/HG00702_SH089_CHSTrio.chr1.vcf.gz.tbi
    Untracked:  data/ncrna_NONCODE[v3.0].fasta.tar.gz
    Untracked:  data/ncrna_noncode_v3.fa
    Untracked:  data/netmhciipan.out.gz
    Untracked:  export/davetang039sblog.WordPress.2023-06-30.xml
    Untracked:  export/output/
    Untracked:  women.json

Unstaged changes:
    Modified:   analysis/graph.Rmd

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/complex_heatmap.Rmd) and HTML (docs/complex_heatmap.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 3e13eb5 Dave Tang 2023-11-01 ComplexHeatmap

Install latest version from GitHub.

remotes::install_github("jokergoo/ComplexHeatmap")

Load library.

library(ComplexHeatmap)

Download example data.

example_file <- "https://davetang.org/file/TagSeqExample.tab"
data <- read.delim(example_file, header = TRUE, row.names = "gene")
data_subset <- as.matrix(data[rowSums(data)>50000,])
dim(data_subset)
[1] 49  6

Default heatmap for ComplexHeatmap.

Heatmap(data_subset)

Normalise using z-score.

cal_z_score <- function(x){
  (x - mean(x)) / sd(x)
}

data_subset_norm <- t(apply(data_subset, 1, cal_z_score))
Heatmap(data_subset_norm)

Add a title using column_title; the name parameter puts a title of the heatmap legend.

Heatmap(data_subset_norm, column_title = "My title", name = "Legend")

Two heatmaps.

one <- Heatmap(data_subset, column_title = "Raw", name = "Raw")
two <- Heatmap(data_subset_norm, column_title = "Scaled", name = "Scaled")

one + two

Add annotations.

set.seed(123)
mat <- matrix(rnorm(100), 10)
rownames(mat) = paste0("R", 1:10)
colnames(mat) = paste0("C", 1:10)

column_ha = HeatmapAnnotation(
  foo1 = rep(c('N', 'T'), 5),
  bar1 = anno_barplot(colMeans(mat))
)

row_ha = rowAnnotation(
  foo2 = runif(10),
  bar2 = anno_barplot(rowMeans(mat))
)

Heatmap(mat, name = "mat", top_annotation = column_ha, right_annotation = row_ha)

Heatmap split.

Heatmap(mat, name = "mat", row_km = 3, column_km = 3)


sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [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       

time zone: Etc/UTC
tzcode source: system (glibc)

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

other attached packages:
[1] ComplexHeatmap_2.15.4 gridExtra_2.3         dendextend_1.17.1    
[4] pheatmap_1.0.12       workflowr_1.7.1      

loaded via a namespace (and not attached):
 [1] shape_1.4.6         circlize_0.4.15     gtable_0.3.4       
 [4] rjson_0.2.21        xfun_0.40           bslib_0.5.1        
 [7] ggplot2_3.4.4       GlobalOptions_0.1.2 processx_3.8.2     
[10] callr_3.7.3         vctrs_0.6.4         tools_4.3.2        
[13] ps_1.7.5            generics_0.1.3      stats4_4.3.2       
[16] parallel_4.3.2      tibble_3.2.1        fansi_1.0.5        
[19] cluster_2.1.4       pkgconfig_2.0.3     RColorBrewer_1.1-3 
[22] S4Vectors_0.40.1    lifecycle_1.0.3     compiler_4.3.2     
[25] stringr_1.5.0       git2r_0.32.0        munsell_0.5.0      
[28] getPass_0.2-2       codetools_0.2-19    clue_0.3-65        
[31] httpuv_1.6.12       htmltools_0.5.6.1   sass_0.4.7         
[34] yaml_2.3.7          later_1.3.1         pillar_1.9.0       
[37] crayon_1.5.2        jquerylib_0.1.4     whisker_0.4.1      
[40] cachem_1.0.8        iterators_1.0.14    viridis_0.6.4      
[43] foreach_1.5.2       tidyselect_1.2.0    digest_0.6.33      
[46] stringi_1.7.12      dplyr_1.1.3         rprojroot_2.0.3    
[49] fastmap_1.1.1       colorspace_2.1-0    cli_3.6.1          
[52] magrittr_2.0.3      utf8_1.2.4          scales_1.2.1       
[55] promises_1.2.1      rmarkdown_2.25      httr_1.4.7         
[58] matrixStats_1.0.0   png_0.1-8           GetoptLong_1.0.5   
[61] evaluate_0.22       knitr_1.44          IRanges_2.36.0     
[64] doParallel_1.0.17   viridisLite_0.4.2   rlang_1.1.1        
[67] Rcpp_1.0.11         glue_1.6.2          BiocGenerics_0.48.0
[70] rstudioapi_0.15.0   jsonlite_1.8.7      R6_2.5.1           
[73] fs_1.6.3