Back to Multiple platform build/check report for BioC 3.15
AB[C]DEFGHIJKLMNOPQRSTUVWXYZ

This page was generated on 2022-10-19 13:22:45 -0400 (Wed, 19 Oct 2022).

HostnameOSArch (*)R versionInstalled pkgs
nebbiolo1Linux (Ubuntu 20.04.5 LTS)x86_644.2.1 (2022-06-23) -- "Funny-Looking Kid" 4386
palomino3Windows Server 2022 Datacenterx644.2.1 (2022-06-23 ucrt) -- "Funny-Looking Kid" 4138
merida1macOS 10.14.6 Mojavex86_644.2.1 (2022-06-23) -- "Funny-Looking Kid" 4205
Click on any hostname to see more info about the system (e.g. compilers)      (*) as reported by 'uname -p', except on Windows and Mac OS X

CHECK results for ComplexHeatmap on merida1


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? for more information.
- Make sure to use the following settings in order to reproduce any error or warning you see on this page.

raw results

Package 392/2140HostnameOS / ArchINSTALLBUILDCHECKBUILD BIN
ComplexHeatmap 2.12.1  (landing page)
Zuguang Gu
Snapshot Date: 2022-10-18 13:55:19 -0400 (Tue, 18 Oct 2022)
git_url: https://git.bioconductor.org/packages/ComplexHeatmap
git_branch: RELEASE_3_15
git_last_commit: 2c5fe70
git_last_commit_date: 2022-08-08 15:31:16 -0400 (Mon, 08 Aug 2022)
nebbiolo1Linux (Ubuntu 20.04.5 LTS) / x86_64  OK    OK    OK  UNNEEDED, same version is already published
palomino3Windows Server 2022 Datacenter / x64  OK    OK    OK    OK  UNNEEDED, same version is already published
merida1macOS 10.14.6 Mojave / x86_64  OK    OK    OK    OK  UNNEEDED, same version is already published

Summary

Package: ComplexHeatmap
Version: 2.12.1
Command: /Library/Frameworks/R.framework/Resources/bin/R CMD check --install=check:ComplexHeatmap.install-out.txt --library=/Library/Frameworks/R.framework/Resources/library --no-vignettes --timings ComplexHeatmap_2.12.1.tar.gz
StartedAt: 2022-10-19 00:54:44 -0400 (Wed, 19 Oct 2022)
EndedAt: 2022-10-19 01:05:32 -0400 (Wed, 19 Oct 2022)
EllapsedTime: 648.5 seconds
RetCode: 0
Status:   OK  
CheckDir: ComplexHeatmap.Rcheck
Warnings: 0

Command output

##############################################################################
##############################################################################
###
### Running command:
###
###   /Library/Frameworks/R.framework/Resources/bin/R CMD check --install=check:ComplexHeatmap.install-out.txt --library=/Library/Frameworks/R.framework/Resources/library --no-vignettes --timings ComplexHeatmap_2.12.1.tar.gz
###
##############################################################################
##############################################################################


* using log directory ‘/Users/biocbuild/bbs-3.15-bioc/meat/ComplexHeatmap.Rcheck’
* using R version 4.2.1 (2022-06-23)
* using platform: x86_64-apple-darwin17.0 (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.12.1’
* 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
Examples with CPU (user + system) or elapsed time > 5s
                   user system elapsed
AnnotationFunction 8.49  0.129   8.654
anno_horizon       8.31  0.084   8.407
* 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-textbox.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


Installation output

ComplexHeatmap.Rcheck/00install.out

##############################################################################
##############################################################################
###
### Running command:
###
###   /Library/Frameworks/R.framework/Resources/bin/R CMD INSTALL ComplexHeatmap
###
##############################################################################
##############################################################################


* installing to library ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/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)

Tests output

ComplexHeatmap.Rcheck/tests/test-annotation_axis.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
  4.278   0.260   4.520 

