Back to Multiple platform build/check report for BioC 3.13 |
|
This page was generated on 2021-10-15 15:05:38 -0400 (Fri, 15 Oct 2021).
To the developers/maintainers of the ComplexHeatmap package: - Please allow up to 24 hours (and sometimes 48 hours) for your latest push to git@git.bioconductor.org:packages/ComplexHeatmap.git to reflect on this report. See How and When does the builder pull? When will my changes propagate? here for more information. - Make sure to use the following settings in order to reproduce any error or warning you see on this page. |
Package 372/2041 | Hostname | OS / Arch | INSTALL | BUILD | CHECK | BUILD BIN | ||||||||
ComplexHeatmap 2.8.0 (landing page) Zuguang Gu
| nebbiolo1 | Linux (Ubuntu 20.04.2 LTS) / x86_64 | OK | OK | OK | |||||||||
tokay2 | Windows Server 2012 R2 Standard / x64 | OK | OK | OK | OK | |||||||||
machv2 | macOS 10.14.6 Mojave / x86_64 | OK | OK | OK | OK | |||||||||
Package: ComplexHeatmap |
Version: 2.8.0 |
Command: /home/biocbuild/bbs-3.13-bioc/R/bin/R CMD check --install=check:ComplexHeatmap.install-out.txt --library=/home/biocbuild/bbs-3.13-bioc/R/library --no-vignettes --timings ComplexHeatmap_2.8.0.tar.gz |
StartedAt: 2021-10-14 09:21:20 -0400 (Thu, 14 Oct 2021) |
EndedAt: 2021-10-14 09:26:02 -0400 (Thu, 14 Oct 2021) |
EllapsedTime: 281.9 seconds |
RetCode: 0 |
Status: OK |
CheckDir: ComplexHeatmap.Rcheck |
Warnings: 0 |
############################################################################## ############################################################################## ### ### Running command: ### ### /home/biocbuild/bbs-3.13-bioc/R/bin/R CMD check --install=check:ComplexHeatmap.install-out.txt --library=/home/biocbuild/bbs-3.13-bioc/R/library --no-vignettes --timings ComplexHeatmap_2.8.0.tar.gz ### ############################################################################## ############################################################################## * using log directory ‘/home/biocbuild/bbs-3.13-bioc/meat/ComplexHeatmap.Rcheck’ * using R version 4.1.1 (2021-08-10) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using option ‘--no-vignettes’ * checking for file ‘ComplexHeatmap/DESCRIPTION’ ... OK * checking extension type ... Package * this is package ‘ComplexHeatmap’ version ‘2.8.0’ * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘ComplexHeatmap’ can be installed ... OK * checking installed package size ... OK * checking package directory ... OK * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking files in ‘vignettes’ ... OK * checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... Running ‘test-AnnotationFunction.R’ Running ‘test-ColorMapping-class.R’ Running ‘test-Heatmap-class.R’ Running ‘test-Heatmap-cluster.R’ Running ‘test-HeatmapAnnotation.R’ Running ‘test-HeatmapList-class.R’ Running ‘test-Legend.R’ Running ‘test-SingleAnnotation.R’ Running ‘test-annotation_axis.R’ Running ‘test-dendrogram.R’ Running ‘test-gridtext.R’ Running ‘test-interactive.R’ Running ‘test-multiple-page.R’ Running ‘test-oncoPrint.R’ Running ‘test-pheatmap.R’ Running ‘test-upset.R’ Running ‘test-utils.R’ Running ‘testthat-all.R’ OK * checking for unstated dependencies in vignettes ... OK * checking package vignettes in ‘inst/doc’ ... OK * checking running R code from vignettes ... SKIPPED * checking re-building of vignette outputs ... SKIPPED * checking PDF version of manual ... OK * DONE Status: OK
ComplexHeatmap.Rcheck/00install.out
############################################################################## ############################################################################## ### ### Running command: ### ### /home/biocbuild/bbs-3.13-bioc/R/bin/R CMD INSTALL ComplexHeatmap ### ############################################################################## ############################################################################## * installing to library ‘/home/biocbuild/bbs-3.13-bioc/R/library’ * installing *source* package ‘ComplexHeatmap’ ... ** using staged installation ** R ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** testing if installed package can be loaded from temporary location ** testing if installed package can be loaded from final location ** testing if installed package keeps a record of temporary installation path * DONE (ComplexHeatmap)
ComplexHeatmap.Rcheck/tests/test-annotation_axis.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > > > gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, + side = "left", facing = "outside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "left", facing = "outside"') > grid.draw(gb) > popViewport() > > gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, + side = "left", facing = "inside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "left", facing = "inside"') > grid.draw(gb) > popViewport() > > gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, + side = "right", facing = "outside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "right", facing = "outside"') > grid.draw(gb) > popViewport() > > gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, + side = "right", facing = "inside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "right", facing = "inside"') > grid.draw(gb) > popViewport() > > gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 0, + side = "top", facing = "outside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "top", facing = "outside"') > grid.draw(gb) > popViewport() > > gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 90, + side = "top", facing = "outside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "top", facing = "outside"') > grid.draw(gb) > popViewport() > > gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 45, + side = "top", facing = "outside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "top", facing = "outside"') > grid.draw(gb) > popViewport() > > gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 0, + side = "top", facing = "inside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "top", facing = "inside"') > grid.draw(gb) > popViewport() > > gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 0, + side = "bottom", facing = "outside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "bottom", facing = "outside"') > grid.draw(gb) > popViewport() > > gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 0, + side = "bottom", facing = "inside") > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > grid.rect() > grid.text('side = "bottom", facing = "inside"') > grid.draw(gb) > popViewport() > > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > gb = annotation_axis_grob(labels_rot = 0, side = "left", facing = "outside") > grid.rect() > grid.text('side = "left", facing = "outside"') > grid.draw(gb) > popViewport() > > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > gb = annotation_axis_grob(side = "left", direction = "reverse") > grid.rect() > grid.text('side = "left", direction = "reverse') > grid.draw(gb) > popViewport() > > grid.newpage() > pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) > gb = annotation_axis_grob(side = "bottom", direction = "reverse") > grid.rect() > grid.text('side = "bottom", direction = "reverse"') > grid.draw(gb) > popViewport() > > > > proc.time() user system elapsed 2.131 0.147 2.265
ComplexHeatmap.Rcheck/tests/test-AnnotationFunction.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > if(!exists("normalize_graphic_param_to_mat")) { + normalize_graphic_param_to_mat = ComplexHeatmap:::normalize_graphic_param_to_mat + } > > if(!exists("height")) { + height = ComplexHeatmap:::height + } > > if(!exists("width")) { + width = ComplexHeatmap:::width + } > > normalize_graphic_param_to_mat(1, nc = 2, nr = 4, "foo") [,1] [,2] [1,] 1 1 [2,] 1 1 [3,] 1 1 [4,] 1 1 > normalize_graphic_param_to_mat(1:2, nc = 2, nr = 4, "foo") [,1] [,2] [1,] 1 2 [2,] 1 2 [3,] 1 2 [4,] 1 2 > normalize_graphic_param_to_mat(1:4, nc = 2, nr = 4, "foo") [,1] [,2] [1,] 1 1 [2,] 2 2 [3,] 3 3 [4,] 4 4 > > ### AnnotationFunction constructor ##### > fun = function(index) { + x = runif(10) + pushViewport(viewport(xscale = c(0.5, 10.5), yscale = c(0, 1))) + grid.points(index, x[index]) + popViewport() + } > anno = AnnotationFunction(fun = fun) > > x = runif(10) > fun = function(index) { + pushViewport(viewport(xscale = c(0.5, 10.5), yscale = c(0, 1))) + grid.points(index, x[index]) + popViewport() + } > anno = AnnotationFunction(fun = fun, var_import = "x") > anno = AnnotationFunction(fun = fun, var_import = list(x)) > > > # devAskNewPage(ask = dev.interactive()) > > ########### testing anno_simple ############ > anno = anno_simple(1:10) > draw(anno, test = "as a simple vector") > draw(anno[1:5], test = "subset of column annotation") > anno = anno_simple(1:10, which = "row") > draw(anno, test = "as row annotation") > draw(anno[1:5], test = "subste of row annotation") > > anno = anno_simple(1:10, col = structure(rand_color(10), names = 1:10)) > draw(anno, test = "self-define colors") > > anno = anno_simple(1:10, border = TRUE) > draw(anno, test = "border") > anno = anno_simple(1:10, gp = gpar(col = "red")) > draw(anno, test = "gp for the grids") > > anno = anno_simple(c(1:9, NA)) > draw(anno, test = "vector has NA values") > > anno = anno_simple(cbind(1:10, 10:1)) > draw(anno, test = "a matrix") > draw(anno[1:5], test = "subste of a matrix") > > anno = anno_simple(1:10, pch = 1, pt_gp = gpar(col = "red"), pt_size = unit(seq(1, 10), "mm")) > draw(anno, test = "with symbols + pt_gp + pt_size") > anno = anno_simple(1:10, pch = 1:10) > draw(anno, test = "pch is a vector") > anno = anno_simple(1:10, pch = c(1:4, NA, 6:8, NA, 10, 11)) > draw(anno, test = "pch has NA values") > > anno = anno_simple(cbind(1:10, 10:1), pch = 1, pt_gp = gpar(col = "blue")) > draw(anno, test = "matrix with symbols") > anno = anno_simple(cbind(1:10, 10:1), pch = 1:2) > draw(anno, test = "matrix, length of pch is number of annotations") > anno = anno_simple(cbind(1:10, 10:1), pch = 1:10) > draw(anno, test = "matrix, length of pch is length of samples") > anno = anno_simple(cbind(1:10, 10:1), pch = matrix(1:20, nc = 2)) > draw(anno, test = "matrix, pch is a matrix") > pch = matrix(1:20, nc = 2) > pch[sample(length(pch), 10)] = NA > anno = anno_simple(cbind(1:10, 10:1), pch = pch) > draw(anno, test = "matrix, pch is a matrix with NA values") > > > ####### test anno_empty ###### > anno = anno_empty() > draw(anno, test = "anno_empty") > anno = anno_empty(border = FALSE) > draw(anno, test = "anno_empty without border") > > if(0) { + ###### test anno_image ##### + image1 = sample(dir("~/Downloads/IcoMoon-Free-master/PNG/64px", full.names = TRUE), 10) + anno = anno_image(image1) + draw(anno, test = "png") + draw(anno[1:5], test = "subset of png") + anno = anno_image(image1, which = "row") + draw(anno, test = "png on rows") + image2 = sample(dir("~/Downloads/IcoMoon-Free-master/SVG/", full.names = TRUE), 10) + anno = anno_image(image2) + draw(anno, test = "svg") + image3 = sample(dir("~/Downloads/IcoMoon-Free-master/EPS/", full.names = TRUE), 10) + anno = anno_image(image3) + draw(anno, test = "eps") + image4 = sample(dir("~/Downloads/IcoMoon-Free-master/PDF/", full.names = TRUE), 10) + anno = anno_image(image4) + draw(anno, test = "pdf") + + anno = anno_image(c(image1[1:3], image2[1:3], image3[1:3], image4[1:3])) + draw(anno, test = "png+svg+eps+pdf") + + anno = anno_image(image1, gp = gpar(fill = 1:10, col = "black")) + draw(anno, test = "png + gp") + draw(anno[1:5], test = "png + gp") + + anno = anno_image(image1, space = unit(3, "mm")) + draw(anno, test = "space") + + image1[1] = "" + anno = anno_image(image1) + draw(anno, test = "png") + } > > ######## test anno_points ##### > anno = anno_points(runif(10)) > draw(anno, test = "anno_points") > anno = anno_points(matrix(runif(20), nc = 2), pch = 1:2) > draw(anno, test = "matrix") > anno = anno_points(c(1:5, 1:5)) > draw(anno, test = "anno_points") > anno = anno_points(cbind(c(1:5, 1:5), c(5:1, 5:1)), gp = gpar(col = 2:3)) > draw(anno, test = "matrix") > > anno = anno_points(1:10, gp = gpar(col = rep(2:3, each = 5)), pch = rep(2:3, each = 5)) > draw(anno, test = "anno_points") > draw(anno, index = c(1, 3, 5, 7, 9, 2, 4, 6, 8, 10), test = "anno_points") > > anno = anno_points(c(1:5, NA, 7:10)) > draw(anno, test = "anno_points") > > > anno = anno_points(runif(10), axis_param = list(direction = "reverse"), ylim = c(0, 1)) > draw(anno, test = "anno_points") > > anno = anno_points(runif(10), axis_param = list(direction = "reverse"), ylim = c(0, 1), which = "row") > draw(anno, test = "anno_points") > > # pch as image > if(0) { + image1 = sample(dir("/desktop-home/guz/Downloads/IcoMoon-Free-master/PNG/64px", full.names = TRUE), 10) + x = runif(10) + anno1 = anno_points(x, pch = image1, pch_as_image = TRUE, size = unit(5, "mm"), height = unit(4, "cm")) + anno2 = anno_points(x, height = unit(4, "cm")) + draw(anno1, test = "anno_points") + draw(anno2, test = "anno_points") + } > > ##### test anno_lines ### > anno = anno_lines(runif(10)) > draw(anno, test = "anno_lines") > anno = anno_lines(cbind(c(1:5, 1:5), c(5:1, 5:1)), gp = gpar(col = 2:3)) > draw(anno, test = "matrix") > anno = anno_lines(cbind(c(1:5, 1:5), c(5:1, 5:1)), gp = gpar(col = 2:3), + add_points = TRUE, pt_gp = gpar(col = 5:6), pch = c(1, 16)) > draw(anno, test = "matrix") > anno = anno_lines(sort(rnorm(10)), height = unit(2, "cm"), smooth = TRUE, add_points = TRUE) > draw(anno, test = "anno_lines, smooth") > anno = anno_lines(cbind(sort(rnorm(10)), sort(rnorm(10), decreasing = TRUE)), + height = unit(2, "cm"), smooth = TRUE, add_points = TRUE, gp = gpar(col = 2:3)) > draw(anno, test = "anno_lines, smooth, matrix") > > anno = anno_lines(sort(rnorm(10)), width = unit(2, "cm"), smooth = TRUE, add_points = TRUE, which = "row") > draw(anno, test = "anno_lines, smooth, by row") > anno = anno_lines(cbind(sort(rnorm(10)), sort(rnorm(10), decreasing = TRUE)), + width = unit(2, "cm"), smooth = TRUE, add_points = TRUE, gp = gpar(col = 2:3), which = "row") > draw(anno, test = "anno_lines, smooth, matrix, by row") > > anno = anno_lines(c(1:5, NA, 7:10)) > draw(anno, test = "anno_lines") > > anno = anno_lines(runif(10), axis_param = list(direction = "reverse")) > draw(anno, test = "anno_lines") > > ###### test anno_text ####### > anno = anno_text(month.name) > draw(anno, test = "month names") > anno = anno_text(month.name, gp = gpar(fontsize = 16)) > draw(anno, test = "month names with fontsize") > anno = anno_text(month.name, gp = gpar(fontsize = 1:12+4)) > draw(anno, test = "month names with changing fontsize") > anno = anno_text(month.name, which = "row") > draw(anno, test = "month names on rows") > anno = anno_text(month.name, location = 0, rot = 45, just = "left", gp = gpar(col = 1:12)) > draw(anno, test = "with rotations") > anno = anno_text(month.name, location = 1, rot = 45, just = "right", gp = gpar(fontsize = 1:12+4)) > draw(anno, test = "with rotations") > > > for(rot in seq(0, 360, by = 45)) { + anno = anno_text(month.name, which = "row", location = 0, rot = rot, + just = "left") + draw(anno, test = paste0("rot =", rot)) + } > > > ##### test anno_barplot ##### > anno = anno_barplot(1:10) > draw(anno, test = "a vector") > draw(anno[1:5], test = "a vector, subset") > anno = anno_barplot(1:10, which = "row") > draw(anno, test = "a vector") > anno = anno_barplot(1:10, bar_width = 1) > draw(anno, test = "bar_width") > anno = anno_barplot(1:10, gp = gpar(fill = 1:10)) > draw(anno, test = "fill colors") > > anno = anno_barplot(matrix(nc = 2, c(1:10, 10:1))) > draw(anno, test = "a matrix") > draw(anno[1:5], test = "a matrix, subset") > anno = anno_barplot(matrix(nc = 2, c(1:10, 10:1)), which = "row") > draw(anno, test = "a matrix, on rows") > anno = anno_barplot(matrix(nc = 2, c(1:10, 10:1)), gp = gpar(fill = 2:3, col = 2:3)) > draw(anno, test = "a matrix with fill") > > m = matrix(runif(4*10), nc = 4) > m = t(apply(m, 1, function(x) x/sum(x))) > anno = anno_barplot(m) > draw(anno, test = "proportion matrix") > anno = anno_barplot(m, gp = gpar(fill = 2:5), bar_width = 1, height = unit(6, "cm")) > draw(anno, test = "proportion matrix") > > anno = anno_barplot(c(1:5, NA, 7:10)) > draw(anno, test = "a vector") > > anno = anno_barplot(1:10, which = "row", axis_param = list(direction = "reverse")) > draw(anno, test = "a vector") > > anno = anno_barplot(1:10, baseline = 5, which = "row", axis_param = list(direction = "reverse")) > draw(anno, test = "a vector") > > anno = anno_barplot(matrix(nc = 2, c(1:10, 10:1)), which = "row", axis_param = list(direction = "reverse")) > draw(anno, test = "a vector") > > > ##### test anno_boxplot ##### > set.seed(123) > m = matrix(rnorm(100), 10) > anno = anno_boxplot(m, height = unit(4, "cm")) > draw(anno, test = "anno_boxplot") > draw(anno[1:5], test = "subset") > anno = anno_boxplot(m, height = unit(4, "cm"), gp = gpar(fill = 1:10)) > draw(anno, test = "anno_boxplot with gp") > anno = anno_boxplot(m, height = unit(4, "cm"), box_width = 0.9) > draw(anno, test = "anno_boxplot with box_width") > > m = matrix(rnorm(100), 10) > m[1, ] = NA > anno = anno_boxplot(m, height = unit(4, "cm")) > draw(anno, test = "anno_boxplot") > > > ####### test anno_joyplot #### > m = matrix(rnorm(1000), nc = 10) > lt = apply(m, 2, function(x) data.frame(density(x)[c("x", "y")])) > anno = anno_joyplot(lt, width = unit(4, "cm"), which = "row") > draw(anno, test = "joyplot") > anno = anno_joyplot(lt, width = unit(4, "cm"), which = "row", gp = gpar(fill = 1:10)) > draw(anno, test = "joyplot + col") > anno = anno_joyplot(lt, width = unit(4, "cm"), which = "row", scale = 1) > draw(anno, test = "joyplot + scale") > > m = matrix(rnorm(5000), nc = 50) > lt = apply(m, 2, function(x) data.frame(density(x)[c("x", "y")])) > anno = anno_joyplot(lt, width = unit(4, "cm"), which = "row", gp = gpar(fill = NA), scale = 4) > draw(anno, test = "joyplot") > > ######## test anno_horizon ###### > lt = lapply(1:20, function(x) cumprod(1 + runif(1000, -x/100, x/100)) - 1) > anno = anno_horizon(lt, which = "row") > draw(anno, test = "horizon chart") > anno = anno_horizon(lt, which = "row", gp = gpar(pos_fill = "orange", neg_fill = "darkgreen")) > draw(anno, test = "horizon chart, col") > anno = anno_horizon(lt, which = "row", negative_from_top = TRUE) > draw(anno, test = "horizon chart + negative_from_top") > anno = anno_horizon(lt, which = "row", gap = unit(1, "mm")) > draw(anno, test = "horizon chart + gap") > anno = anno_horizon(lt, which = "row", gp = gpar(pos_fill = rep(c("orange", "red"), each = 10), + neg_fill = rep(c("darkgreen", "blue"), each = 10))) > draw(anno, test = "horizon chart, col") > > ####### test anno_histogram #### > m = matrix(rnorm(1000), nc = 10) > anno = anno_histogram(t(m), which = "row") > draw(anno, test = "row histogram") > draw(anno[1:5], test = "subset row histogram") > anno = anno_histogram(t(m), which = "row", gp = gpar(fill = 1:10)) > draw(anno, test = "row histogram with color") > anno = anno_histogram(t(m), which = "row", n_breaks = 20) > draw(anno, test = "row histogram with color") > m[1, ] = NA > anno = anno_histogram(t(m), which = "row") > draw(anno, test = "row histogram") > > > ####### test anno_density ###### > anno = anno_density(t(m), which = "row") > draw(anno, test = "normal density") > draw(anno[1:5], test = "normal density, subset") > anno = anno_density(t(m), which = "row", type = "violin") > draw(anno, test = "violin") > anno = anno_density(t(m), which = "row", type = "heatmap") > draw(anno, test = "heatmap") > anno = anno_density(t(m), which = "row", type = "heatmap", heatmap_colors = c("white", "orange")) > draw(anno, test = "heatmap, colors") > > > ###### anno_mark ### > if(0) { + library(gridtext) + grid.text = function(text, x = 0.5, y = 0.5, gp = gpar(), rot = 0, default.units = "npc", just = "center") { + if(length(just) == 1) { + if(just == "center") { + just = c("center", "center") + } else if(just == "bottom") { + just = c("center", "bottom") + } else if (just == "top") { + just = c("center", "top") + } else if(just == "left") { + just = c("left", "center") + } else if(just == "right") { + just = c("right", "center") + } + } + just2 = c(0.5, 0.5) + if(is.character(just)) { + just2[1] = switch(just[1], "center" = 0.5, "left" = 0, "right" = 1) + just2[2] = switch(just[2], "center" = 0.5, "bottom" = 0, "top" = 1) + } + gb = richtext_grob(text, x = x, y = y, gp = gpar(fontsize = 10), box_gp = gpar(col = "black"), + default.units = default.units, hjust = just2[1], vjust = just2[2], rot = rot) + grid.draw(gb) + } + } > anno = anno_mark(at = c(1:4, 20, 60, 97:100), labels = month.name[1:10], which = "row") > draw(anno, index = 1:100, test = "anno_mark") > > anno = anno_mark(at = c(1:4, 20, 60, 97:100), labels = month.name[1:10], labels_rot = 30, which = "column") > draw(anno, index = 1:100, test = "anno_mark") > > m = matrix(1:1000, byrow = TRUE, nr = 100) > anno = anno_mark(at = c(1:4, 20, 60, 97:100), labels = month.name[1:10], which = "row", labels_rot = 30) > Heatmap(m, cluster_rows = F, cluster_columns = F) + rowAnnotation(mark = anno) > Heatmap(m) + rowAnnotation(mark = anno) > > ht_list = Heatmap(m, cluster_rows = F, cluster_columns = F) + rowAnnotation(mark = anno) > draw(ht_list, row_split = c(rep("a", 95), rep("b", 5))) > > > grid.newpage() > pushViewport(viewport(x = 0.45, w = 0.7, h = 0.95)) > h = unit(0, "mm") > for(rot in seq(0, 360, by = 30)[-13]) { + anno = anno_mark(at = c(1:4, 20, 60, 97:100), labels = strrep(letters[1:10], 4), labels_rot = rot, which = "column", side = "bottom") + h = h + height(anno) + pushViewport(viewport(y = h, height = height(anno), just = "top")) + grid.rect() + draw(anno, index = 1:100) + grid::grid.text(qq("labels_rot = @{rot}"), unit(1, "npc") + unit(2, "mm"), just = "left") + popViewport() + } > > > grid.newpage() > pushViewport(viewport(w = 0.9, h = 0.9)) > w = unit(0, "mm") > for(rot in seq(0, 360, by = 30)) { + anno = anno_mark(at = c(1:4, 20, 60, 97:100), labels = strrep(letters[1:10], 4), labels_rot = rot, which = "row", side = "left") + w = w + width(anno) + pushViewport(viewport(x = w, width = width(anno), just = "right")) + grid.rect() + draw(anno, index = 1:100) + popViewport() + } > > > > ### graphic parameters after reordering > index = c(1, 3, 5, 7, 9, 2, 4, 6, 8, 10) > anno = anno_simple(1:10, pch = 1:10, pt_gp = gpar(col = rep(c(1, 2), each = 5)), + pt_size = unit(1:10, "mm")) > draw(anno, index, test = "a numeric vector") > anno = anno_simple(1:10, pch = 1:10, pt_gp = gpar(col = rep(c(1, 2), each = 5)), + pt_size = unit(1:10, "mm"), which = "row") > draw(anno, index, test = "a numeric vector") > > > anno = anno_points(1:10, pch = 1:10, gp = gpar(col = rep(c(1, 2), each = 5)), + size = unit(1:10, "mm")) > draw(anno, index, test = "a numeric vector") > anno = anno_points(1:10, pch = 1:10, gp = gpar(col = rep(c(1, 2), each = 5)), + size = unit(1:10, "mm"), which = "row") > draw(anno, index, test = "a numeric vector") > > > anno = anno_lines(sort(runif(10)), pch = 1:10, pt_gp = gpar(col = rep(c(1, 2), each = 5)), + size = unit(1:10, "mm"), add_points = TRUE) > draw(anno, index, test = "a numeric vector") > anno = anno_lines(sort(runif(10)), pch = 1:10, pt_gp = gpar(col = rep(c(1, 2), each = 5)), + size = unit(1:10, "mm"), add_points = TRUE, which = "row") > draw(anno, index, test = "a numeric vector") > > > anno = anno_barplot(1:10, gp = gpar(fill = rep(c(1, 2), each = 5))) > draw(anno, index, test = "a numeric vector") > anno = anno_barplot(1:10, gp = gpar(fill = rep(c(1, 2), each = 5)), which = "row") > draw(anno, index, test = "a numeric vector") > > anno = anno_barplot(cbind(1:10, 10:1), gp = gpar(fill = 1:2)) > draw(anno, index, test = "a numeric vector") > anno = anno_barplot(cbind(1:10, 10:1), gp = gpar(fill = 1:2), which = "row") > draw(anno, index, test = "a numeric vector") > > > m = matrix(rnorm(100), 10) > m = m[, order(apply(m, 2, median))] > anno = anno_boxplot(m, pch = 1:10, gp = gpar(fill = rep(c(1, 2), each = 5)), + size = unit(1:10, "mm"), height = unit(4, "cm")) > draw(anno, index, test = "a numeric vector") > anno = anno_boxplot(t(m), pch = 1:10, gp = gpar(fill = rep(c(1, 2), each = 5)), + size = unit(1:10, "mm"), which = "row", width = unit(4, "cm")) > draw(anno, index, test = "a numeric vector") > > anno = anno_histogram(m, gp = gpar(fill = rep(c(1, 2), each = 5))) > draw(anno, index, test = "a numeric vector") > anno = anno_histogram(t(m), gp = gpar(fill = rep(c(1, 2), each = 5)), which = "row") > draw(anno, index, test = "a numeric vector") > > anno = anno_density(m, gp = gpar(fill = rep(c(1, 2), each = 5))) > draw(anno, index, test = "a numeric vector") > anno = anno_density(t(m), gp = gpar(fill = rep(c(1, 2), each = 5)), which = "row") > draw(anno, index, test = "a numeric vector") > > > anno = anno_density(m, type = "violin", gp = gpar(fill = rep(c(1, 2), each = 5))) > draw(anno, index, test = "a numeric vector") > anno = anno_density(t(m), type = "violin", gp = gpar(fill = rep(c(1, 2), each = 5)), which = "row") > draw(anno, index, test = "a numeric vector") > > > anno = anno_text(month.name, gp = gpar(col = rep(c(1, 2), each = 5))) > draw(anno, index, test = "a numeric vector") > anno = anno_text(month.name, gp = gpar(col = rep(c(1, 2), each = 5)), which= "row") > draw(anno, index, test = "a numeric vector") > > lt = lapply(1:10, function(x) cumprod(1 + runif(1000, -x/100, x/100)) - 1) > anno = anno_horizon(lt, gp = gpar(pos_fill = rep(c(1, 2), each = 5), neg_fill = rep(c(3, 4), each = 5)), which = "row") > draw(anno, index, test = "a numeric vector") > > m = matrix(rnorm(1000), nc = 10) > lt = apply(m, 2, function(x) data.frame(density(x)[c("x", "y")])) > anno = anno_joyplot(lt, gp = gpar(fill = rep(c(1, 2), each = 5)), + width = unit(4, "cm"), which = "row") > draw(anno, index, test = "joyplot") > > > anno = anno_block(gp = gpar(fill = 1:4)) > draw(anno, index = 1:10, k = 1, n = 4, test = "anno_block") > draw(anno, index = 1:10, k = 2, n = 4, test = "anno_block") > > anno = anno_block(gp = gpar(fill = 1:4), labels = letters[1:4], labels_gp = gpar(col = "white")) > draw(anno, index = 1:10, k = 2, n = 4, test = "anno_block") > draw(anno, index = 1:10, k = 4, n = 4, test = "anno_block") > # draw(anno, index = 1:10, k = 2, n = 2, test = "anno_block") > > anno = anno_block(gp = gpar(fill = 1:4), labels = letters[1:4], labels_gp = gpar(col = "white"), which = "row") > draw(anno, index = 1:10, k = 2, n = 4, test = "anno_block") > > > ### anno_zoom > fa = sort(sample(letters[1:3], 100, replace = TRUE, prob = c(1, 2, 3))) > panel_fun = function(index, nm) { + grid.rect() + grid.text(nm) + } > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun) > draw(anno, index = 1:100, test = "anno_zoom") > > anno = anno_zoom(align_to = list(a = which(fa == "a")), which = "row", panel_fun = panel_fun) > draw(anno, index = 1:100, test = "anno_zoom") > > > panel_fun = function(index, nm) { + grid.rect(gp = gpar(fill = "grey", col = NA)) + grid.text(nm) + } > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, link_gp = gpar(fill = "grey", col = "black"), internal_line = FALSE) > draw(anno, index = 1:100, test = "anno_zoom") > > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + gap = unit(1, "cm")) > draw(anno, index = 1:100, test = "anno_zoom, set gap") > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + size = 1:3) > draw(anno, index = 1:100, test = "anno_zoom, size set as relative values") > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + size = 1:3, extend = unit(1, "cm")) > draw(anno, index = 1:100, test = "anno_zoom, extend") > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + size = unit(1:3, "cm")) > draw(anno, index = 1:100, test = "anno_zoom, size set as absolute values") > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + size = unit(c(2, 20, 40), "cm")) > draw(anno, index = 1:100, test = "anno_zoom, big size") > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + size = 1:3, gap = unit(1, "cm")) > draw(anno, index = 1:100, test = "anno_zoom, size set as relative values, gap") > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + size = unit(1:3, "cm"), gap = unit(1, "cm")) > draw(anno, index = 1:100, test = "anno_zoom, size set as absolute values, gap") > > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + size = unit(1:3, "cm"), side = "left") > draw(anno, index = 1:100, test = "anno_zoom, side") > > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + size = unit(1:3, "cm"), link_gp = gpar(fill = 1:3)) > draw(anno, index = 1:100, test = "anno_zoom, link_gp") > > anno = anno_zoom(align_to = fa, which = "row", panel_fun = panel_fun, + size = unit(1:3, "cm"), link_gp = gpar(fill = 1:3), + link_width = unit(2, "cm"), width = unit(4, "cm")) > draw(anno, index = 1:100, test = "anno_zoom, width") > > anno = anno_zoom(align_to = list(a = 1:10, b = 30:45, c = 70:90), + which = "row", panel_fun = panel_fun, size = unit(1:3, "cm")) > draw(anno, index = 1:100, test = "anno_zoom, a list of indices") > > anno = anno_zoom(align_to = fa, which = "column", panel_fun = panel_fun, + size = unit(1:3, "cm")) > draw(anno, index = 1:100, test = "anno_zoom, column annotation") > > > m = matrix(rnorm(100*10), nrow = 100) > hc = hclust(dist(m)) > fa2 = cutree(hc, k = 4) > anno = anno_zoom(align_to = fa2, which = "row", panel_fun = panel_fun) > draw(anno, index = hc$order, test = "anno_zoom, column annotation") > > anno = anno_zoom(align_to = fa2, which = "column", panel_fun = panel_fun) > draw(anno, index = hc$order, test = "anno_zoom, column annotation") > > > anno = anno_zoom(align_to = fa2, which = "row", panel_fun = panel_fun) > draw(Heatmap(m, cluster_rows = hc, right_annotation = rowAnnotation(foo = anno))) > draw(Heatmap(m, cluster_rows = hc, right_annotation = rowAnnotation(foo = anno), row_split = 2)) > > > anno = anno_zoom(align_to = fa2, which = "row", panel_fun = panel_fun, size = unit(1:4, "cm")) > draw(Heatmap(m, cluster_rows = hc, right_annotation = rowAnnotation(foo = anno))) > > set.seed(123) > m = matrix(rnorm(100*10), nrow = 100) > subgroup = sample(letters[1:3], 100, replace = TRUE, prob = c(1, 5, 10)) > rg = range(m) > panel_fun = function(index, nm) { + pushViewport(viewport(xscale = rg, yscale = c(0, 2))) + grid.rect() + grid.xaxis(gp = gpar(fontsize = 8)) + grid.boxplot(m[index, ], pos = 1, direction = "horizontal") + grid.text(paste("distribution of group", nm), mean(rg), y = 1.9, + just = "top", default.units = "native", gp = gpar(fontsize = 10)) + popViewport() + } > anno = anno_zoom(align_to = subgroup, which = "row", panel_fun = panel_fun, + size = unit(2, "cm"), gap = unit(1, "cm"), width = unit(4, "cm")) > draw(Heatmap(m, right_annotation = rowAnnotation(foo = anno), row_split = subgroup)) > > panel_fun2 = function(index, nm) { + pushViewport(viewport()) + grid.rect() + n = floor(length(index)/4) + txt = paste("gene function", 1:n, collapse = "\n") + grid.text(txt, 0.95, 0.5, default.units = "npc", just = "right", gp = gpar(fontsize = 8)) + popViewport() + } > anno2 = anno_zoom(align_to = subgroup, which = "row", panel_fun = panel_fun2, + gap = unit(1, "cm"), width = unit(3, "cm"), side = "left") > > draw(Heatmap(m, right_annotation = rowAnnotation(subgroup = subgroup, foo = anno, + show_annotation_name = FALSE), + left_annotation = rowAnnotation(bar = anno2, subgroup = subgroup, show_annotation_name = FALSE), + show_row_dend = FALSE, + row_split = subgroup)) > > draw(Heatmap(m, right_annotation = rowAnnotation(foo = anno), + left_annotation = rowAnnotation(bar = anno2), + show_row_dend = FALSE, + row_split = subgroup)) > > set.seed(12345) > mat = matrix(rnorm(30*10), nr = 30) > row_split = c(rep("a", 10), rep("b", 5), rep("c", 2), rep("d", 3), + rep("e", 2), letters[10:17]) > row_split = factor(row_split) > > panel_fun = function(index, name) { + pushViewport(viewport()) + grid.rect() + grid.text(name) + popViewport() + } > > anno = anno_zoom(align_to = row_split, which = "row", panel_fun = panel_fun, + size = unit(0.5, "cm"), width = unit(4, "cm")) > > # > dev.size() > # [1] 3.938326 4.502203 > dev.new(width = 3.938326, height = 4.502203) dev.new(): using pdf(file="Rplots1.pdf") > draw(Heatmap(mat, right_annotation = rowAnnotation(foo = anno), + row_split = row_split)) > > > proc.time() user system elapsed 15.191 0.313 15.488
ComplexHeatmap.Rcheck/tests/test-ColorMapping-class.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > cm = ColorMapping(name = "test", + colors = c("blue", "white", "red"), + levels = c("a", "b", "c")) > color_mapping_legend(cm) > > cm = ColorMapping(name = "test", + col_fun = colorRamp2(c(0, 0.5, 1), c("blue", "white", "red"))) > color_mapping_legend(cm) > > cm = ColorMapping(name = "test", + colors = c("blue", "white", "red"), + levels = c(1, 2, 3)) > color_mapping_legend(cm) > > ha = SingleAnnotation(value = rep(NA, 10), name = "foo") > cm = ha@color_mapping > color_mapping_legend(cm) > > > proc.time() user system elapsed 2.165 0.135 2.286
ComplexHeatmap.Rcheck/tests/test-dendrogram.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > if(!exists("cut_dendrogram")) { + cut_dendrogram = ComplexHeatmap:::cut_dendrogram + } > > library(dendextend) --------------------- Welcome to dendextend version 1.15.1 Type citation('dendextend') for how to cite the package. Type browseVignettes(package = 'dendextend') for the package vignette. The github page is: https://github.com/talgalili/dendextend/ Suggestions and bug-reports can be submitted at: https://github.com/talgalili/dendextend/issues Or contact: <tal.galili@gmail.com> To suppress this message use: suppressPackageStartupMessages(library(dendextend)) --------------------- Attaching package: 'dendextend' The following object is masked from 'package:stats': cutree > > m = matrix(rnorm(100), 10) > dend1 = as.dendrogram(hclust(dist(m))) > dend1 = adjust_dend_by_x(dend1, sort(runif(10))) > > m = matrix(rnorm(50), nr = 5) > dend2 = as.dendrogram(hclust(dist(m))) > > dend3 = as.dendrogram(hclust(dist(m[1:2, ]))) > > > dend_merge = merge_dendrogram(dend3, + list(set(dend1, "branches_col", "red"), + set(dend2, "branches_col", "blue")) + ) > > grid.dendrogram(dend_merge, test = TRUE, facing = "bottom") > grid.dendrogram(dend_merge, test = TRUE, facing = "top") > grid.dendrogram(dend_merge, test = TRUE, facing = "left") > grid.dendrogram(dend_merge, test = TRUE, facing = "right") > > grid.dendrogram(dend_merge, test = TRUE, facing = "bottom", order = "reverse") > grid.dendrogram(dend_merge, test = TRUE, facing = "top", order = "reverse") > grid.dendrogram(dend_merge, test = TRUE, facing = "left", order = "reverse") > grid.dendrogram(dend_merge, test = TRUE, facing = "right", order = "reverse") > > > m = matrix(rnorm(100), 10) > dend1 = as.dendrogram(hclust(dist(m))) > dend1 = adjust_dend_by_x(dend1, unit(1:10, "cm")) > grid.dendrogram(dend1, test = TRUE) > > dl = cut_dendrogram(dend1, k = 3) > grid.dendrogram(dl$upper, test = TRUE) > > > m1 = matrix(rnorm(100), nr = 10) > m2 = matrix(rnorm(80), nr = 8) > m3 = matrix(rnorm(50), nr = 5) > dend1 = as.dendrogram(hclust(dist(m1))) > dend2 = as.dendrogram(hclust(dist(m2))) > dend3 = as.dendrogram(hclust(dist(m3))) > dend_p = as.dendrogram(hclust(dist(rbind(colMeans(m1), colMeans(m2), colMeans(m3))))) > dend_m = merge_dendrogram(dend_p, list(dend1, dend2, dend3)) > grid.dendrogram(dend_m, test = T) > > dend_m = merge_dendrogram(dend_p, list(dend1, dend2, dend3), only_parent = TRUE) > grid.dendrogram(dend_m, test = T) > > require(dendextend) > dend1 = color_branches(dend1, k = 1, col = "red") > dend2 = color_branches(dend2, k = 1, col = "blue") > dend3 = color_branches(dend3, k = 1, col = "green") > dend_p = color_branches(dend_p, k = 1, col = "orange") > dend_m = merge_dendrogram(dend_p, list(dend1, dend2, dend3)) > grid.dendrogram(dend_m, test = T) > > > m = matrix(rnorm(120), nc = 12) > colnames(m) = letters[1:12] > fa = rep(c("a", "b", "c"), times = c(2, 4, 6)) > dend = cluster_within_group(m, fa) > grid.dendrogram(dend, test = TRUE) > > > # stack overflow problem > m = matrix(1, nrow = 1000, ncol = 10) > m[1, 2] = 2 > dend = as.dendrogram(hclust(dist(m))) > grid.dendrogram(dend, test = T) > > # node attr > m = matrix(rnorm(100), 10) > dend = as.dendrogram(hclust(dist(m))) > require(dendextend) > dend1 = color_branches(dend, k = 2, col = 1:2) > grid.dendrogram(dend1, test = T) > dend1 = dend > dend1 = dendrapply(dend, function(d) { + attr(d, "nodePar") = list(pch = sample(20, 1), cex = runif(1, min = 0.3, max = 1.3), col = rand_color(1)) + d + }) > grid.dendrogram(dend1, test = T) > > Heatmap(m, cluster_rows = dend1, cluster_columns = dend1) > > d1 = ComplexHeatmap:::dend_edit_node(dend, method = "top-bottom", function(d, index) { + attr(d, "depth") = length(index) + d + }) > > d2 = ComplexHeatmap:::dend_edit_node(dend, method = "bottom-top", function(d, index) { + attr(d, "depth") = length(index) + d + }) > > identical(d1, d2) [1] TRUE > > proc.time() user system elapsed 6.549 0.235 6.768
ComplexHeatmap.Rcheck/tests/test-gridtext.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > > if(requireNamespace("gridtext")) { + ##### test anno_richtext #### + mat = matrix(rnorm(100), 10) + rownames(mat) = letters[1:10] + ht = Heatmap(mat, + column_title = gt_render("Some <span style='color:blue'>blue text **in bold.**</span><br>And *italics text.*<br>And some <span style='font-size:18pt; color:black'>large</span> text.", r = unit(2, "pt"), padding = unit(c(2, 2, 2, 2), "pt")), + column_title_gp = gpar(box_fill = "orange"), + row_labels = gt_render(letters[1:10], padding = unit(c(2, 10, 2, 10), "pt")), + row_names_gp = gpar(box_col = rep(2:3, times = 5), box_fill = ifelse(1:10%%2, "yellow", "white")), + row_km = 2, + row_title = gt_render(c("title1", "title2")), + row_title_gp = gpar(box_fill = "yellow"), + heatmap_legend_param = list( + title = gt_render("<span style='color:orange'>**Legend title**</span>"), + title_gp = gpar(box_fill = "grey"), + at = c(-3, 0, 3), + labels = gt_render(c("*negative* three", "zero", "*positive* three")) + )) + ht = rowAnnotation( + foo = anno_text(gt_render(sapply(LETTERS[1:10], strrep, 10), align_widths = TRUE), + gp = gpar(box_col = "blue", box_lwd = 2), + just = "right", + location = unit(1, "npc") + )) + ht + draw(ht) + + } Loading required namespace: gridtext > > proc.time() user system elapsed 3.800 0.176 3.963
ComplexHeatmap.Rcheck/tests/test-Heatmap-class.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > set.seed(123) > nr1 = 10; nr2 = 8; nr3 = 6 > nc1 = 6; nc2 = 8; nc3 = 10 > mat = cbind(rbind(matrix(rnorm(nr1*nc1, mean = 1, sd = 0.5), nr = nr1), + matrix(rnorm(nr2*nc1, mean = 0, sd = 0.5), nr = nr2), + matrix(rnorm(nr3*nc1, mean = 0, sd = 0.5), nr = nr3)), + rbind(matrix(rnorm(nr1*nc2, mean = 0, sd = 0.5), nr = nr1), + matrix(rnorm(nr2*nc2, mean = 1, sd = 0.5), nr = nr2), + matrix(rnorm(nr3*nc2, mean = 0, sd = 0.5), nr = nr3)), + rbind(matrix(rnorm(nr1*nc3, mean = 0.5, sd = 0.5), nr = nr1), + matrix(rnorm(nr2*nc3, mean = 0.5, sd = 0.5), nr = nr2), + matrix(rnorm(nr3*nc3, mean = 1, sd = 0.5), nr = nr3)) + ) > > rownames(mat) = paste0("row", seq_len(nrow(mat))) > colnames(mat) = paste0("column", seq_len(nrow(mat))) > > ht = Heatmap(mat) > draw(ht, test = TRUE) > ht > > > ht = Heatmap(mat, col = colorRamp2(c(-3, 0, 3), c("green", "white", "red"))) > draw(ht, test = TRUE) > > ht = Heatmap(mat, name = "test") > draw(ht, test = TRUE) > > ht = Heatmap(mat, rect_gp = gpar(col = "black")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, border = "red") > draw(ht, test = TRUE) > > ######## test title ########## > ht = Heatmap(mat, row_title = "blablabla") > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_title = "blablabla", row_title_side = "right") > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_title = "blablabla", row_title_gp = gpar(fontsize = 20, font = 2)) > draw(ht, test = TRUE) > > # ht = Heatmap(mat, row_title = "blablabla", row_title_rot = 45) > # draw(ht, test = TRUE) > > ht = Heatmap(mat, row_title = "blablabla", row_title_rot = 0) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_title = "blablabla", row_title_gp = gpar(fill = "red", col = "white")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_title = "blablabla") > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_title = "blablabla", column_title_side = "bottom") > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_title = "blablabla", column_title_gp = gpar(fontsize = 20, font = 2)) > draw(ht, test = TRUE) > > # ht = Heatmap(mat, column_title = "blablabla", column_title_rot = 45) > # draw(ht, test = TRUE) > > ht = Heatmap(mat, column_title = "blablabla", column_title_rot = 90) > draw(ht, test = TRUE) > > > ### test clustering #### > > ht = Heatmap(mat, cluster_rows = FALSE) > draw(ht, test = TRUE) > > ht = Heatmap(mat, clustering_distance_rows = "pearson") > draw(ht, test = TRUE) > > ht = Heatmap(mat, clustering_distance_rows = function(x) dist(x)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, clustering_distance_rows = function(x, y) 1 - cor(x, y)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, clustering_method_rows = "single") > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_dend_side = "right") > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_dend_width = unit(4, "cm")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_dend_gp = gpar(lwd = 2, col = "red")) > draw(ht, test = TRUE) > > dend = as.dendrogram(hclust(dist(mat))) > ht = Heatmap(mat, cluster_rows = dend) > draw(ht, test = TRUE) > > library(dendextend) --------------------- Welcome to dendextend version 1.15.1 Type citation('dendextend') for how to cite the package. Type browseVignettes(package = 'dendextend') for the package vignette. The github page is: https://github.com/talgalili/dendextend/ Suggestions and bug-reports can be submitted at: https://github.com/talgalili/dendextend/issues Or contact: <tal.galili@gmail.com> To suppress this message use: suppressPackageStartupMessages(library(dendextend)) --------------------- Attaching package: 'dendextend' The following object is masked from 'package:stats': cutree > dend = color_branches(dend, k = 3) > ht = Heatmap(mat, cluster_rows = dend) > draw(ht, test = TRUE) > > > ht = Heatmap(mat, cluster_columns = FALSE) > draw(ht, test = TRUE) > > ht = Heatmap(mat, clustering_distance_columns = "pearson") > draw(ht, test = TRUE) > > ht = Heatmap(mat, clustering_distance_columns = function(x) dist(x)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, clustering_distance_columns = function(x, y) 1 - cor(x, y)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, clustering_method_columns = "single") > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_dend_side = "bottom") > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_dend_height = unit(4, "cm")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_dend_gp = gpar(lwd = 2, col = "red")) > draw(ht, test = TRUE) > > dend = as.dendrogram(hclust(dist(t(mat)))) > ht = Heatmap(mat, cluster_columns = dend) > draw(ht, test = TRUE) > > dend = color_branches(dend, k = 3) > ht = Heatmap(mat, cluster_columns = dend) > draw(ht, test = TRUE) > > > ### test row/column order > od = c(seq(1, 24, by = 2), seq(2, 24, by = 2)) > ht = Heatmap(mat, row_order = od) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_order = od, cluster_rows = TRUE) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_order = od) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_order = od, cluster_columns = TRUE) > draw(ht, test = TRUE) > > > #### test row/column names ##### > ht = Heatmap(unname(mat)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, show_row_names = FALSE) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_names_side = "left") > draw(ht, test = TRUE) > > random_str2 = function(k) { + sapply(1:k, function(i) paste(sample(letters, sample(5:10, 1)), collapse = "")) + } > ht = Heatmap(mat, row_labels = random_str2(24)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_names_gp = gpar(fontsize = 20)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_names_gp = gpar(fontsize = 1:24/2 + 5)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_names_rot = 45) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_names_rot = 45, row_names_side = "left") > draw(ht, test = TRUE) > > ht = Heatmap(mat, show_column_names = FALSE) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_names_side = "top") > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_labels = random_str2(24)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_names_gp = gpar(fontsize = 20)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_names_gp = gpar(fontsize = 1:24/2 + 5)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_names_rot = 45) > draw(ht, test = TRUE) > > ### test annotations #### > anno = HeatmapAnnotation( + foo = 1:24, + df = data.frame(type = c(rep("A", 12), rep("B", 12))), + bar = anno_barplot(24:1)) > ht = Heatmap(mat, top_annotation = anno) > draw(ht, test = TRUE) > > ht = Heatmap(mat, bottom_annotation = anno) > draw(ht, test = TRUE) > > ht = Heatmap(mat, top_annotation = anno, bottom_annotation = anno) > draw(ht, test = TRUE) > > > ### test split #### > ht = Heatmap(mat, km = 3) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 3) > draw(ht, test = TRUE) > > ht = Heatmap(mat, split = rep(c("A", "B"), times = c(6, 18))) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = rep(c("A", "B"), times = c(6, 18))) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = factor(rep(c("A", "B"), times = c(6, 18)), levels = c("B", "A"))) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = rep(c("A", "B"), 12), row_gap = unit(5, "mm")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = data.frame(rep(c("A", "B"), 12), rep(c("C", "D"), each = 12))) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = data.frame(rep(c("A", "B"), 12), rep(c("C", "D"), each = 12)), + row_gap = unit(c(1, 2, 3), "mm")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 3, row_title = "foo") > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 3, row_title = "cluster%s") > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 3, row_title = "cluster%s", row_title_rot = 0) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 3, row_title = "cluster%s", row_title_gp = gpar(fill = 2:4, col = "white")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 3, row_title = NULL) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 3, row_names_gp = gpar(col = 2:4)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = rep(c("A", "B"), times = c(6, 18)), row_km = 3) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = rep(c("A", "B"), times = c(6, 18)), row_km = 3, row_title = "cluster%s,group%s", row_title_rot = 0) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = 2) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = 2, row_title = "foo") > ht = Heatmap(mat, row_split = 2, row_title = "cluster%s") > > > dend = as.dendrogram(hclust(dist(mat))) > ht = Heatmap(mat, cluster_rows = dend, row_split = 2) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = 2, row_names_gp = gpar(col = 2:3)) > draw(ht, test = TRUE) > > > ### column split > ht = Heatmap(mat, column_km = 2) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_km = 2, column_gap = unit(1, "cm")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_split = rep(c("A", "B"), times = c(6, 18))) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_split = data.frame(rep(c("A", "B"), 12), rep(c("C", "D"), each = 12)), + column_gap = unit(c(1, 2, 3), "mm")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_km = 2, column_title = "foo") > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_km = 2, column_title = "cluster%s") > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_km = 2, column_title = "cluster%s", column_title_rot = 90) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_km = 2, column_title = "cluster%s", column_title_gp = gpar(fill = 2:3, col = "white")) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_km = 2, column_title = NULL) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_km = 2, column_names_gp = gpar(col = 2:3)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_split = factor(rep(c("A", "B"), times = c(6, 18)), levels = c("A", "B")), column_km = 2) > draw(ht, test = TRUE) > ht = Heatmap(mat, column_split = factor(rep(c("A", "B"), times = c(6, 18)), levels = c("B", "A")), column_km = 2) > > > ht = Heatmap(mat, column_split = rep(c("A", "B"), times = c(6, 18)), column_km = 2, + column_title = "cluster%s,group%s", column_title_rot = 90) > draw(ht, test = TRUE) > > ht = Heatmap(mat, column_split = 3) > draw(ht, test = TRUE) > > dend = as.dendrogram(hclust(dist(t(mat)))) > ht = Heatmap(mat, cluster_columns = dend, column_split = 3) > draw(ht, test = TRUE) > > ht = Heatmap(mat, top_annotation = anno, bottom_annotation = anno, column_km = 2) > draw(ht, test = TRUE) > > ht = Heatmap(mat, top_annotation = anno, bottom_annotation = anno, column_split = 3) > draw(ht, test = TRUE) > > ### combine row and column split > ht = Heatmap(mat, row_km = 3, column_km = 3) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = 3, column_split = 3) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 3, column_split = 3) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_split = rep(c("A", "B"), 12), + column_split = rep(c("C", "D"), 12)) > draw(ht, test = TRUE) > > ht = Heatmap(mat, top_annotation = anno, + row_split = rep(c("A", "B"), 12), + row_names_gp = gpar(col = 2:3), row_gap = unit(2, "mm"), + column_split = 3, + column_names_gp = gpar(col = 2:4), column_gap = unit(4, "mm") + ) > draw(ht, test = TRUE) > > > #### character matrix > mat3 = matrix(sample(letters[1:6], 100, replace = TRUE), 10, 10) > rownames(mat3) = {x = letters[1:10]; x[1] = "aaaaaaaaaaaaaaaaaaaaaaa";x} > ht = Heatmap(mat3, rect_gp = gpar(col = "white")) > draw(ht, test = TRUE) > > > ### cell_fun > mat = matrix(1:9, 3, 3) > rownames(mat) = letters[1:3] > colnames(mat) = letters[1:3] > > ht = Heatmap(mat, rect_gp = gpar(col = "white"), cell_fun = function(j, i, x, y, width, height, fill) grid.text(mat[i, j], x = x, y = y), + cluster_rows = FALSE, cluster_columns = FALSE, row_names_side = "left", column_names_side = "top", + column_names_rot = 0) > draw(ht, test = TRUE) > > > ### test the size > ht = Heatmap(mat) > ht = prepare(ht) > ht@heatmap_param[c("width", "height")] $width [1] 1npc $height [1] 1npc > ht@matrix_param[c("width", "height")] $width [1] 3null $height [1] 3null > > ht = Heatmap(mat, width = unit(10, "cm"), height = unit(10, "cm")) > ht = prepare(ht) > ht@heatmap_param[c("width", "height")] $width [1] 114.853733333333mm $height [1] 114.853733333333mm > ht@matrix_param[c("width", "height")] $width [1] 10cm $height [1] 10cm > draw(ht, test = TRUE) > > ht = Heatmap(mat, width = unit(10, "cm")) > ht = prepare(ht) > ht@heatmap_param[c("width", "height")] $width [1] 114.853733333333mm $height [1] 1npc > ht@matrix_param[c("width", "height")] $width [1] 10cm $height [1] 3null > draw(ht, test = TRUE) > > ht = Heatmap(mat, heatmap_width = unit(10, "cm"), heatmap_height = unit(10, "cm")) > ht = prepare(ht) > ht@heatmap_param[c("width", "height")] $width [1] 10cm $height [1] 10cm > ht@matrix_param[c("width", "height")] $width [1] 85.1462666666667mm $height [1] 85.1462666666667mm > draw(ht, test = TRUE) > > ht = Heatmap(mat, heatmap_width = unit(10, "cm")) > ht = prepare(ht) > ht@heatmap_param[c("width", "height")] $width [1] 10cm $height [1] 1npc > ht@matrix_param[c("width", "height")] $width [1] 85.1462666666667mm $height [1] 3null > draw(ht, test = TRUE) > > ht = Heatmap(mat, use_raster = TRUE) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 2, use_raster = TRUE) > draw(ht, test = TRUE) > > ht = Heatmap(mat, row_km = 2, column_km = 2, use_raster = TRUE) > draw(ht, test = TRUE) > > #### test global padding > ra = rowAnnotation(foo = 1:3) > ht = Heatmap(mat, show_column_names = FALSE) + ra > draw(ht) > > ht = Heatmap(matrix(rnorm(100), 10), row_km = 2, row_title = "") > draw(ht) > > if(0) { + ht = Heatmap(matrix(rnorm(100), 10), heatmap_width = unit(5, "mm")) + draw(ht) + } > > proc.time() user system elapsed 19.376 0.390 19.713
ComplexHeatmap.Rcheck/tests/test-Heatmap-cluster.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > # ht_opt("verbose" = TRUE) > m = matrix(rnorm(50), nr = 10) > > ht = Heatmap(m) > ht = make_row_cluster(ht) > > ht = Heatmap(m, cluster_rows = FALSE) > ht = make_row_cluster(ht) > > ht = Heatmap(m, row_km = 2) > ht = make_row_cluster(ht) > > ht = Heatmap(m, row_split = sample(letters[1:2], 10, replace = TRUE)) > ht = make_row_cluster(ht) > > ht = Heatmap(m, cluster_rows = hclust(dist(m))) > ht = make_row_cluster(ht) > > ht = Heatmap(m, cluster_rows = hclust(dist(m)), row_split = 2) > ht = make_row_cluster(ht) > > # ht_opt("verbose" = FALSE) > > proc.time() user system elapsed 2.312 0.105 2.403
ComplexHeatmap.Rcheck/tests/test-HeatmapAnnotation.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > > ha = HeatmapAnnotation(foo = 1:10) > ha A HeatmapAnnotation object with 1 annotation name: heatmap_annotation_0 position: column items: 10 width: 1npc height: 5mm this object is subsetable 6.75733333333333mm extension on the right name annotation_type color_mapping height foo continuous vector random 5mm > > > ha = HeatmapAnnotation(foo = cbind(1:10, 10:1)) > ha A HeatmapAnnotation object with 1 annotation name: heatmap_annotation_1 position: column items: 10 width: 1npc height: 10mm this object is subsetable 6.75733333333333mm extension on the right name annotation_type color_mapping height foo continuous matrix random 10mm > draw(ha, test = "matrix as column annotation") > > ha = HeatmapAnnotation(foo = 1:10, bar = sample(c("a", "b"), 10, replace = TRUE), + pt = anno_points(1:10), annotation_name_side = "left") > draw(ha, test = "complex annotations") > > ha = HeatmapAnnotation(foo = 1:10, bar = sample(c("a", "b"), 10, replace = TRUE), + pt = anno_points(1:10), annotation_name_side = "left", height = unit(8, "cm")) > draw(ha, test = "complex annotations") > > > ha = HeatmapAnnotation(foo = 1:10, bar = sample(c("a", "b"), 10, replace = TRUE)) > > ha = HeatmapAnnotation(foo = 1:10, + bar = cbind(1:10, 10:1), + pt = anno_points(1:10), + gap = unit(2, "mm")) > draw(ha, test = "complex annotations") > > ha2 = re_size(ha, annotation_height = unit(1:3, "cm")) > draw(ha2, test = "complex annotations") > ha2 = re_size(ha, annotation_height = 1, height = unit(6, "cm")) > draw(ha2, test = "complex annotations") > ha2 = re_size(ha, annotation_height = 1:3, height = unit(6, "cm")) > draw(ha2, test = "complex annotations") > ha2 = re_size(ha, annotation_height = unit(c(1, 2, 3), c("null", "null", "cm")), height = unit(6, "cm")) > draw(ha2, test = "complex annotations") > ha2 = re_size(ha, annotation_height = unit(c(2, 2, 3), c("cm", "null", "cm")), height = unit(6, "cm")) > draw(ha2, test = "complex annotations") > ha2 = re_size(ha, annotation_height = unit(c(2, 2, 3), c("cm", "cm", "cm"))) > draw(ha2, test = "complex annotations") > ha2 = re_size(ha[, 1:2], annotation_height = 1, height = unit(4, "cm")) > draw(ha2, test = "complex annotations") > ha2 = re_size(ha[, 1:2], annotation_height = c(1, 4), height = unit(4, "cm")) > draw(ha2, test = "complex annotations") > ha2 = re_size(ha[, 1:2], height = unit(6, "cm")) > draw(ha2, test = "complex annotations") > > ha2 = re_size(ha, height = unit(6, "cm")) > draw(ha2, test = "complex annotations") > > #### test anno_empty and self-defined anotation function > ha = HeatmapAnnotation(foo = anno_empty(), height = unit(4, "cm")) > draw(ha, 1:10, test = "anno_empty") > ha = HeatmapAnnotation(foo = anno_empty(), bar = 1:10, height = unit(4, "cm")) > draw(ha, 1:10, test = "anno_empty") > ha = HeatmapAnnotation(foo = anno_empty(), bar = 1:10, height = unit(4, "cm")) > draw(ha, 1:10, test = "anno_empty") > > ha = HeatmapAnnotation(foo = function(index) {grid.rect()}, bar = 1:10, height = unit(4, "cm")) > draw(ha, 1:10, test = "self-defined function") > > > lt = lapply(1:10, function(x) cumprod(1 + runif(1000, -x/100, x/100)) - 1) > ha = HeatmapAnnotation(foo = 1:10, bar = sample(c("a", "b"), 10, replace = TRUE), + anno = anno_horizon(lt), which = "row") > draw(ha, test = "complex annotations on row") > > ## test row annotation with no heatmap > rowAnnotation(foo = 1:10, bar = anno_points(10:1)) A HeatmapAnnotation object with 2 annotations name: heatmap_annotation_11 position: row items: 10 width: 15.3514598035146mm height: 1npc this object is subsetable 9.17784444444445mm extension on the bottom name annotation_type color_mapping width foo continuous vector random 5mm bar anno_points() 10mm > > if(0) { + HeatmapAnnotation(1:10) + + HeatmapAnnotation(data.frame(1:10)) + } > > > ha = HeatmapAnnotation(summary = anno_summary(height = unit(4, "cm"))) > v = sample(letters[1:2], 50, replace = TRUE) > split = sample(letters[1:2], 50, replace = TRUE) > > ht = Heatmap(v, top_annotation = ha, width = unit(1, "cm"), split = split) > draw(ht) > > ha = HeatmapAnnotation(summary = anno_summary(gp = gpar(fill = 2:3), height = unit(4, "cm"))) > v = rnorm(50) > ht = Heatmap(v, top_annotation = ha, width = unit(1, "cm"), split = split) > draw(ht) > > > ### auto adjust > m = matrix(rnorm(100), 10) > ht_list = Heatmap(m, top_annotation = HeatmapAnnotation(foo = 1:10), column_dend_height = unit(4, "cm")) + + Heatmap(m, top_annotation = HeatmapAnnotation(bar = anno_points(1:10)), + cluster_columns = FALSE) > draw(ht_list) > > fun = function(index) { + grid.rect() + } > ha = HeatmapAnnotation(fun = fun, height = unit(4, "cm")) > draw(ha, 1:10, test = TRUE) > > ha = rowAnnotation(fun = fun, width = unit(4, "cm")) > draw(ha, 1:10, test = TRUE) > > > ## test anno_mark > m = matrix(rnorm(1000), nrow = 100) > ha1 = rowAnnotation(foo = anno_mark(at = c(1:4, 20, 60, 97:100), labels = month.name[1:10])) > ht = Heatmap(m, name = "mat", cluster_rows = FALSE, right_annotation = ha1) > draw(ht) > ht = Heatmap(m, name = "mat", cluster_rows = FALSE) + ha1 > draw(ht) > > split = rep("a", 100); split[c(1:4, 20, 60, 98:100)] = "b" > ht = Heatmap(m, name = "mat", cluster_rows = FALSE, right_annotation = ha1, row_split = split, gap = unit(1, "cm")) > draw(ht) > ht = Heatmap(m, name = "mat", cluster_rows = FALSE, row_split = split, gap = unit(1, "cm")) + ha1 > draw(ht) > > # ha has two annotations > ha2 = rowAnnotation(foo = anno_mark(at = c(1:4, 20, 60, 97:100), labels = month.name[1:10]), bar = 1:100) > ht = Heatmap(m, name = "mat", cluster_rows = FALSE, right_annotation = ha2) > draw(ht) > ht = Heatmap(m, name = "mat", cluster_rows = FALSE) + ha2 > draw(ht) > > ht = Heatmap(m, name = "mat", cluster_rows = FALSE, right_annotation = ha2, row_split = split, gap = unit(1, "cm")) > draw(ht) > ht = Heatmap(m, name = "mat", cluster_rows = FALSE, row_split = split, gap = unit(1, "cm")) + ha2 > draw(ht) > > ## test anno_mark as column annotation > m = matrix(rnorm(1000), ncol = 100) > ha1 = columnAnnotation(foo = anno_mark(at = c(1:4, 20, 60, 97:100), labels = month.name[1:10])) > ht = Heatmap(m, name = "mat", cluster_columns = FALSE, top_annotation = ha1) > draw(ht) > ht_list = ha1 %v% Heatmap(m, name = "mat", cluster_columns = FALSE) > draw(ht_list) > > split = rep("a", 100); split[c(1:4, 20, 60, 98:100)] = "b" > ht = Heatmap(m, name = "mat", cluster_columns = FALSE, top_annotation = ha1, column_split = split, column_gap = unit(1, "cm")) > draw(ht) > ht_list = ha1 %v% Heatmap(m, name = "mat", cluster_columns = FALSE, column_split = split, gap = unit(1, "cm")) > draw(ht_list) > > # ha has two annotations > ha2 = HeatmapAnnotation(foo = anno_mark(at = c(1:4, 20, 60, 97:100), labels = month.name[1:10]), bar = 1:100) > ht = Heatmap(m, name = "mat", cluster_columns = FALSE, top_annotation = ha2) > draw(ht) > ht_list = ha2 %v% Heatmap(m, name = "mat", cluster_columns = FALSE) > draw(ht_list) > > ht = Heatmap(m, name = "mat", cluster_columns = FALSE, top_annotation = ha2, column_split = split, column_gap = unit(1, "cm")) > draw(ht) > ht_list = ha2 %v% Heatmap(m, name = "mat", cluster_columns = FALSE, column_split = split, column_gap = unit(1, "cm")) > draw(ht_list) > > > ### when there are only simple annotations > col_fun = colorRamp2(c(0, 10), c("white", "blue")) > ha = HeatmapAnnotation( + foo = cbind(a = 1:10, b = 10:1), + bar = sample(letters[1:3], 10, replace = TRUE), + col = list(foo = col_fun, + bar = c("a" = "red", "b" = "green", "c" = "blue") + ), + simple_anno_size = unit(1, "cm") + ) > draw(ha, test = TRUE) > > set.seed(123) > mat1 = matrix(rnorm(80, 2), 8, 10) > mat1 = rbind(mat1, matrix(rnorm(40, -2), 4, 10)) > rownames(mat1) = paste0("R", 1:12) > colnames(mat1) = paste0("C", 1:10) > > mat2 = matrix(runif(60, max = 3, min = 1), 6, 10) > mat2 = rbind(mat2, matrix(runif(60, max = 2, min = 0), 6, 10)) > rownames(mat2) = paste0("R", 1:12) > colnames(mat2) = paste0("C", 1:10) > > ind = sample(12, 12) > mat1 = mat1[ind, ] > mat2 = mat2[ind, ] > > ha1 = HeatmapAnnotation(foo1 = 1:10, + annotation_height = unit(1, "cm"), + simple_anno_size_adjust = TRUE, + annotation_name_side = "left") > ha2 = HeatmapAnnotation(df = data.frame(foo1 = 1:10, + foo2 = 1:10, + foo4 = 1:10, + foo5 = 1:10)) > ht1 = Heatmap(mat1, name = "rnorm", top_annotation = ha1) > ht2 = Heatmap(mat2, name = "runif", top_annotation = ha2) > > draw(ht1 + ht2) > > ##### test size of a single simple annotation > > ha = HeatmapAnnotation(foo1 = 1:10, + simple_anno_size = unit(1, "cm") + ) > ha = HeatmapAnnotation(foo1 = 1:10, + annotation_height = unit(1, "cm"), + simple_anno_size_adjust = TRUE + ) > ha = HeatmapAnnotation(foo1 = 1:10, + height = unit(1, "cm"), + simple_anno_size_adjust = TRUE + ) > > > ## annotation with the same names > > set.seed(123) > m = matrix(rnorm(100), 10) > ha1 = HeatmapAnnotation(foo = sample(c("a", "b"), 10, replace = TRUE)) > ha2 = HeatmapAnnotation(foo = sample(c("b", "c"), 10, replace = TRUE)) > > ht_list = Heatmap(m, top_annotation = ha1) + + Heatmap(m, top_annotation = ha2) > draw(ht_list) > > ha1 = HeatmapAnnotation(foo = sample(c("a", "b"), 10, replace = TRUE), + annotation_legend_param = list( + foo = list(title = "letters", + at = c("a", "b", "c"), + labels = c("A", "B", "C") + ) + )) > ha2 = HeatmapAnnotation(foo = sample(c("b", "c"), 10, replace = TRUE)) > > ht_list = Heatmap(m, top_annotation = ha1) + + Heatmap(m, top_annotation = ha2) > draw(ht_list) > > x = matrix(rnorm(6), ncol=3) > subtype_col = c("Basal" = "purple","Her2" = "black","Normal" = "blue") > h1 <- HeatmapAnnotation("Subtype" = c("Basal","Her2", "Normal"), + col = list("Subtype" = subtype_col)) > h2 <- HeatmapAnnotation("Subtype" = c("Normal","Normal", "Basal"), + col = list("Subtype" = subtype_col)) > > ht_list = Heatmap(x,top_annotation = h1) + Heatmap(x,top_annotation = h2) > draw(ht_list) > > > ### test annotation_label > ha = HeatmapAnnotation(foo = 1:10, bar = letters[1:10], + annotation_label = c("anno1", "anno2")) > draw(ha, test = TRUE) > > ha = HeatmapAnnotation(foo = 1:10, bar = letters[1:10], + annotation_label = list(foo = "anno1")) > draw(ha, test = TRUE) > > > ha = HeatmapAnnotation(foo = 1:10, bar = letters[1:10], + annotation_label = list( + foo = gt_render("foo", gp = gpar(box_fill = "red")))) Loading required namespace: gridtext > draw(ha, test = TRUE) > > ha = HeatmapAnnotation(foo = 1:10, bar = letters[1:10], + annotation_label = list( + foo = gt_render("foo", gp = gpar(box_fill = "red")), + bar = gt_render("bar", gp = gpar(box_fill = "blue")))) > draw(ha, test = TRUE) > > proc.time() user system elapsed 11.664 0.231 11.880
ComplexHeatmap.Rcheck/tests/test-HeatmapList-class.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > set.seed(123) > nr1 = 10; nr2 = 8; nr3 = 6 > nc1 = 6; nc2 = 8; nc3 = 10 > mat1 = cbind(rbind(matrix(rnorm(nr1*nc1, mean = 1, sd = 0.5), nr = nr1), + matrix(rnorm(nr2*nc1, mean = 0, sd = 0.5), nr = nr2), + matrix(rnorm(nr3*nc1, mean = 0, sd = 0.5), nr = nr3)), + rbind(matrix(rnorm(nr1*nc2, mean = 0, sd = 0.5), nr = nr1), + matrix(rnorm(nr2*nc2, mean = 1, sd = 0.5), nr = nr2), + matrix(rnorm(nr3*nc2, mean = 0, sd = 0.5), nr = nr3)), + rbind(matrix(rnorm(nr1*nc3, mean = 0.5, sd = 0.5), nr = nr1), + matrix(rnorm(nr2*nc3, mean = 0.5, sd = 0.5), nr = nr2), + matrix(rnorm(nr3*nc3, mean = 1, sd = 0.5), nr = nr3)) + ) > > rownames(mat1) = paste0("row_1_", seq_len(nrow(mat1))) > colnames(mat1) = paste0("column_1_", seq_len(nrow(mat1))) > > nr3 = 10; nr1 = 8; nr2 = 6 > nc3 = 6; nc1 = 8; nc2 = 10 > mat2 = cbind(rbind(matrix(rnorm(nr1*nc1, mean = 1, sd = 0.5), nr = nr1), + matrix(rnorm(nr2*nc1, mean = 0, sd = 0.5), nr = nr2), + matrix(rnorm(nr3*nc1, mean = 0, sd = 0.5), nr = nr3)), + rbind(matrix(rnorm(nr1*nc2, mean = 0, sd = 0.5), nr = nr1), + matrix(rnorm(nr2*nc2, mean = 1, sd = 0.5), nr = nr2), + matrix(rnorm(nr3*nc2, mean = 0, sd = 0.5), nr = nr3)), + rbind(matrix(rnorm(nr1*nc3, mean = 0.5, sd = 0.5), nr = nr1), + matrix(rnorm(nr2*nc3, mean = 0.5, sd = 0.5), nr = nr2), + matrix(rnorm(nr3*nc3, mean = 1, sd = 0.5), nr = nr3)) + ) > > rownames(mat2) = paste0("row_2_", seq_len(nrow(mat2))) > colnames(mat2) = paste0("column_2_", seq_len(nrow(mat2))) > > > ht_list = Heatmap(mat1) + Heatmap(mat2) > draw(ht_list) > > ######### legend ############ > draw(ht_list, heatmap_legend_side = "bottom") > draw(ht_list, heatmap_legend_side = "left") > draw(ht_list, heatmap_legend_side = "top") > > > ########## width ############# > ht_list = Heatmap(mat1, width = unit(6, "cm")) + Heatmap(mat2) > draw(ht_list) > ht_list = Heatmap(mat1) + Heatmap(mat2, width = unit(8, "cm")) > draw(ht_list) > ht_list = Heatmap(mat1, width = unit(12, "cm")) + Heatmap(mat2, width = unit(8, "cm")) > draw(ht_list) > > ht_list = Heatmap(mat1, width = unit(6, "cm")) + Heatmap(mat2) > draw(ht_list) > ht_list = Heatmap(mat1) + Heatmap(mat2, width = unit(6, "cm")) > draw(ht_list) > ht_list = Heatmap(mat1, width = unit(6, "cm")) + Heatmap(mat2, width = unit(6, "cm")) > draw(ht_list) > ht_list = Heatmap(mat1, width = 4) + Heatmap(mat2) > draw(ht_list) > ht_list = Heatmap(mat1, width = 2) + Heatmap(mat2, width = 1) > draw(ht_list) > > > ########### height ########### > ht_list = Heatmap(mat1, height = unit(6, "cm")) + Heatmap(mat2) > draw(ht_list) > ht_list = Heatmap(mat1, heatmap_height = unit(6, "cm")) + Heatmap(mat2) > draw(ht_list) > ht_list = Heatmap(mat1, width = unit(6, "cm"), height = unit(6, "cm")) + + Heatmap(mat2, width = unit(6, "cm"), height = unit(6, "cm")) > draw(ht_list, column_title = "foooooooooo", row_title = "baaaaaaaaaaar") > > ##### split ##### > ht_list = Heatmap(mat1, name = "m1", row_km = 2) + Heatmap(mat2, name = "m2", row_km = 3) > draw(ht_list, main_heatmap = "m1") > draw(ht_list, main_heatmap = "m2") > > ht_list = Heatmap(mat1, name = "m1", row_km = 2, column_km = 3, width = unit(8, "cm"), height = unit(6, "cm")) + + Heatmap(mat2, name = "m2", row_km = 3, column_km = 2, width = unit(8, "cm"), height = unit(10, "cm")) > draw(ht_list, main_heatmap = "m1", column_title = "foooooooooo", row_title = "baaaaaaaaaaar") > draw(ht_list, main_heatmap = "m2", column_title = "foooooooooo", row_title = "baaaaaaaaaaar") > > ##### adjust column annotations ##### > ha1 = HeatmapAnnotation(foo = 1:24, bar = anno_points(24:1, height = unit(4, "cm"))) > ha2 = HeatmapAnnotation(bar = anno_points(24:1), foo = 1:24) > ht_list = Heatmap(mat1, top_annotation = ha1) + Heatmap(mat2, top_annotation = ha2) > draw(ht_list) > ha2 = HeatmapAnnotation(foo = 1:24) > ht_list = Heatmap(mat1, top_annotation = ha1) + Heatmap(mat2, top_annotation = ha2) > draw(ht_list) > ht_list = Heatmap(mat1, top_annotation = ha1) + Heatmap(mat2) > draw(ht_list) > ht_list = Heatmap(mat1, bottom_annotation = ha1) + Heatmap(mat2) > draw(ht_list) > > > #### row annotations ##### > ha = rowAnnotation(foo = 1:24, bar = anno_points(24:1), width = unit(6, "cm")) > ht_list = Heatmap(mat1) + ha > draw(ht_list) > ht_list = Heatmap(mat1, width = unit(6, "cm")) + ha > draw(ht_list) > ht_list = Heatmap(mat1, width = unit(6, "cm"), row_km = 2) + ha > draw(ht_list) > > ht_list = Heatmap(matrix(rnorm(100), 10), name = "rnorm") + + rowAnnotation(foo = 1:10, bar = anno_points(10:1)) + + Heatmap(matrix(runif(100), 10), name = "runif") > summary(ht_list[1:5, ]) A horizontal heamtap list with 3 heatmap/annotations. rnorm: a matrix with 5 rows and 10 columns heatmap_annotation_4: a list of 2 annotations foo: a simple annotation. bar: a complex annotation. runif: a matrix with 5 rows and 10 columns > summary(ht_list[1:5, 1]) A horizontal heamtap list with 1 heatmap/annotations. rnorm: a matrix with 5 rows and 10 columns > summary(ht_list[1:5, "rnorm"]) A horizontal heamtap list with 1 heatmap/annotations. rnorm: a matrix with 5 rows and 10 columns > summary(ht_list[1:5, c("rnorm", "foo")]) A horizontal heamtap list with 2 heatmap/annotations. rnorm: a matrix with 5 rows and 10 columns heatmap_annotation_4: a list of 1 annotations foo: a simple annotation. > > ht_list = Heatmap(matrix(rnorm(100), 10), name = "rnorm") %v% + columnAnnotation(foo = 1:10, bar = anno_points(10:1)) %v% + Heatmap(matrix(runif(100), 10), name = "runif") > summary(ht_list[, 1:5]) A vertical heamtap list with 3 heatmap/annotations. rnorm: a matrix with 10 rows and 5 columns heatmap_annotation_5: a list of 2 annotations foo: a simple annotation. bar: a complex annotation. runif: a matrix with 10 rows and 5 columns > summary(ht_list[1, 1:5]) A vertical heamtap list with 1 heatmap/annotations. rnorm: a matrix with 10 rows and 5 columns > summary(ht_list["rnorm", 1:5]) A vertical heamtap list with 1 heatmap/annotations. rnorm: a matrix with 10 rows and 5 columns > summary(ht_list[c("rnorm", "foo"), 1:5]) A vertical heamtap list with 2 heatmap/annotations. rnorm: a matrix with 10 rows and 5 columns heatmap_annotation_5: a list of 1 annotations foo: a simple annotation. > > > > > proc.time() user system elapsed 14.014 0.254 14.252
ComplexHeatmap.Rcheck/tests/test-interactive.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > if(0) { + + m = matrix(rnorm(100), 10) + rownames(m) = 1:10 + colnames(m) = 1:10 + + ht = Heatmap(m) + ht = draw(ht) + selectArea(ht) + + + + ht = Heatmap(m, row_km = 2, column_km = 2) + ht = draw(ht) + selectArea(ht) + + + ht = Heatmap(m, row_km = 2, column_km = 2) + Heatmap(m, row_km = 2, column_km = 2) + ht = draw(ht) + selectArea(ht) + + pdf("~/test.pdf") + ht = Heatmap(m) + ht = draw(ht) + selectArea(ht, pos1 = unit(c(1, 1), "cm"), pos2 = unit(c(4, 4), "cm"), verbose = TRUE) + + set.seed(123) + ht = Heatmap(m, row_km = 2, column_km = 2) + ht = draw(ht) + selectArea(ht, pos1 = unit(c(1, 1), "cm"), pos2 = unit(c(8, 8), "cm"), verbose = TRUE) + dev.off() + + png("~/test-1.png") + ht = Heatmap(m) + ht = draw(ht) + selectArea(ht, pos1 = unit(c(1, 1), "cm"), pos2 = unit(c(4, 4), "cm"), verbose = TRUE) + dev.off() + + png("~/test-2.png") + set.seed(123) + ht = Heatmap(m, row_km = 2, column_km = 2) + ht = draw(ht) + selectArea(ht, pos1 = unit(c(1, 1), "cm"), pos2 = unit(c(8, 8), "cm"), verbose = TRUE) + dev.off() + + } > > proc.time() user system elapsed 0.178 0.034 0.197
ComplexHeatmap.Rcheck/tests/test-Legend.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > if(!exists("random_str")) { + random_str = ComplexHeatmap:::random_str + } > > lgd = Legend(at = 1:6, legend_gp = gpar(fill = 1:6)) > draw(lgd, test = "default discrete legends style") > > lgd = Legend(labels = 1:6, legend_gp = gpar(fill = 1:6)) > draw(lgd, test = "only specify labels with no at") > > > lgd = Legend(labels = month.name[1:6], title = "foo", legend_gp = gpar(fill = 1:6)) > draw(lgd, test = "add labels and title") > > lgd = Legend(labels = month.name[1:6], title = "foo", legend_gp = gpar(fill = 1:6), + title_position = "lefttop") > draw(lgd, test = "title put in the lefttop") > > lgd = Legend(labels = month.name[1:6], title = "foo", legend_gp = gpar(fill = 1:6), + title_position = "lefttop-rot") > draw(lgd, test = "title put in the lefttop-rot") > > lgd = Legend(labels = month.name[1:6], title = "foo", legend_gp = gpar(fill = 1:6), + title_position = "leftcenter-rot") > draw(lgd, test = "title put in the leftcenter-rot") > > lgd = Legend(labels = 1:6, title = "fooooooo", legend_gp = gpar(fill = 1:6)) > draw(lgd, test = "title is longer than the legend body") > > lgd = Legend(at = 1:6, legend_gp = gpar(fill = 1:6), grid_height = unit(1, "cm"), + title = "foo", grid_width = unit(5, "mm")) > draw(lgd, test = "grid size") > > lgd = Legend(labels = month.name[1:6], legend_gp = gpar(fill = 1:6), title = "foo", + labels_gp = gpar(col = "red", fontsize = 14)) > draw(lgd, test = "labels_gp") > > lgd = Legend(labels = month.name[1:6], legend_gp = gpar(fill = 1:6), title = "foo", + title_gp = gpar(col = "red", fontsize = 14)) > draw(lgd, test = "title_gp") > > lgd = Legend(labels = month.name[1:6], legend_gp = gpar(fill = 1:6), title = "foo", + border = "red") > draw(lgd, test = "legend border") > > lgd = Legend(labels = month.name[1:10], legend_gp = gpar(fill = 1:10), title = "foo", + ncol = 3) > draw(lgd, test = "in 3 columns") > > lgd = Legend(labels = month.name[1:10], legend_gp = gpar(fill = 1:10), title = "foo", + ncol = 3, title_position = "topcenter") > draw(lgd, test = "in 3 columns, title in the center") > > lgd = Legend(labels = month.name[1:10], legend_gp = gpar(fill = 1:10), title = "foo", + ncol = 3, by_row = TRUE) > draw(lgd, test = "in 3 columns and by rows") > > lgd = Legend(labels = month.name[1:10], legend_gp = gpar(fill = 1:10), title = "foo", + ncol = 3, gap = unit(1, "cm")) > draw(lgd, test = "in 3 columns with gap between columns") > > lgd = Legend(labels = month.name[1:10], legend_gp = gpar(fill = 1:10), title = "foo", + nrow = 3) > draw(lgd, test = "in 3 rows") > > lgd = Legend(labels = month.name[1:6], legend_gp = gpar(fill = 1:6), title = "foooooo", + nrow = 1, title_position = "lefttop") > draw(lgd, test = "1 row and title is on the left") > > lgd = Legend(labels = month.name[1:6], legend_gp = gpar(fill = 1:6), title = "foooooo", + nrow = 1, title_position = "lefttop-rot") > draw(lgd, test = "1 row and title is on the left, 90 rotation") > > lgd = Legend(labels = month.name[1:6], legend_gp = gpar(fill = 1:6), title = "foooooo", + nrow = 1, title_position = "leftcenter") > draw(lgd, test = "1 row and title is on the left, 90 rotation") > > lgd = Legend(labels = month.name[1:6], title = "foo", type = "points", pch = 1:6, + legend_gp = gpar(col = 1:6), background = "red") > draw(lgd, test = "points as legends") > > lgd = Legend(labels = month.name[1:6], title = "foo", type = "points", pch = letters[1:6], + legend_gp = gpar(col = 1:6), background = "white") > draw(lgd, test = "letters as legends") > > lgd = Legend(labels = month.name[1:6], title = "foo", type = "lines", + legend_gp = gpar(col = 1:6, lty = 1:6)) > draw(lgd, test = "lines as legends") > > ###### vertical continous legend ####### > col_fun = colorRamp2(c(0, 0.5, 1), c("blue", "white", "red")) > lgd = Legend(col_fun = col_fun, title = "foo") > draw(lgd, test = "only col_fun") > > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.25, 0.5, 0.75, 1)) > draw(lgd, test = "with at") > > lgd = Legend(col_fun = col_fun, title = "foo", at = rev(c(0, 0.25, 0.5, 0.75, 1))) > draw(lgd, test = "with at") > > > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.5, 1), labels = c("low", "median", "high")) > draw(lgd, test = "with labels") > > lgd = Legend(col_fun = col_fun, title = "foo", legend_height = unit(6, "cm")) > draw(lgd, test = "set legend_height") > > lgd = Legend(col_fun = col_fun, title = "foo", labels_gp = gpar(col = "red")) > draw(lgd, test = "set label color") > > lgd = Legend(col_fun = col_fun, title = "foo", border = "red") > draw(lgd, test = "legend border") > > lgd = Legend(col_fun = col_fun, title = "foooooooo", title_position = "lefttop-rot") > draw(lgd, test = "lefttop rot title") > > lgd = Legend(col_fun = col_fun, title = "foooooooo", title_position = "leftcenter-rot") > draw(lgd, test = "leftcenter top title") > > > lgd = Legend(col_fun = col_fun, title = "foo", title_position = "lefttop", direction = "horizontal") > draw(lgd, test = "lefttop title") > > ###### horizontal continous legend ####### > col_fun = colorRamp2(c(0, 0.5, 1), c("blue", "white", "red")) > lgd = Legend(col_fun = col_fun, title = "foo", direction = "horizontal") > draw(lgd, test = "only col_fun") > > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.25, 0.5, 0.75, 1), direction = "horizontal") > draw(lgd, test = "with at") > > lgd = Legend(col_fun = col_fun, title = "foo", at = rev(c(0, 0.25, 0.5, 0.75, 1)), direction = "horizontal") > draw(lgd, test = "with at") > > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.5, 1), labels = c("low", "median", "high"), + direction = "horizontal") > draw(lgd, test = "with labels") > > lgd = Legend(col_fun = col_fun, title = "foo", legend_width = unit(6, "cm"), direction = "horizontal") > draw(lgd, test = "set legend_width") > > lgd = Legend(col_fun = col_fun, title = "foo", labels_gp = gpar(col = "red"), direction = "horizontal") > draw(lgd, test = "set label color") > > lgd = Legend(col_fun = col_fun, title = "foo", border = "red", direction = "horizontal") > draw(lgd, test = "legend border") > > lgd = Legend(col_fun = col_fun, title = "foooooooo", direction = "horizontal", + title_position = "topcenter") > draw(lgd, test = "topcenter title") > > lgd = Legend(col_fun = col_fun, title = "foooooooo", direction = "horizontal", + title_position = "lefttop") > draw(lgd, test = "lefttop title") > > lgd = Legend(col_fun = col_fun, title = "foooooooo", direction = "horizontal", + title_position = "leftcenter") > draw(lgd, test = "leftcenter title") > > > ###### pack legend > lgd1 = Legend(at = 1:6, legend_gp = gpar(fill = 1:6), title = "legend1") > lgd2 = Legend(col_fun = col_fun, title = "legend2", at = c(0, 0.25, 0.5, 0.75, 1)) > > pd = packLegend(lgd1, lgd2) > draw(pd, test = "two legends") > > pd = packLegend(list = list(lgd1, lgd2)) > draw(pd, test = "two legends specified as a list") > > pd = packLegend(lgd1, lgd2, direction = "horizontal") > draw(pd, test = "two legends packed horizontally") > > lgd3 = Legend(at = 1:6, legend_gp = gpar(fill = 1:6), title = "legend1") > lgd4 = Legend(col_fun = col_fun, title = "legend2", at = c(0, 0.25, 0.5, 0.75, 1), direction = "horizontal") > pd = packLegend(lgd3, lgd4) > draw(pd, test = "two legends with different directions") > pd = packLegend(lgd3, lgd4, direction = "horizontal") > draw(pd, test = "two legends with different directions") > > pd = packLegend(lgd1, lgd2, lgd1, lgd2) > draw(pd, test = "many legends with same legends") > > lgd3 = Legend(at = 1:6, legend_gp = gpar(fill = 1:6), title = "legend1") > lgd4 = Legend(col_fun = col_fun, title = "legend2", at = c(0, 0.25, 0.5, 0.75, 1)) > pd = packLegend(lgd1, lgd2, lgd3, lgd4) > draw(pd, test = "many legends with all different legends") > > pd = packLegend(lgd1, lgd2, lgd1, lgd2, lgd1, lgd2) > draw(pd, test = "many legends") > > pd = packLegend(lgd1, lgd2, lgd1, lgd2, lgd1, lgd2, max_height = unit(1, "npc")) > draw(pd, test = "many legends, max_height = unit(1, 'npc')") > ## reduce the height of the interactive window and rerun draw() > > pd = packLegend(lgd1, lgd2, lgd1, lgd2, lgd1, lgd2, max_height = unit(10, "cm")) > draw(pd, test = "many legends, max_height = unit(10, 'cm')") > > pd = packLegend(lgd1, lgd2, lgd1, lgd2, lgd1, lgd2, max_height = unit(10, "cm"), gap = unit(1, "cm")) > draw(pd, test = "many legends, max_height = unit(10, 'cm'), with gap") > > lgd_long = Legend(at = 1:50, legend_gp = gpar(fill = 1:50)) > pd = packLegend(lgd1, lgd2, lgd1, lgd2, lgd1, lgd2, lgd_long, max_height = unit(10, "cm")) > draw(pd, test = "many legends with a long one, max_height = unit(10, 'cm')") > > lgd1 = Legend(at = 1:6, legend_gp = gpar(fill = 1:6), title = "legend1", + nr = 1) > lgd2 = Legend(col_fun = col_fun, title = "legend2", at = c(0, 0.25, 0.5, 0.75, 1), + direction = "horizontal") > pd = packLegend(lgd1, lgd2, lgd1, lgd2, lgd1, lgd2, direction = "horizontal") > draw(pd, test = "many legends") > > pd = packLegend(lgd1, lgd2, lgd1, lgd2, lgd1, lgd2, max_width = unit(1, "npc"), direction = "horizontal") > draw(pd, test = "many legends, max_width = unit(1, 'npc')") > ## reduce the height of the interactive window and rerun draw() > > pd = packLegend(lgd1, lgd2, lgd1, lgd2, lgd1, lgd2, max_width = unit(10, "cm"), direction = "horizontal") > draw(pd, test = "many legends, max_width = unit(10, 'cm')") > > > ####### unequal interval breaks > col_fun = colorRamp2(c(0, 0.5, 1), c("blue", "white", "red")) > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.1, 0.15, 0.5, 0.9, 0.95, 1)) > draw(lgd, test = "unequal interval breaks") > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.3, 1), legend_height = unit(4, "cm")) > draw(lgd, test = "unequal interval breaks but not label position adjustment") > > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.1, 0.15, 0.5, 0.9, 0.95, 1), + direction = "horizontal") > draw(lgd, test = "unequal interval breaks") > > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.1, 0.15, 0.5, 0.9, 0.95, 1), + direction = "horizontal", title_position = "lefttop") > draw(lgd, test = "unequal interval breaks") > > > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.1, 0.15, 0.5, 0.9, 0.95, 1), + direction = "horizontal", title_position = "lefttop", labels_rot = 90) > draw(lgd, test = "unequal interval breaks, label rot 90") > > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.1, 0.5, 0.75, 1), + labels = c("mininal", "q10", "median", "q75", "maximal"), + direction = "horizontal", title_position = "lefttop") > draw(lgd, test = "unequal interval breaks with labels") > > > lgd = Legend(col_fun = col_fun, title = "foo", at = c(0, 0.1, 0.5, 0.75, 1), + labels = c("mininal", "q10", "median", "q75", "maximal"), + direction = "horizontal") > draw(lgd, test = "unequal interval breaks with labels") > > > col_fun = colorRamp2(c(0, 0.05, 0.1, 0.5, 1), c("green", "white", "red", "black", "blue")) > lgd = Legend(col_fun = col_fun, title = "foo", break_dist = 1:4) > draw(lgd, test = "unequal interval breaks") > > > #### position of legends to heatmaps ## > if(0) { + m = matrix(rnorm(100), 10) + rownames(m) = random_str(10, len = 20) + colnames(m) = random_str(10, len = 20) + Heatmap(m) + } > > > > proc.time() user system elapsed 3.446 0.343 3.774
ComplexHeatmap.Rcheck/tests/test-multiple-page.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > m = matrix(rnorm(100), 10) > > postscript("test.ps") > lgd = Legend(labels = c("a", "b", "c")) > draw(Heatmap(m), heatmap_legend_list = list(lgd)) > dev.off() null device 1 > > check_pages = function() { + lines = readLines("test.ps") + print(lines[length(lines)-1]) + invisible(file.remove("test.ps")) + } > > check_pages() [1] "%%Pages: 1" > > postscript("test.ps") > ha = HeatmapAnnotation(foo = 1:10, bar = anno_points(1:10)) > Heatmap(m, top_annotation = ha) > dev.off() null device 1 > > check_pages() [1] "%%Pages: 1" > > proc.time() user system elapsed 6.061 0.182 6.229
ComplexHeatmap.Rcheck/tests/test-oncoPrint.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > mat = read.table(textConnection( + "s1,s2,s3 + g1,snv;indel,snv,indel + g2,,snv;indel,snv + g3,snv,,indel;snv"), row.names = 1, header = TRUE, sep = ",", stringsAsFactors = FALSE) > mat = as.matrix(mat) > > get_type_fun = function(x) strsplit(x, ";")[[1]] > > alter_fun = list( + snv = function(x, y, w, h) grid.rect(x, y, w*0.9, h*0.9, + gp = gpar(fill = col["snv"], col = NA)), + indel = function(x, y, w, h) grid.rect(x, y, w*0.9, h*0.4, + gp = gpar(fill = col["indel"], col = NA)) + ) > > col = c(snv = "red", indel = "blue") > ht = oncoPrint(mat, get_type = get_type_fun, + alter_fun = alter_fun, col = col) All mutation types: snv, indel. `alter_fun` is assumed vectorizable. If it does not generate correct plot, please set `alter_fun_is_vectorized = FALSE` in `oncoPrint()`. > draw(ht) > > ## turn off row names while turn on column names > ht = oncoPrint(mat, get_type = get_type_fun, + alter_fun = alter_fun, col = col, + show_column_names = TRUE, show_row_names = FALSE, show_pct = FALSE) All mutation types: snv, indel. `alter_fun` is assumed vectorizable. If it does not generate correct plot, please set `alter_fun_is_vectorized = FALSE` in `oncoPrint()`. > draw(ht) > > ht = oncoPrint(mat, get_type = get_type_fun, + alter_fun = alter_fun, col = col, pct_side = "right", + row_names_side = "left") All mutation types: snv, indel. `alter_fun` is assumed vectorizable. If it does not generate correct plot, please set `alter_fun_is_vectorized = FALSE` in `oncoPrint()`. > draw(ht) > > ht = oncoPrint(mat, get_type = get_type_fun, + alter_fun = alter_fun, col = col, + top_annotation = HeatmapAnnotation(column_barplot = anno_oncoprint_barplot()) + ) All mutation types: snv, indel. `alter_fun` is assumed vectorizable. If it does not generate correct plot, please set `alter_fun_is_vectorized = FALSE` in `oncoPrint()`. > draw(ht) > > ht = oncoPrint(mat, get_type = get_type_fun, + alter_fun = alter_fun, col = col, + top_annotation = HeatmapAnnotation( + column_barplot = anno_oncoprint_barplot(), + foo = 1:3, + annotation_name_side = "left") + ) All mutation types: snv, indel. `alter_fun` is assumed vectorizable. If it does not generate correct plot, please set `alter_fun_is_vectorized = FALSE` in `oncoPrint()`. > draw(ht) > > ht = oncoPrint(mat, get_type = get_type_fun, + alter_fun = alter_fun, col = col, + top_annotation = HeatmapAnnotation( + cbar = anno_oncoprint_barplot(), + foo1 = 1:3, + annotation_name_side = "left"), + left_annotation = rowAnnotation(foo2 = 1:3), + right_annotation = rowAnnotation(cbar = anno_oncoprint_barplot(), foo3 = 1:3), + ) All mutation types: snv, indel. `alter_fun` is assumed vectorizable. If it does not generate correct plot, please set `alter_fun_is_vectorized = FALSE` in `oncoPrint()`. > draw(ht) > > > ht = oncoPrint(mat, get_type = get_type_fun, + alter_fun = alter_fun, col = col, + top_annotation = HeatmapAnnotation( + cbar = anno_oncoprint_barplot(border = TRUE), + foo1 = 1:3, + annotation_name_side = "left"), + left_annotation = rowAnnotation(foo2 = 1:3), + right_annotation = rowAnnotation( + cbar = anno_oncoprint_barplot(border = TRUE), + foo3 = 1:3), + ) All mutation types: snv, indel. `alter_fun` is assumed vectorizable. If it does not generate correct plot, please set `alter_fun_is_vectorized = FALSE` in `oncoPrint()`. > draw(ht) > > ht = oncoPrint(mat, get_type = get_type_fun, + alter_fun = alter_fun, col = col, + right_annotation = rowAnnotation(rbar = anno_oncoprint_barplot(axis_param = list(side = "bottom", labels_rot = 90))) + ) All mutation types: snv, indel. `alter_fun` is assumed vectorizable. If it does not generate correct plot, please set `alter_fun_is_vectorized = FALSE` in `oncoPrint()`. > draw(ht) > > > proc.time() user system elapsed 8.338 0.252 8.577
ComplexHeatmap.Rcheck/tests/test-pheatmap.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > > if(requireNamespace("pheatmap")) { + mat = matrix(rnorm(100), 10) + + compare_pheatmap(mat) + + pheatmap(mat) + pheatmap(mat, col = rev(RColorBrewer::brewer.pal(n = 7, name = "RdYlBu"))) + + test = matrix(rnorm(200), 20, 10) + test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3 + test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2 + test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4 + colnames(test) = paste("Test", 1:10, sep = "") + rownames(test) = paste("Gene", 1:20, sep = "") + + # Draw heatmaps + compare_pheatmap(test) + compare_pheatmap(test, kmeans_k = 2) + compare_pheatmap(test, scale = "row", clustering_distance_rows = "correlation") + compare_pheatmap(test, color = colorRampPalette(c("navy", "white", "firebrick3"))(50)) + compare_pheatmap(test, cluster_row = FALSE) + compare_pheatmap(test, legend = FALSE) + + # Show text within cells + compare_pheatmap(test, display_numbers = TRUE) + compare_pheatmap(test, display_numbers = TRUE, number_format = "%.1e") + compare_pheatmap(test, display_numbers = matrix(ifelse(test > 5, "*", ""), nrow(test))) + compare_pheatmap(test, cluster_row = FALSE, legend_breaks = -1:4, legend_labels = c("0", + "1e-4", "1e-3", "1e-2", "1e-1", "1")) + + # Fix cell sizes and save to file with correct size + compare_pheatmap(test, cellwidth = 15, cellheight = 12, main = "Example heatmap") + + # Generate annotations for rows and columns + annotation_col = data.frame( + CellType = factor(rep(c("CT1", "CT2"), 5)), + Time = 1:5 + ) + rownames(annotation_col) = paste("Test", 1:10, sep = "") + + annotation_row = data.frame( + GeneClass = factor(rep(c("Path1", "Path2", "Path3"), c(10, 4, 6))) + ) + rownames(annotation_row) = paste("Gene", 1:20, sep = "") + + # Display row and color annotations + compare_pheatmap(test, annotation_col = annotation_col) + compare_pheatmap(test, annotation_col = annotation_col, annotation_legend = FALSE) + compare_pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row) + + # Change angle of text in the columns + compare_pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row, angle_col = "45") + compare_pheatmap(test, annotation_col = annotation_col, angle_col = "0") + + # Specify colors + ann_colors = list( + Time = c("white", "firebrick"), + CellType = c(CT1 = "#1B9E77", CT2 = "#D95F02"), + GeneClass = c(Path1 = "#7570B3", Path2 = "#E7298A", Path3 = "#66A61E") + ) + + compare_pheatmap(test, annotation_col = annotation_col, annotation_colors = ann_colors, main = "Title") + compare_pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row, + annotation_colors = ann_colors) + compare_pheatmap(test, annotation_col = annotation_col, annotation_colors = ann_colors[2]) + + # Gaps in heatmaps + compare_pheatmap(test, annotation_col = annotation_col, cluster_rows = FALSE, gaps_row = c(10, 14)) + compare_pheatmap(test, annotation_col = annotation_col, cluster_rows = FALSE, gaps_row = c(10, 14), + cutree_col = 2) + + # Show custom strings as row/col names + labels_row = c("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "Il10", "Il15", "Il1b") + + compare_pheatmap(test, annotation_col = annotation_col, labels_row = labels_row) + + # Specifying clustering from distance matrix + drows = dist(test, method = "minkowski") + dcols = dist(t(test), method = "minkowski") + compare_pheatmap(test, clustering_distance_rows = drows, clustering_distance_cols = dcols) + + library(dendsort) + + callback = function(hc, ...){dendsort(hc)} + compare_pheatmap(test, clustering_callback = callback) + } Loading required namespace: pheatmap Warning message: argument `kmeans_k` is not suggested to use in pheatmap -> Heatmap translation because it changes the input matrix. You might check `row_km` and `column_km` arguments in Heatmap(). > > proc.time() user system elapsed 19.657 0.249 19.894
ComplexHeatmap.Rcheck/tests/test-SingleAnnotation.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > ha = SingleAnnotation(value = 1:10) > draw(ha, test = "single column annotation") > ha = SingleAnnotation(value = 1:10, which = "row") > draw(ha, test = "single row annotation") > ha = SingleAnnotation(value = 1:10) > draw(ha, index = 6:10, test = "single column annotation, subset") > draw(ha, index = 6:10, k = 1, n = 2, test = "single column annotation, subset, k=1 n=2") > draw(ha, index = 6:10, k = 2, n = 2, test = "single column annotation, subset, k=1 n=2") > > x = 1:10 > ha = SingleAnnotation(value = x) > draw(ha, test = "single column annotation") > > m = cbind(1:10, 10:1) > colnames(m) = c("a", "b") > ha = SingleAnnotation(value = m) > draw(ha, test = "matrix as column annotation") > > ha = SingleAnnotation(value = 1:10, col = colorRamp2(c(1, 10), c("blue", "red"))) > draw(ha, test = "color mapping function") > > ha = SingleAnnotation(value = c(rep(c("a", "b"), 5))) > draw(ha, test = "discrete annotation") > ha = SingleAnnotation(value = c(rep(c("a", "b"), 5)), col = c("a" = "red", "b" = "blue")) > draw(ha, test = "discrete annotation with defined colors") > > anno = anno_simple(1:10) > ha = SingleAnnotation(fun = anno) > draw(ha, test = "AnnotationFunction as input") > > anno = anno_barplot(matrix(nc = 2, c(1:10, 10:1))) > ha = SingleAnnotation(fun = anno) > draw(ha, test = "anno_barplot as input") > draw(ha, index = 1:5, test = "anno_barplot as input, 1:5") > draw(ha, index = 1:5, k = 1, n = 2, test = "anno_barplot as input, 1:5, k = 1, n = 2") > draw(ha, index = 1:5, k = 2, n = 2, test = "anno_barplot as input, 1:5, k = 2, n = 2") > > lt = lapply(1:20, function(x) cumprod(1 + runif(1000, -x/100, x/100)) - 1) > anno = anno_horizon(lt, which = "row") > ha = SingleAnnotation(fun = anno, which = "row") > draw(ha, test = "anno_horizon as input") > > fun = local({ + value = 1:10 + function(index, k = 1, n = 1) { + pushViewport(viewport(xscale = c(0.5, length(index) + 0.5), yscale = range(value))) + grid.points(seq_along(index), value[index]) + grid.rect() + if(k == 1) grid.yaxis() + popViewport() + } + }) > ha = SingleAnnotation(fun = fun, height = unit(4, "cm")) > # ha[1:5] > draw(ha, index = c(1, 4, 2, 6), test = "self-defined function") > draw(ha, index = c(1, 4, 2, 6), k = 1, n = 2, test = "self-defined function, k = 1, n = 2") > draw(ha, index = c(1, 4, 2, 6), k = 2, n = 2, test = "self-defined function, k = 2, n = 2") > > > # test gridtext > ha = SingleAnnotation(value = 1:10, label = gt_render("foo", r = unit(2, "pt")), name_gp = gpar(box_fill = "red")) Loading required namespace: gridtext > draw(ha, test = "single column annotation") > > > > proc.time() user system elapsed 3.484 0.151 3.624
ComplexHeatmap.Rcheck/tests/test-upset.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > set.seed(123) > lt = list(a = sample(letters, 10), + b = sample(letters, 15), + c = sample(letters, 20)) > > m = make_comb_mat(lt) > t(m) A combination matrix with 3 sets and 6 combinations. ranges of combination set size: c(1, 8). mode for the combination size: distinct. sets are on columns Combination sets are: a b c code size x x x 111 4 x x 110 4 x x 101 2 x x 011 6 x 010 1 x 001 8 Sets are: set size a 10 b 15 c 20 > set_name(m) [1] "a" "b" "c" > comb_name(m) [1] "111" "110" "101" "011" "010" "001" > set_size(m) a b c 10 15 20 > comb_size(m) 111 110 101 011 010 001 4 4 2 6 1 8 > lapply(comb_name(m), function(x) extract_comb(m, x)) [[1]] [1] "e" "j" "x" "y" [[2]] [1] "c" "k" "n" "s" [[3]] [1] "o" "r" [[4]] [1] "a" "g" "h" "i" "l" "u" [[5]] [1] "d" [[6]] [1] "b" "f" "m" "q" "t" "v" "w" "z" > draw(UpSet(m)) > draw(UpSet(m, comb_col = c(rep(2, 3), rep(3, 3), 1))) > draw(UpSet(t(m))) > > set_name(t(m)) [1] "a" "b" "c" > comb_name(t(m)) [1] "111" "110" "101" "011" "010" "001" > set_size(t(m)) a b c 10 15 20 > comb_size(t(m)) 111 110 101 011 010 001 4 4 2 6 1 8 > lapply(comb_name(t(m)), function(x) extract_comb(t(m), x)) [[1]] [1] "e" "j" "x" "y" [[2]] [1] "c" "k" "n" "s" [[3]] [1] "o" "r" [[4]] [1] "a" "g" "h" "i" "l" "u" [[5]] [1] "d" [[6]] [1] "b" "f" "m" "q" "t" "v" "w" "z" > > m = make_comb_mat(lt, mode = "intersect") > lapply(comb_name(m), function(x) extract_comb(m, x)) [[1]] [1] "e" "j" "x" "y" [[2]] [1] "c" "e" "j" "k" "n" "s" "x" "y" [[3]] [1] "e" "j" "o" "r" "x" "y" [[4]] [1] "a" "e" "g" "h" "i" "j" "l" "u" "x" "y" [[5]] [1] "c" "e" "j" "k" "n" "o" "r" "s" "x" "y" [[6]] [1] "a" "c" "d" "e" "g" "h" "i" "j" "k" "l" "n" "s" "u" "x" "y" [[7]] [1] "a" "b" "e" "f" "g" "h" "i" "j" "l" "m" "o" "q" "r" "t" "u" "v" "w" "x" "y" [20] "z" > draw(UpSet(m)) > > m = make_comb_mat(lt, mode = "union") > lapply(comb_name(m), function(x) extract_comb(m, x)) [[1]] [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "q" "r" "s" "t" [20] "u" "v" "w" "x" "y" "z" [[2]] [1] "a" "c" "d" "e" "g" "h" "i" "j" "k" "l" "n" "o" "r" "s" "u" "x" "y" [[3]] [1] "a" "b" "c" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "q" "r" "s" "t" "u" [20] "v" "w" "x" "y" "z" [[4]] [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "q" "r" "s" "t" [20] "u" "v" "w" "x" "y" "z" [[5]] [1] "c" "e" "j" "k" "n" "o" "r" "s" "x" "y" [[6]] [1] "a" "c" "d" "e" "g" "h" "i" "j" "k" "l" "n" "s" "u" "x" "y" [[7]] [1] "a" "b" "e" "f" "g" "h" "i" "j" "l" "m" "o" "q" "r" "t" "u" "v" "w" "x" "y" [20] "z" > draw(UpSet(m)) > > f = system.file("extdata", "movies.csv", package = "UpSetR") > if(file.exists(f)) { + movies <- read.csv(system.file("extdata", "movies.csv", package = "UpSetR"), header = T, sep = ";") + m = make_comb_mat(movies, top_n_sets = 6) + t(m) + set_name(m) + comb_name(m) + set_size(m) + comb_size(m) + lapply(comb_name(m), function(x) extract_comb(m, x)) + + set_name(t(m)) + comb_name(t(m)) + set_size(t(m)) + comb_size(t(m)) + lapply(comb_name(t(m)), function(x) extract_comb(t(m), x)) + + draw(UpSet(m)) + draw(UpSet(t(m))) + + m = make_comb_mat(movies, top_n_sets = 6, mode = "intersect") + m = make_comb_mat(movies, top_n_sets = 6, mode = "union") + } > > library(circlize) > library(GenomicRanges) Loading required package: stats4 Loading required package: BiocGenerics Loading required package: parallel Attaching package: 'BiocGenerics' The following objects are masked from 'package:parallel': clusterApply, clusterApplyLB, clusterCall, clusterEvalQ, clusterExport, clusterMap, parApply, parCapply, parLapply, parLapplyLB, parRapply, parSapply, parSapplyLB The following objects are masked from 'package:stats': IQR, mad, sd, var, xtabs The following objects are masked from 'package:base': Filter, Find, Map, Position, Reduce, anyDuplicated, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted, lapply, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind, rownames, sapply, setdiff, sort, table, tapply, union, unique, unsplit, which.max, which.min Loading required package: S4Vectors Attaching package: 'S4Vectors' The following objects are masked from 'package:base': I, expand.grid, unname Loading required package: IRanges Loading required package: GenomeInfoDb > lt = lapply(1:4, function(i) generateRandomBed()) > lt = lapply(lt, function(df) GRanges(seqnames = df[, 1], ranges = IRanges(df[, 2], df[, 3]))) > names(lt) = letters[1:4] > m = make_comb_mat(lt) > > # if(0) { > # set.seed(123) > # lt = list(a = sample(letters, 10), > # b = sample(letters, 15), > # c = sample(letters, 20)) > # v = gplots::venn(lt, show.plot = FALSE) > # rownames(v) = apply(v[, -1], 1, paste, collapse = "") > # m = make_comb_mat(lt) > # cs = structure(comb_size(m), names = comb_name(m)) > # } > > if(file.exists(f)) { + movies <- read.csv(f, header = T, sep = ";") + genre = c("Action", "Romance", "Horror", "Children", "SciFi", "Documentary") + rate = cut(movies$AvgRating, c(0, 1, 2, 3, 4, 5)) + m_list = tapply(seq_len(nrow(movies)), rate, function(ind) { + make_comb_mat(movies[ind, genre, drop = FALSE]) + }) + m_list2 = normalize_comb_mat(m_list) + + lapply(m_list2, set_name) + lapply(m_list2, set_size) + lapply(m_list2, comb_name) + lapply(m_list2, comb_size) + + lapply(1:length(m_list), function(i) { + n1 = comb_name(m_list[[i]]) + x1 = comb_size(m_list[[i]]) + n2 = comb_name(m_list2[[i]]) + x2 = comb_size(m_list2[[i]]) + l = n2 %in% n1 + x2[!l] + }) + } [[1]] 110001 100101 100011 110000 100100 100010 100001 010100 010010 010001 000110 0 0 0 0 0 0 0 0 0 0 0 000101 000011 100000 000010 0 0 0 1 [[2]] 110001 100101 100011 100001 010100 010010 010001 000110 000101 000011 1 1 0 5 0 0 0 0 8 0 [[3]] 110001 100101 100011 100001 010001 000101 000011 0 4 0 35 7 27 1 [[4]] 110001 100101 100011 100100 100001 010001 000101 000011 1 6 1 6 45 5 11 4 [[5]] 110001 100101 100011 100100 100001 010100 010010 010001 000110 000101 000011 0 1 1 1 6 0 0 0 0 0 0 > > > proc.time() user system elapsed 18.619 0.259 18.867
ComplexHeatmap.Rcheck/tests/test-utils.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(circlize) ======================================== circlize version 0.4.13 CRAN page: https://cran.r-project.org/package=circlize Github page: https://github.com/jokergoo/circlize Documentation: https://jokergoo.github.io/circlize_book/book/ If you use it in published research, please cite: Gu, Z. circlize implements and enhances circular visualization in R. Bioinformatics 2014. This message can be suppressed by: suppressPackageStartupMessages(library(circlize)) ======================================== > library(ComplexHeatmap) Loading required package: grid ======================================== ComplexHeatmap version 2.8.0 Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ Github page: https://github.com/jokergoo/ComplexHeatmap Documentation: http://jokergoo.github.io/ComplexHeatmap-reference If you use it in published research, please cite: Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics 2016. The new InteractiveComplexHeatmap package can directly export static complex heatmaps into an interactive Shiny app with zero effort. Have a try! This message can be suppressed by: suppressPackageStartupMessages(library(ComplexHeatmap)) ======================================== > library(GetoptLong) > > # things needed to be tested > # 1. the order > # 2. if the sum of sizes are larger than xlim > > make_plot = function(pos1, pos2, range) { + oxpd = par("xpd") + par(xpd = NA) + plot(NULL, xlim = c(0, 4), ylim = range, ann = FALSE) + col = rand_color(nrow(pos1), transparency = 0.5) + rect(0.5, pos1[, 1], 1.5, pos1[, 2], col = col) + rect(2.5, pos2[, 1], 3.5, pos2[, 2], col = col) + segments(1.5, rowMeans(pos1), 2.5, rowMeans(pos2)) + par(xpd = oxpd) + } > > range = c(0, 10) > pos1 = rbind(c(1, 2), c(5, 7)) > make_plot(pos1, smartAlign2(pos1, range = range), range) > > range = c(0, 10) > pos1 = rbind(c(-0.5, 2), c(5, 7)) > make_plot(pos1, smartAlign2(pos1, range = range), range) > > pos1 = rbind(c(-1, 2), c(3, 4), c(5, 6), c(7, 11)) > pos1 = pos1 + runif(length(pos1), max = 0.3, min = -0.3) > par(mfrow = c(3, 3)) > for(i in 1:9) { + ind = sample(4, 4) + make_plot(pos1[ind, ], smartAlign2(pos1[ind, ], range = range), range) + } > par(mfrow = c(1, 1)) > > pos1 = rbind(c(3, 6), c(4, 7)) > make_plot(pos1, smartAlign2(pos1, range = range), range) > > pos1 = rbind(c(1, 8), c(3, 10)) > make_plot(pos1, smartAlign2(pos1, range = range), range) > > ########## new version of smartAlign2() ############ > > start = c(0.0400972528391016, 0.0491583597430212, 0.0424302664385027, 0.0547524243812509, 0.0820937279769642, 0.126861283282835, 0.178503822565168, 0.327742831447437, 0.570671411156898, 0.81775868755151) > end = c(0.0921142856224367, 0.107091640256979, 0.137858195099959, 0.159189883311057, 0.177521656638421, 0.20727333210178, 0.304669254357909, 0.463122553167947, 0.676924742689255, 0.929837466294643) > range = c(0, 1) > smartAlign2(start, end, range, plot = TRUE) enter to continue [,1] [,2] [1,] 0.002200888 0.05421792 [2,] 0.054217921 0.11215120 [3,] 0.112151202 0.20757913 [4,] 0.207579130 0.31201659 [5,] 0.312016589 0.40744452 [6,] 0.407444518 0.48785657 [7,] 0.487856567 0.61402200 [8,] 0.614021999 0.74940172 [9,] 0.749401720 0.85565505 [10,] 0.855655052 0.96773383 > > > start <- c(0.722121284290678, 0.701851666769472, 0.284795592003117, 0.335674695572052, 0.246977082249377, 0.767289857630785, 0.728198060058033, 0.299241440370817, -0.0149946764559372, 0.85294351791166, 0.126216621670218, 0.478169948493225) > end <- c(0.766196472718668, 0.763101604258565, 0.34604552949221, 0.421334650222341, 0.344144413077725, 0.847196123677626, 0.813858014708322, 0.392347344675911, 0.108452620381171, 0.969486388630396, 0.249951602628847, 0.584914163656308) > od = order(start) > start = start[od]; end = end[od] > range = c(0, 1) > pos = smartAlign2(start, end, range) > n = nrow(pos) > pos[1:(n-1), 2] > pos[2:n, 1] [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE > > > if(0) { + go_id = random_GO(500) + mat = GO_similarity(go_id) + invisible(simplify(mat, order_by_size = FALSE)) + } > > proc.time() user system elapsed 2.451 0.143 2.577
ComplexHeatmap.Rcheck/tests/testthat-all.Rout
R version 4.1.1 (2021-08-10) -- "Kick Things" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > > suppressWarnings(suppressPackageStartupMessages(library(ComplexHeatmap))) > library(testthat) > > test_check("ComplexHeatmap") [ FAIL 0 | WARN 0 | SKIP 0 | PASS 181 ] > > proc.time() user system elapsed 19.151 0.613 19.689
ComplexHeatmap.Rcheck/ComplexHeatmap-Ex.timings
name | user | system | elapsed | |
AdditiveUnit-class | 0 | 0 | 0 | |
AdditiveUnit | 0 | 0 | 0 | |
AnnotationFunction-class | 0 | 0 | 0 | |
AnnotationFunction | 3.723 | 0.044 | 3.766 | |
ColorMapping-class | 0 | 0 | 0 | |
ColorMapping | 0.012 | 0.000 | 0.012 | |
ComplexHeatmap-package | 0 | 0 | 0 | |
Extract.AnnotationFunction | 0.020 | 0.000 | 0.019 | |
Extract.Heatmap | 0.480 | 0.012 | 0.492 | |
Extract.HeatmapAnnotation | 0.04 | 0.00 | 0.04 | |
Extract.HeatmapList | 0.137 | 0.000 | 0.137 | |
Extract.SingleAnnotation | 0.017 | 0.000 | 0.016 | |
Extract.comb_mat | 0.008 | 0.004 | 0.011 | |
Extract.gridtext | 0 | 0 | 0 | |
Heatmap-class | 0 | 0 | 0 | |
Heatmap | 0 | 0 | 0 | |
Heatmap3D | 0.142 | 0.001 | 0.144 | |
HeatmapAnnotation-class | 0.000 | 0.000 | 0.001 | |
HeatmapAnnotation | 0 | 0 | 0 | |
HeatmapList-class | 0 | 0 | 0 | |
HeatmapList | 0.000 | 0.001 | 0.000 | |
Legend | 0.056 | 0.007 | 0.063 | |
Legends-class | 0.007 | 0.000 | 0.007 | |
Legends | 0.000 | 0.000 | 0.001 | |
SingleAnnotation-class | 0.001 | 0.000 | 0.000 | |
SingleAnnotation | 0.051 | 0.000 | 0.051 | |
UpSet | 0.405 | 0.000 | 0.405 | |
add.AdditiveUnit | 0 | 0 | 0 | |
add_heatmap-Heatmap-method | 0.000 | 0.001 | 0.000 | |
add_heatmap-HeatmapAnnotation-method | 0 | 0 | 0 | |
add_heatmap-HeatmapList-method | 0 | 0 | 0 | |
add_heatmap-dispatch | 0 | 0 | 0 | |
adjust_dend_by_x | 0.010 | 0.004 | 0.014 | |
adjust_heatmap_list-HeatmapList-method | 0 | 0 | 0 | |
alter_graphic | 0.149 | 0.000 | 0.150 | |
anno_barplot | 0.019 | 0.000 | 0.019 | |
anno_block | 0.717 | 0.000 | 0.717 | |
anno_boxplot | 0.024 | 0.000 | 0.025 | |
anno_density | 0.401 | 0.008 | 0.408 | |
anno_empty | 0.010 | 0.004 | 0.015 | |
anno_histogram | 0.070 | 0.000 | 0.071 | |
anno_horizon | 3.662 | 0.040 | 3.702 | |
anno_image | 0 | 0 | 0 | |
anno_joyplot | 0.386 | 0.000 | 0.386 | |
anno_lines | 0.077 | 0.008 | 0.085 | |
anno_link | 0 | 0 | 0 | |
anno_mark | 0.372 | 0.008 | 0.379 | |
anno_oncoprint_barplot | 0.001 | 0.000 | 0.000 | |
anno_points | 0.019 | 0.000 | 0.019 | |
anno_simple | 0.045 | 0.000 | 0.044 | |
anno_summary | 0.251 | 0.000 | 0.250 | |
anno_text | 0.055 | 0.004 | 0.059 | |
anno_zoom | 0.357 | 0.000 | 0.357 | |
annotation_axis_grob | 0.038 | 0.020 | 0.058 | |
annotation_legend_size-HeatmapList-method | 0.001 | 0.000 | 0.001 | |
attach_annotation-Heatmap-method | 0.664 | 0.000 | 0.663 | |
bar3D | 0.006 | 0.000 | 0.006 | |
bin_genome | 0 | 0 | 0 | |
c.ColorMapping | 0.001 | 0.000 | 0.001 | |
c.HeatmapAnnotation | 0.032 | 0.000 | 0.032 | |
cluster_between_groups | 0.022 | 0.000 | 0.022 | |
cluster_within_group | 0.021 | 0.000 | 0.021 | |
color_mapping_legend-ColorMapping-method | 0 | 0 | 0 | |
columnAnnotation | 0 | 0 | 0 | |
column_dend-Heatmap-method | 0.239 | 0.004 | 0.242 | |
column_dend-HeatmapList-method | 0.811 | 0.008 | 0.819 | |
column_dend-dispatch | 0.001 | 0.000 | 0.000 | |
column_order-Heatmap-method | 0.499 | 0.004 | 0.503 | |
column_order-HeatmapList-method | 0.793 | 0.004 | 0.797 | |
column_order-dispatch | 0 | 0 | 0 | |
comb_degree | 0.001 | 0.000 | 0.001 | |
comb_name | 0.002 | 0.000 | 0.002 | |
comb_size | 0.001 | 0.000 | 0.001 | |
compare_heatmap.2 | 0.835 | 0.016 | 0.851 | |
compare_heatmap | 0.583 | 0.004 | 0.587 | |
compare_pheatmap | 0.449 | 0.004 | 0.453 | |
complement_size | 0 | 0 | 0 | |
component_height-Heatmap-method | 0 | 0 | 0 | |
component_height-HeatmapList-method | 0.000 | 0.001 | 0.000 | |
component_height-dispatch | 0.000 | 0.000 | 0.001 | |
component_width-Heatmap-method | 0 | 0 | 0 | |
component_width-HeatmapList-method | 0 | 0 | 0 | |
component_width-dispatch | 0.000 | 0.001 | 0.000 | |
copy_all-AnnotationFunction-method | 0.000 | 0.000 | 0.001 | |
copy_all-SingleAnnotation-method | 0 | 0 | 0 | |
copy_all-dispatch | 0 | 0 | 0 | |
decorate_annotation | 0.211 | 0.004 | 0.215 | |
decorate_column_dend | 0 | 0 | 0 | |
decorate_column_names | 0.001 | 0.000 | 0.001 | |
decorate_column_title | 0 | 0 | 0 | |
decorate_dend | 0.12 | 0.00 | 0.12 | |
decorate_dimnames | 0.128 | 0.004 | 0.132 | |
decorate_heatmap_body | 0.110 | 0.004 | 0.114 | |
decorate_row_dend | 0 | 0 | 0 | |
decorate_row_names | 0 | 0 | 0 | |
decorate_row_title | 0 | 0 | 0 | |
decorate_title | 0.121 | 0.000 | 0.121 | |
default_axis_param | 0.001 | 0.000 | 0.001 | |
default_get_type | 0.001 | 0.000 | 0.000 | |
dend_heights | 0 | 0 | 0 | |
dend_xy | 0.004 | 0.003 | 0.008 | |
dendrogramGrob | 0 | 0 | 0 | |
densityHeatmap | 0.951 | 0.008 | 0.959 | |
dim.Heatmap | 0 | 0 | 0 | |
dist2 | 0.008 | 0.000 | 0.008 | |
draw-AnnotationFunction-method | 0 | 0 | 0 | |
draw-Heatmap-method | 0.001 | 0.000 | 0.000 | |
draw-HeatmapAnnotation-method | 0 | 0 | 0 | |
draw-HeatmapList-method | 0 | 0 | 0 | |
draw-Legends-method | 0.010 | 0.000 | 0.011 | |
draw-SingleAnnotation-method | 0 | 0 | 0 | |
draw-dispatch | 0 | 0 | 0 | |
draw_annotation-Heatmap-method | 0 | 0 | 0 | |
draw_annotation_legend-HeatmapList-method | 0.001 | 0.000 | 0.001 | |
draw_dend-Heatmap-method | 0 | 0 | 0 | |
draw_dimnames-Heatmap-method | 0 | 0 | 0 | |
draw_heatmap_body-Heatmap-method | 0.000 | 0.001 | 0.000 | |
draw_heatmap_legend-HeatmapList-method | 0.000 | 0.000 | 0.001 | |
draw_heatmap_list-HeatmapList-method | 0 | 0 | 0 | |
draw_title-Heatmap-method | 0.000 | 0.001 | 0.000 | |
draw_title-HeatmapList-method | 0.000 | 0.000 | 0.001 | |
draw_title-dispatch | 0 | 0 | 0 | |
extract_comb | 0.000 | 0.002 | 0.002 | |
frequencyHeatmap | 0.472 | 0.004 | 0.477 | |
full_comb_code | 0.003 | 0.000 | 0.003 | |
getXY_in_parent_vp | 0.003 | 0.004 | 0.007 | |
get_color_mapping_list-HeatmapAnnotation-method | 0 | 0 | 0 | |
get_legend_param_list-HeatmapAnnotation-method | 0 | 0 | 0 | |
grid.annotation_axis | 0 | 0 | 0 | |
grid.boxplot | 0.004 | 0.002 | 0.006 | |
grid.dendrogram | 0.437 | 0.012 | 0.450 | |
grid.draw.Legends | 0.01 | 0.00 | 0.01 | |
gt_render | 0.556 | 0.000 | 0.557 | |
heatmap_legend_size-HeatmapList-method | 0 | 0 | 0 | |
height.AnnotationFunction | 0.003 | 0.004 | 0.007 | |
height.Heatmap | 0.001 | 0.000 | 0.000 | |
height.HeatmapAnnotation | 0 | 0 | 0 | |
height.HeatmapList | 0 | 0 | 0 | |
height.Legends | 0.012 | 0.000 | 0.012 | |
height.SingleAnnotation | 0.001 | 0.000 | 0.001 | |
heightAssign.AnnotationFunction | 0 | 0 | 0 | |
heightAssign.HeatmapAnnotation | 0 | 0 | 0 | |
heightAssign.SingleAnnotation | 0 | 0 | 0 | |
heightDetails.annotation_axis | 0.001 | 0.000 | 0.000 | |
heightDetails.legend | 0 | 0 | 0 | |
heightDetails.legend_body | 0 | 0 | 0 | |
heightDetails.packed_legends | 0.001 | 0.000 | 0.001 | |
ht_global_opt | 0 | 0 | 0 | |
ht_opt | 0.006 | 0.000 | 0.006 | |
ht_size | 0 | 0 | 0 | |
is_abs_unit | 0.001 | 0.000 | 0.001 | |
length.HeatmapAnnotation | 0 | 0 | 0 | |
length.HeatmapList | 0 | 0 | 0 | |
list_components | 0 | 0 | 0 | |
list_to_matrix | 0.001 | 0.001 | 0.002 | |
make_column_cluster-Heatmap-method | 0 | 0 | 0 | |
make_comb_mat | 0.003 | 0.001 | 0.004 | |
make_layout-Heatmap-method | 0 | 0 | 0 | |
make_layout-HeatmapList-method | 0 | 0 | 0 | |
make_layout-dispatch | 0 | 0 | 0 | |
make_row_cluster-Heatmap-method | 0 | 0 | 0 | |
map_to_colors-ColorMapping-method | 0.011 | 0.003 | 0.014 | |
max_text_height | 0.000 | 0.001 | 0.002 | |
max_text_width | 0.002 | 0.000 | 0.001 | |
merge_dendrogram | 0.075 | 0.004 | 0.079 | |
names.HeatmapAnnotation | 0.011 | 0.000 | 0.011 | |
names.HeatmapList | 0.001 | 0.000 | 0.000 | |
namesAssign.HeatmapAnnotation | 0.011 | 0.000 | 0.011 | |
ncol.Heatmap | 0 | 0 | 0 | |
nobs.AnnotationFunction | 0.003 | 0.000 | 0.003 | |
nobs.HeatmapAnnotation | 0 | 0 | 0 | |
nobs.SingleAnnotation | 0.001 | 0.000 | 0.001 | |
normalize_comb_mat | 0 | 0 | 0 | |
normalize_genomic_signals_to_bins | 0.000 | 0.001 | 0.001 | |
nrow.Heatmap | 0.000 | 0.001 | 0.000 | |
oncoPrint | 0 | 0 | 0 | |
order.comb_mat | 0 | 0 | 0 | |
packLegend | 0.049 | 0.001 | 0.049 | |
pct_v_pct | 0 | 0 | 0 | |
pheatmap | 0.000 | 0.000 | 0.001 | |
pindex | 0.005 | 0.000 | 0.005 | |
prepare-Heatmap-method | 0.001 | 0.000 | 0.000 | |
print.comb_mat | 0 | 0 | 0 | |
re_size-HeatmapAnnotation-method | 0 | 0 | 0 | |
restore_matrix | 0.306 | 0.004 | 0.310 | |
rowAnnotation | 0.001 | 0.000 | 0.000 | |
row_anno_barplot | 0 | 0 | 0 | |
row_anno_boxplot | 0 | 0 | 0 | |
row_anno_density | 0.001 | 0.000 | 0.001 | |
row_anno_histogram | 0 | 0 | 0 | |
row_anno_points | 0 | 0 | 0 | |
row_anno_text | 0.000 | 0.000 | 0.001 | |
row_dend-Heatmap-method | 0.335 | 0.003 | 0.338 | |
row_dend-HeatmapList-method | 0.715 | 0.000 | 0.715 | |
row_dend-dispatch | 0 | 0 | 0 | |
row_order-Heatmap-method | 0.274 | 0.004 | 0.278 | |
row_order-HeatmapList-method | 0.666 | 0.003 | 0.670 | |
row_order-dispatch | 0.001 | 0.001 | 0.001 | |
set_component_height-Heatmap-method | 0 | 0 | 0 | |
set_component_width-Heatmap-method | 0 | 0 | 0 | |
set_name | 0.002 | 0.000 | 0.002 | |
set_nameAssign | 0.006 | 0.000 | 0.006 | |
set_size | 0.002 | 0.000 | 0.002 | |
show-AnnotationFunction-method | 0 | 0 | 0 | |
show-ColorMapping-method | 0.001 | 0.000 | 0.001 | |
show-Heatmap-method | 0 | 0 | 0 | |
show-HeatmapAnnotation-method | 0 | 0 | 0 | |
show-HeatmapList-method | 0 | 0 | 0 | |
show-SingleAnnotation-method | 0.001 | 0.000 | 0.000 | |
show-dispatch | 0 | 0 | 0 | |
size.AnnotationFunction | 0.008 | 0.000 | 0.008 | |
size.HeatmapAnnotation | 0.001 | 0.000 | 0.001 | |
size.SingleAnnotation | 0 | 0 | 0 | |
sizeAssign.AnnotationFunction | 0.004 | 0.000 | 0.004 | |
sizeAssign.HeatmapAnnotation | 0 | 0 | 0 | |
sizeAssign.SingleAnnotation | 0 | 0 | 0 | |
smartAlign2 | 0.226 | 0.004 | 0.230 | |
str.comb_mat | 0 | 0 | 0 | |
subset_gp | 0 | 0 | 0 | |
subset_matrix_by_row | 0 | 0 | 0 | |
subset_vector | 0 | 0 | 0 | |
summary.Heatmap | 0.001 | 0.000 | 0.001 | |
summary.HeatmapList | 0 | 0 | 0 | |
t.comb_mat | 0.000 | 0.005 | 0.005 | |
test_alter_fun | 0.048 | 0.001 | 0.050 | |
unify_mat_list | 0 | 0 | 0 | |
upset_right_annotation | 0 | 0 | 0 | |
upset_top_annotation | 0.001 | 0.000 | 0.001 | |
width.AnnotationFunction | 0.007 | 0.000 | 0.007 | |
width.Heatmap | 0 | 0 | 0 | |
width.HeatmapAnnotation | 0 | 0 | 0 | |
width.HeatmapList | 0.000 | 0.000 | 0.001 | |
width.Legends | 0.011 | 0.003 | 0.014 | |
width.SingleAnnotation | 0 | 0 | 0 | |
widthAssign.AnnotationFunction | 0 | 0 | 0 | |
widthAssign.HeatmapAnnotation | 0.001 | 0.000 | 0.001 | |
widthAssign.SingleAnnotation | 0 | 0 | 0 | |
widthDetails.annotation_axis | 0 | 0 | 0 | |
widthDetails.legend | 0 | 0 | 0 | |
widthDetails.legend_body | 0.000 | 0.000 | 0.001 | |
widthDetails.packed_legends | 0 | 0 | 0 | |