ComplexHeatmap.Rcheck/tests/test-AnnotationFunction.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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))
> 
> 
> x = runif(10)
> cell_fun = function(i) {
+ 	pushViewport(viewport(yscale = c(0, 1)))
+ 	grid.points(unit(0.5, "npc"), x[i])
+ 	popViewport()
+ }
> anno = AnnotationFunction(cell_fun = cell_fun, var_import = "x")
> ha = HeatmapAnnotation(foo = anno)
> draw(ha, 1:10, test = T)
> 
> cell_fun = function(i) {
+ 	pushViewport(viewport(xscale = c(0, 1)))
+ 	grid.points(x[i], unit(0.5, "npc"))
+ 	popViewport()
+ }
> anno = AnnotationFunction(cell_fun = cell_fun, var_import = "x", which = "row")
> ha = rowAnnotation(foo = anno)
> draw(ha, 1:10, test = T)
> 
> # 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")
> 
> 
> anno = anno_barplot(matrix(nc = 2, c(1:10, 10:1)), beside = TRUE)
> draw(anno, test = "a matrix")
> draw(anno[1:5], test = "a matrix, subset")
> anno = anno_barplot(matrix(nc = 2, c(1:10, 10:1)), beside = TRUE, which = "row")
> draw(anno, test = "a matrix, on rows")
> anno = anno_barplot(matrix(nc = 2, c(1:10, 10:1)), beside = TRUE, gp = gpar(fill = 2:3, col = 2:3))
> draw(anno, test = "a matrix with fill")
> 
> 
> 
> ##### 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))
> 
> 
> 
> #### anno_customize ###
> x = sort(sample(letters[1:3], 10, replace = TRUE))
> graphics = list(
+ 	"a" = function(x, y, w, h) grid.points(x, y, pch = 16),
+ 	"b" = function(x, y, w, h) grid.rect(x, y, w*0.8, h*0.8, gp = gpar(fill = "red")),
+ 	"c" = function(x, y, w, h) grid.segments(x - 0.5*w, y - 0.5*h, x + 0.5*w, y + 0.5*h, gp = gpar(lty = 2))
+ )
> 
> anno = anno_customize(x, graphics = graphics)
> draw(anno, index = 1:10, test = "")
> 
> anno = anno_customize(c(x, "d"), graphics = graphics)
Note: following levels in `x` have no graphics defined:
    d.
Set `verbose = FALSE` in `anno_customize()` to turn off this message.
> 
> ### anno_numeric ##
> x = runif(10)
> anno = anno_numeric(x)
> draw(anno, 1:10, test = TRUE)
> anno = anno_numeric(x, align_to = "right")
> draw(anno, 1:10, test = TRUE)
> 
> 
> x = 10^(-runif(10, 1, 6))
> anno = anno_numeric(x, x_convert = function(x) -log10(x), labels_format = function(x) sprintf("%.2e", x))
> draw(anno, 1:10, test = TRUE)
> 
> x = runif(10, -1, 1)
> anno = anno_numeric(x)
> draw(anno, 1:10, test = TRUE)
> anno = anno_numeric(x, labels_gp = gpar(col = c("green", "red")))
> draw(anno, 1:10, test = TRUE)
> 
> anno = anno_numeric(x, bg_gp = gpar(col = c("green", "red")))
> draw(anno, 1:10, test = TRUE)
> 
> 
> x = runif(10, 0.5, 1.5)
> anno = anno_numeric(x, align_to = 0)
> draw(anno, 1:10, test = TRUE)
> 
> 
> 
> 
> 
> proc.time()
   user  system elapsed 
 34.011   0.625  34.708 

ComplexHeatmap.Rcheck/tests/test-ColorMapping-class.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
  4.588   0.269   4.835 

ComplexHeatmap.Rcheck/tests/test-dendrogram.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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.16.0
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
You may ask questions at stackoverflow, use the r and dendextend tags: 
	 https://stackoverflow.com/questions/tagged/dendextend

	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 
 13.817   0.520  14.342 

ComplexHeatmap.Rcheck/tests/test-gridtext.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
  8.081   0.373   8.437 

ComplexHeatmap.Rcheck/tests/test-Heatmap-class.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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.16.0
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
You may ask questions at stackoverflow, use the r and dendextend tags: 
	 https://stackoverflow.com/questions/tagged/dendextend

	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 
 43.678   0.610  44.382 

ComplexHeatmap.Rcheck/tests/test-Heatmap-cluster.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
  4.776   0.275   5.032 

ComplexHeatmap.Rcheck/tests/test-HeatmapAnnotation.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 subsettable
  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 subsettable
  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 subsettable
  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)
> 
> 
> ### test whether arguments can be captured
> HeatmapAnnotation(a = 1:10)
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_38 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm
> rowAnnotation(a = 1:10)
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_39 
  position: row 
  items: 10 
  width: 5mm 
  height: 1npc 
  this object is subsettable
  3.35373333333333mm extension on the bottom 

 name   annotation_type color_mapping width
    a continuous vector        random   5mm
> columnAnnotation(a = 1:10)
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_40 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm
> do.call(HeatmapAnnotation, list(a = 1:10))
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_41 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm
> do.call(rowAnnotation, list(a = 1:10))
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_42 
  position: row 
  items: 10 
  width: 5mm 
  height: 1npc 
  this object is subsettable
  3.35373333333333mm extension on the bottom 

 name   annotation_type color_mapping width
    a continuous vector        random   5mm
> do.call(columnAnnotation, list(a = 1:10))
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_43 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm
> do.call("HeatmapAnnotation", list(a = 1:10))
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_44 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm
> do.call("rowAnnotation", list(a = 1:10))
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_45 
  position: row 
  items: 10 
  width: 5mm 
  height: 1npc 
  this object is subsettable
  3.35373333333333mm extension on the bottom 

 name   annotation_type color_mapping width
    a continuous vector        random   5mm
> do.call("columnAnnotation", list(a = 1:10))
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_46 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm
> 
> f = function() HeatmapAnnotation(a = 1:10)
> f()
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_47 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm
> f = function() rowAnnotation(a = 1:10)
> f()
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_48 
  position: row 
  items: 10 
  width: 5mm 
  height: 1npc 
  this object is subsettable
  3.35373333333333mm extension on the bottom 

 name   annotation_type color_mapping width
    a continuous vector        random   5mm
> f = function() columnAnnotation(a = 1:10)
> f()
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_49 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm
> 
> sapply(1, function(x) HeatmapAnnotation(a = 1:10))
[[1]]
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_50 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm

> sapply(1, function(x) rowAnnotation(a = 1:10))
[[1]]
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_51 
  position: row 
  items: 10 
  width: 5mm 
  height: 1npc 
  this object is subsettable
  3.35373333333333mm extension on the bottom 

 name   annotation_type color_mapping width
    a continuous vector        random   5mm

> sapply(1, function(x) columnAnnotation(a = 1:10))
[[1]]
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_52 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm

> 
> mapply(function(x, y) HeatmapAnnotation(a = 1:10), list(1), list(1))
[[1]]
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_53 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm

> mapply(function(x, y) rowAnnotation(a = 1:10), list(1), list(1))
[[1]]
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_54 
  position: row 
  items: 10 
  width: 5mm 
  height: 1npc 
  this object is subsettable
  3.35373333333333mm extension on the bottom 

 name   annotation_type color_mapping width
    a continuous vector        random   5mm

> mapply(function(x, y) columnAnnotation(a = 1:10), list(1), list(1))
[[1]]
A HeatmapAnnotation object with 1 annotation
  name: heatmap_annotation_55 
  position: column 
  items: 10 
  width: 1npc 
  height: 5mm 
  this object is subsettable
  3.35373333333333mm extension on the right 

 name   annotation_type color_mapping height
    a continuous vector        random    5mm

> 
> 
> try({
+ 	HeatmapAnnotation(1:10)
+ 	HeatmapAnnotation(df = data.frame(a = 1:10), a = 1:10)
+ })
Error : The annotation should be specified as name-value pairs or via argument
`df` with a data frame.
> 
> proc.time()
   user  system elapsed 
 25.560   0.491  26.079 

ComplexHeatmap.Rcheck/tests/test-HeatmapList-class.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
 31.875   0.475  32.392 

ComplexHeatmap.Rcheck/tests/test-interactive.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.350   0.077   0.403 

ComplexHeatmap.Rcheck/tests/test-Legend.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
  7.568   0.319   7.889 

ComplexHeatmap.Rcheck/tests/test-multiple-page.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
 12.892   0.377  13.263 

ComplexHeatmap.Rcheck/tests/test-oncoPrint.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
 16.345   0.397  16.931 

ComplexHeatmap.Rcheck/tests/test-pheatmap.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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(). 
> 
> 
> set.seed(42)
> nsamples <- 10
> 
> mat <- matrix(rpois(20*nsamples, 20), ncol=nsamples)
> colnames(mat) <- paste0("sample", seq_len(ncol(mat)))
> rownames(mat) <- paste0("gene", seq_len(nrow(mat)))
> 
> annot <- data.frame(
+   labs = sample(c("A","B","C","D"), size = ncol(mat), replace = TRUE),
+   row.names = colnames(mat)
+ )
> ins <- list(mat = mat, annotation_col = annot)
> do.call(ComplexHeatmap::pheatmap, ins[1])
> do.call(ComplexHeatmap::pheatmap, ins)
> 
> proc.time()
   user  system elapsed 
 53.213   0.532  53.864 

ComplexHeatmap.Rcheck/tests/test-SingleAnnotation.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
  7.806   0.321   8.114 

ComplexHeatmap.Rcheck/tests/test-textbox.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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))
========================================

> 
> words = sapply(1:30, function(x) strrep(sample(letters, 1), sample(3:10, 1)))
> grid.newpage()
> grid.textbox(words, gp = gpar(fontsize = runif(30, min = 5, max = 30)))
> 
> sentenses = c("This is sentense 1", "This is a long long long long long long long sentense.")
> grid.newpage()
> grid.textbox(sentenses)
> grid.textbox(sentenses, word_wrap = TRUE)
> grid.textbox(sentenses, word_wrap = TRUE, add_new_line = TRUE)
> 
> 
> require(circlize)
Loading required package: circlize
========================================
circlize version 0.4.15
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))
========================================

> mat = matrix(rnorm(100*10), nrow = 100)
> 
> split = sample(letters[1:10], 100, replace = TRUE)
> text = lapply(unique(split), function(x) {
+ 	data.frame(month.name, col = rand_color(12, friendly = TRUE), fontsize = runif(12, 6, 14))
+ })
> names(text) = unique(split)
> 
> Heatmap(mat, cluster_rows = FALSE, row_split = split,
+     right_annotation = rowAnnotation(wc = anno_textbox(split, text))
+ )
> 
> proc.time()
   user  system elapsed 
  7.576   0.344   7.905 

ComplexHeatmap.Rcheck/tests/test-upset.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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

Attaching package: 'BiocGenerics'

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 
 35.775   0.591  36.413 

ComplexHeatmap.Rcheck/tests/test-utils.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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.15
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.12.1
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 either one:
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.


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 
  4.963   0.263   5.211 

ComplexHeatmap.Rcheck/tests/testthat-all.Rout


R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (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 ]
Warning messages:
1: In environment() : closing unused connection 7 (<-localhost:11483)
2: In environment() : closing unused connection 6 (<-localhost:11483)
3: In environment() : closing unused connection 5 (<-localhost:11483)
4: In for (i in seq_len(n)) { :
  closing unused connection 8 (<-localhost:11483)
> 
> proc.time()
   user  system elapsed 
 37.839   0.584  56.110 

Example timings

ComplexHeatmap.Rcheck/ComplexHeatmap-Ex.timings

nameusersystemelapsed
AdditiveUnit-class0.0000.0000.001
AdditiveUnit0.0010.0000.000
AnnotationFunction-class0.0000.0000.001
AnnotationFunction8.4900.1298.654
ColorMapping-class0.0000.0000.001
ColorMapping0.0210.0010.022
ComplexHeatmap-package000
Extract.AnnotationFunction0.0430.0010.043
Extract.Heatmap1.0510.0071.064
Extract.HeatmapAnnotation0.0840.0020.086
Extract.HeatmapList0.2710.0020.273
Extract.SingleAnnotation0.0280.0010.030
Extract.comb_mat0.0150.0010.016
Extract.gridtext000
Heatmap-class0.0000.0000.001
Heatmap0.0000.0000.001
Heatmap3D0.3150.0010.318
HeatmapAnnotation-class000
HeatmapAnnotation000
HeatmapList-class0.0000.0000.001
HeatmapList000
Legend0.1620.0030.165
Legends-class0.0150.0010.015
Legends0.0010.0000.000
SingleAnnotation-class0.0010.0010.000
SingleAnnotation0.1190.0030.129
UpSet0.9720.0050.981
add.AdditiveUnit000
add_heatmap-Heatmap-method000
add_heatmap-HeatmapAnnotation-method000
add_heatmap-HeatmapList-method0.0000.0000.001
add_heatmap-dispatch000
adjust_dend_by_x0.0240.0020.026
adjust_heatmap_list-HeatmapList-method0.0000.0010.000
alter_graphic0.3020.0010.304
anno_barplot0.0400.0010.042
anno_block1.9120.0081.923
anno_boxplot0.0580.0020.060
anno_customize1.2880.0051.295
anno_density0.7830.0160.804
anno_empty0.0190.0010.021
anno_histogram0.1510.0020.154
anno_horizon8.3100.0848.407
anno_image000
anno_joyplot0.7070.0200.739
anno_lines0.1260.0020.130
anno_link000
anno_mark0.9190.0130.933
anno_numeric0.3420.0010.344
anno_oncoprint_barplot000
anno_points0.0380.0020.039
anno_simple0.1110.0030.114
anno_summary0.6030.0020.607
anno_text0.1360.0040.140
anno_textbox1.2390.0051.246
anno_zoom0.6680.0030.672
annotation_axis_grob0.1090.0080.117
annotation_legend_size-HeatmapList-method000
attach_annotation-Heatmap-method1.1010.0041.107
bar3D0.0120.0010.012
bin_genome0.0010.0000.000
c.ColorMapping0.0030.0000.003
c.HeatmapAnnotation0.0620.0010.063
cluster_between_groups0.0490.0010.049
cluster_within_group0.0430.0010.044
color_mapping_legend-ColorMapping-method000
columnAnnotation0.0000.0000.001
column_dend-Heatmap-method0.5560.0020.560
column_dend-HeatmapList-method1.8900.0071.902
column_dend-dispatch000
column_order-Heatmap-method0.5720.0030.577
column_order-HeatmapList-method1.9580.0111.974
column_order-dispatch000
comb_degree0.0040.0010.004
comb_name0.0030.0000.003
comb_size0.0040.0010.003
compare_heatmap.22.0620.0122.077
compare_heatmap1.5800.0051.588
compare_pheatmap1.9160.0141.933
complement_size0.0010.0000.000
component_height-Heatmap-method000
component_height-HeatmapList-method000
component_height-dispatch0.0000.0000.001
component_width-Heatmap-method000
component_width-HeatmapList-method000
component_width-dispatch0.0000.0000.001
copy_all-AnnotationFunction-method000
copy_all-SingleAnnotation-method0.0010.0000.000
copy_all-dispatch000
decorate_annotation0.4840.0020.487
decorate_column_dend000
decorate_column_names000
decorate_column_title000
decorate_dend0.2780.0020.280
decorate_dimnames0.3200.0010.322
decorate_heatmap_body0.2570.0010.258
decorate_row_dend000
decorate_row_names0.0010.0000.000
decorate_row_title0.0000.0000.001
decorate_title0.2830.0010.284
default_axis_param0.0010.0010.001
default_get_type000
dend_heights0.0000.0000.001
dend_xy0.0200.0010.021
dendrogramGrob000
densityHeatmap2.2090.0162.230
dim.Heatmap0.0000.0000.001
dist20.0180.0010.019
draw-AnnotationFunction-method000
draw-Heatmap-method0.0000.0010.000
draw-HeatmapAnnotation-method0.0000.0000.001
draw-HeatmapList-method0.0010.0000.000
draw-Legends-method0.0240.0000.024
draw-SingleAnnotation-method000
draw-dispatch000
draw_annotation-Heatmap-method0.0000.0000.001
draw_annotation_legend-HeatmapList-method0.0000.0010.000
draw_dend-Heatmap-method000
draw_dimnames-Heatmap-method0.0000.0000.001
draw_heatmap_body-Heatmap-method000
draw_heatmap_legend-HeatmapList-method000
draw_heatmap_list-HeatmapList-method0.0010.0010.000
draw_title-Heatmap-method0.0000.0000.001
draw_title-HeatmapList-method000
draw_title-dispatch000
extract_comb0.0050.0000.005
frequencyHeatmap0.9980.0051.005
full_comb_code0.0030.0000.004
getXY_in_parent_vp0.0120.0010.013
get_color_mapping_list-HeatmapAnnotation-method0.0000.0010.001
get_legend_param_list-HeatmapAnnotation-method000
grid.annotation_axis0.0000.0010.000
grid.boxplot0.0140.0000.015
grid.dendrogram1.0460.0301.078
grid.draw.Legends0.0240.0010.024
grid.textbox000
gt_render1.1720.0131.189
heatmap_legend_size-HeatmapList-method000
height.AnnotationFunction0.0120.0000.012
height.Heatmap000
height.HeatmapAnnotation000
height.HeatmapList0.0000.0010.000
height.Legends0.0290.0000.030
height.SingleAnnotation000
heightAssign.AnnotationFunction000
heightAssign.HeatmapAnnotation0.0000.0000.001
heightAssign.SingleAnnotation0.0000.0010.000
heightDetails.annotation_axis000
heightDetails.legend0.0010.0000.000
heightDetails.legend_body000
heightDetails.packed_legends0.0000.0000.001
heightDetails.textbox000
ht_global_opt000
ht_opt0.0090.0010.011
ht_size000
is_abs_unit0.0010.0000.002
length.HeatmapAnnotation000
length.HeatmapList000
list_components000
list_to_matrix0.0010.0010.003
make_column_cluster-Heatmap-method0.0010.0000.000
make_comb_mat0.0070.0010.007
make_layout-Heatmap-method0.0000.0000.001
make_layout-HeatmapList-method000
make_layout-dispatch000
make_row_cluster-Heatmap-method0.0000.0000.001
map_to_colors-ColorMapping-method0.0310.0010.032
max_text_height0.0030.0000.004
max_text_width0.0030.0000.003
merge_dendrogram0.1840.0040.189
names.HeatmapAnnotation0.0290.0000.029
names.HeatmapList000
namesAssign.HeatmapAnnotation0.0290.0000.029
ncol.Heatmap0.0000.0000.001
nobs.AnnotationFunction0.0050.0000.005
nobs.HeatmapAnnotation000
nobs.SingleAnnotation000
normalize_comb_mat0.0000.0010.000
normalize_genomic_signals_to_bins0.0000.0010.002
nrow.Heatmap000
oncoPrint0.0000.0010.001
order.comb_mat000
packLegend0.1230.0030.128
pct_v_pct000
pheatmap0.0000.0000.001
pindex0.0080.0000.008
plot.Heatmap000
plot.HeatmapAnnotation000
plot.HeatmapList000
prepare-Heatmap-method000
print.comb_mat0.0000.0010.000
re_size-HeatmapAnnotation-method0.0010.0000.001
restore_matrix0.6980.0050.705
rowAnnotation000
row_anno_barplot0.0000.0000.001
row_anno_boxplot000
row_anno_density000
row_anno_histogram0.0010.0010.001
row_anno_points000
row_anno_text000
row_dend-Heatmap-method0.5620.0030.566
row_dend-HeatmapList-method1.5000.0061.514
row_dend-dispatch000
row_order-Heatmap-method0.5770.0020.581
row_order-HeatmapList-method1.4710.0061.480
row_order-dispatch000
set_component_height-Heatmap-method000
set_component_width-Heatmap-method000
set_name0.0030.0000.003
set_nameAssign0.0090.0000.010
set_size0.0040.0000.004
show-AnnotationFunction-method000
show-ColorMapping-method0.0010.0000.001
show-Heatmap-method0.0010.0000.000
show-HeatmapAnnotation-method0.0010.0000.000
show-HeatmapList-method000
show-SingleAnnotation-method0.0000.0010.000
show-dispatch0.0000.0000.001
size.AnnotationFunction0.0120.0010.012
size.HeatmapAnnotation0.0000.0000.001
size.SingleAnnotation000
sizeAssign.AnnotationFunction0.0070.0000.007
sizeAssign.HeatmapAnnotation000
sizeAssign.SingleAnnotation0.0010.0000.001
smartAlign20.4960.0040.500
str.comb_mat000
subset_gp0.0000.0010.000
subset_matrix_by_row000
subset_no000
subset_vector000
summary.Heatmap0.0010.0000.000
summary.HeatmapList0.0000.0000.001
t.comb_mat0.010.000.01
test_alter_fun0.1130.0030.117
textbox_grob0.2160.0040.220
unify_mat_list000
upset_left_annotation0.0010.0000.000
upset_right_annotation0.0010.0000.001
upset_top_annotation000
width.AnnotationFunction0.0130.0000.013
width.Heatmap000
width.HeatmapAnnotation000
width.HeatmapList0.0000.0010.000
width.Legends0.0310.0000.032
width.SingleAnnotation000
widthAssign.AnnotationFunction0.0000.0000.001
widthAssign.HeatmapAnnotation000
widthAssign.SingleAnnotation0.0000.0010.000
widthDetails.annotation_axis000
widthDetails.legend000
widthDetails.legend_body000
widthDetails.packed_legends000
widthDetails.textbox0.0000.0000.001