\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{appleacid (appleacid)} \pdfinfo{ /Title (complexheatmap-complete-reference.pdf) /Creator (Cheatography) /Author (appleacid (appleacid)) /Subject (ComplexHeatmap Complete Reference Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3775D} \definecolor{LightBackground}{HTML}{F9F6F4} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{ComplexHeatmap Complete Reference Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{appleacid (appleacid)} via \textcolor{DarkBackground}{\uline{cheatography.com/119008/cs/22342/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}appleacid (appleacid) \\ \uline{cheatography.com/appleacid} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 8th April, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{1.1 General design}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{A single heatmap is composed of the heatmap body and the heatmap components. The heatmap body can be split by rows and columns. The heatmap components are titles, dendrograms, matrix names and heatmap annotations, which are put on the four sides of the heamap body. The heatmap components are reordered or split according to the heatmap body.% Row Count 7 (+ 7) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{3 Heatmap Annotations}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{A simple usage of heatmap annotations}} \newline % Row Count 1 (+ 1) column\_ha = HeatmapAnnotation(foo1 = runif(10), bar1 = \seqsplit{anno\_barplot(runif(10)))} \newline % Row Count 3 (+ 2) row\_ha = rowAnnotation(foo2 = runif(10), bar2 = \seqsplit{anno\_barplot(runif(10)))} \newline % Row Count 5 (+ 2) Heatmap(mat, name = "mat", top\_annotation = column\_ha, right\_annotation = row\_ha) \newline % Row Count 7 (+ 2) {\bf{Color of annotations}} \newline % Row Count 8 (+ 1) library(circlize) \newline % Row Count 9 (+ 1) col\_fun = colorRamp2(c(0, 5, 10), c("blue", "white", "red")) \newline % Row Count 11 (+ 2) ha = HeatmapAnnotation(foo = 1:10, col = list(foo = col\_fun)) \newline % Row Count 13 (+ 2) ha = HeatmapAnnotation(bar = sample(letters{[}1:3{]}, 10, replace = TRUE), \newline % Row Count 15 (+ 2) col = list(bar = c("a" = "red", "b" = "green", "c" = "blue"))) \newline % Row Count 17 (+ 2) {\bf{specify more than one vectors}} \newline % Row Count 18 (+ 1) ha = HeatmapAnnotation( \newline % Row Count 19 (+ 1) foo = 1:10, \newline % Row Count 20 (+ 1) bar = sample(letters{[}1:3{]}, 10, replace = TRUE), \newline % Row Count 22 (+ 2) col = list(foo = col\_fun, \newline % Row Count 23 (+ 1) bar = c("a" = "red", "b" = "green", "c" = "blue"))) \newline % Row Count 25 (+ 2) {\bf{annotation table by df}} \newline % Row Count 26 (+ 1) anno\_df = data.frame(foo = 1:10, \newline % Row Count 27 (+ 1) bar = sample(letters{[}1:3{]}, 10, replace = TRUE)) \newline % Row Count 29 (+ 2) ha = HeatmapAnnotation(df = anno\_df, \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{3 Heatmap Annotations (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{ col = list(foo = col\_fun, \newline % Row Count 1 (+ 1) bar = c("a" = "red", "b" = "green", "c" = "blue"))) \newline % Row Count 3 (+ 2) {\bf{anno\_simple() makes heatmap-like annotations}} \newline % Row Count 4 (+ 1) ha = HeatmapAnnotation(foo = anno\_simple(1:10, pch = 1, \newline % Row Count 6 (+ 2) pt\_gp = gpar(col = "red"), pt\_size = unit(1:10, "mm"))) \newline % Row Count 8 (+ 2) 3.4 Block annotation \newline % Row Count 9 (+ 1) \seqsplit{Heatmap(matrix(rnorm(100)}, 10), name = "mat", \newline % Row Count 10 (+ 1) top\_annotation = HeatmapAnnotation(foo = anno\_block(gp = gpar(fill = 2:4))), \newline % Row Count 12 (+ 2) column\_km = 3) \newline % Row Count 13 (+ 1) ** other annotation graphics \newline % Row Count 14 (+ 1) ha = HeatmapAnnotation(foo = anno\_points(runif(10))) \#3.6 Points annotation** \newline % Row Count 16 (+ 2) ha = HeatmapAnnotation(foo = anno\_lines(runif(10))) \#3.7 Lines annotation \newline % Row Count 18 (+ 2) ha = HeatmapAnnotation(foo = anno\_barplot(1:10)) \#3.8 Barplot annotation \newline % Row Count 20 (+ 2) \#\# a barplot annotation which visualizes a proportion matrix \newline % Row Count 22 (+ 2) m = matrix(runif(4*10), nc = 4) \newline % Row Count 23 (+ 1) m = t(apply(m, 1, function(x) x/sum(x))) \newline % Row Count 24 (+ 1) ha = HeatmapAnnotation(foo = anno\_barplot(m, gp = gpar(fill = 2:5), \newline % Row Count 26 (+ 2) bar\_width = 1, height = unit(6, "cm"))) \newline % Row Count 27 (+ 1) ha = HeatmapAnnotation(foo = anno\_boxplot(m, height = unit(4, "cm"))) \#3.9 Boxplot annotation \newline % Row Count 29 (+ 2) ha = rowAnnotation(foo = anno\_histogram(m)) \# apply `m` on rows \#3.10 Histogram annotation \newline % Row Count 31 (+ 2) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{3 Heatmap Annotations (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{3.18 Multiple annotations}} \newline % Row Count 1 (+ 1) ha = HeatmapAnnotation(foo = 1:10, \newline % Row Count 2 (+ 1) bar = cbind(1:10, 10:1), \newline % Row Count 3 (+ 1) pt = anno\_points(1:10), \newline % Row Count 4 (+ 1) show\_legend = c("bar" = FALSE)) \newline % Row Count 5 (+ 1) \seqsplit{Heatmap(matrix(rnorm(100)}, 10), name = "mat", top\_annotation = ha)% Row Count 7 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{4 A List of Heatmaps}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{The main feature of ComplexHeatmap package is it supports to concatenate a list of heatmaps and annotations horizontally or vertically so that it makes it possible to visualize the associations from various sources of information. \newline % Row Count 5 (+ 5) {\bf{concatenate heatmaps}} \newline % Row Count 6 (+ 1) ht1 = Heatmap(mat1, name = "rnorm") \newline % Row Count 7 (+ 1) ht2 = Heatmap(mat2, name = "runif") \newline % Row Count 8 (+ 1) ht3 = Heatmap(le, name = "letters") \newline % Row Count 9 (+ 1) ht1 + ht2 + ht3 \newline % Row Count 10 (+ 1) {\bf{4.1 Titles}} \newline % Row Count 11 (+ 1) draw(ht\_list, row\_title = "Three heatmaps, row title", row\_title\_gp = gpar(col = "red"), \newline % Row Count 13 (+ 2) column\_title = "Three heatmaps, column title", column\_title\_gp = gpar(fontsize = 16)) \newline % Row Count 15 (+ 2) {\bf{4.3 Gap between heatmaps}} \newline % Row Count 16 (+ 1) draw(ht\_list, ht\_gap = unit(1, "cm")) \newline % Row Count 17 (+ 1) {\bf{4.8 Concatenate only the annotations}} \newline % Row Count 18 (+ 1) rowAnnotation(foo = 1:12) + \newline % Row Count 19 (+ 1) rowAnnotation(bar = anno\_barplot(1:12, width = unit(4, "cm"))) \newline % Row Count 21 (+ 2) {\bf{4.9 Vertical concatenation}} \newline % Row Count 22 (+ 1) ht\_list = ht1 \%v\% ht2 \%v\% ht3; draw(ht\_list)% Row Count 23 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{2 A Single Heatmap}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{2.1 Colors}} \newline % Row Count 1 (+ 1) \#\# continueous \newline % Row Count 2 (+ 1) library(circlize) \newline % Row Count 3 (+ 1) col\_fun = colorRamp2(c(-2, 0, 2), c("green", "white", "red"), space = "RGB") \newline % Row Count 5 (+ 2) Heatmap(mat, name = "mat", col = col\_fun) \newline % Row Count 6 (+ 1) \#\# discrete \newline % Row Count 7 (+ 1) discrete\_mat = matrix(sample(1:4, 100, replace = TRUE), 10, 10) \newline % Row Count 9 (+ 2) colors = structure(1:4, names = c("1", "2", "3", "4")) \# black, red, green, blue \newline % Row Count 11 (+ 2) Heatmap(discrete\_mat, name = "mat", col = colors) \newline % Row Count 12 (+ 1) {\bf{2.4 Set row and column orders}} \newline % Row Count 13 (+ 1) Heatmap(mat, name = "mat", row\_order = \seqsplit{order(as.numeric(gsub("row"}, "", rownames(mat)))), \newline % Row Count 15 (+ 2) column\_order = \seqsplit{order(as.numeric(gsub("column"}, "", colnames(mat))))) \newline % Row Count 17 (+ 2) {\bf{2.7 Split by categorical variables}} \newline % Row Count 18 (+ 1) \#\# split by a vector \newline % Row Count 19 (+ 1) Heatmap(mat, name = "mat", \newline % Row Count 20 (+ 1) row\_split = rep(c("A", "B"), 9), column\_split = rep(c("C", "D"), 12)) \newline % Row Count 22 (+ 2) \#\# split by a data frame \newline % Row Count 23 (+ 1) Heatmap(mat, name = "mat", \newline % Row Count 24 (+ 1) row\_split = data.frame(rep(c("A", "B"), 9), rep(c("C", "D"), each = 9))) \newline % Row Count 26 (+ 2) \#\# Order of slices \newline % Row Count 27 (+ 1) Heatmap(mat, name = "mat", \newline % Row Count 28 (+ 1) row\_split = factor(rep(LETTERS{[}1:3{]}, 6), levels = LETTERS{[}3:1{]}), \newline % Row Count 30 (+ 2) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{2 A Single Heatmap (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{ column\_split = factor(rep(letters{[}1:6{]}, 4), levels = letters{[}6:1{]}), \newline % Row Count 2 (+ 2) cluster\_row\_slices = FALSE, \newline % Row Count 3 (+ 1) cluster\_column\_slices = FALSE) \newline % Row Count 4 (+ 1) {\bf{2.12 Get orders and dendrograms}} \newline % Row Count 5 (+ 1) small\_mat = mat{[}1:9, 1:9{]}; ht1 = Heatmap(small\_mat); row\_order(ht1) \newline % Row Count 7 (+ 2) {\bf{2.13 Subset a heatmap}} \newline % Row Count 8 (+ 1) ht = Heatmap(mat, name = "mat") \newline % Row Count 9 (+ 1) dim(ht); ht{[}1:10, 1:10{]}% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{7 OncoPrint}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\#\# If the separators are in ;:,|, oncoPrint() automatically spit the alteration strings\#\# \newline % Row Count 2 (+ 2) get\_type\_fun = function(x) strsplit(x, ";"){[}{[}1{]}{]} \newline % Row Count 3 (+ 1) {\bf{ layer by layer style by specifying alter\_fun as a list}} \newline % Row Count 5 (+ 2) col = c(snv = "red", indel = "blue") \newline % Row Count 6 (+ 1) oncoPrint(mat, \newline % Row Count 7 (+ 1) alter\_fun = list( \newline % Row Count 8 (+ 1) snv = function(x, y, w, h) grid.rect(x, y, w{\emph{0.9, h}}0.9, \newline % Row Count 10 (+ 2) gp = gpar(fill = col{[}"snv"{]}, col = NA)), \newline % Row Count 12 (+ 2) indel = function(x, y, w, h) grid.rect(x, y, w{\emph{0.9, h}}0.4, \newline % Row Count 14 (+ 2) gp = gpar(fill = col{[}"indel"{]}, col = NA))), col = col) \newline % Row Count 16 (+ 2) {\bf{7.1.2 grid-by-grid style by specifying alter\_fun as a single function}} \newline % Row Count 18 (+ 2) oncoPrint(mat, \newline % Row Count 19 (+ 1) alter\_fun = function(x, y, w, h, v) \{ \newline % Row Count 20 (+ 1) if(v{[}"snv"{]}) grid.rect(x, y, w{\emph{0.9, h}}0.9, \# v{[}"snv"{]} is a logical value \newline % Row Count 22 (+ 2) gp = gpar(fill = col{[}"snv"{]}, col = NA)) \newline % Row Count 24 (+ 2) if(v{[}"indel"{]}) grid.rect(x, y, w{\emph{0.9, h}}0.4, \# v{[}"indel"{]} is a logical value \newline % Row Count 26 (+ 2) gp = gpar(fill = col{[}"indel"{]}, col = NA)) \}, col = col) \newline % Row Count 28 (+ 2) {\bf{7.1.3 Background}} \newline % Row Count 29 (+ 1) If alter\_fun is specified as a list, the order of the elements controls the order of adding graphics. There is a special element called background which defines how to draw background and it should be always put as the first element in the alter\_fun list. \newline % Row Count 35 (+ 6) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{7 OncoPrint (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{7.2 Apply to cBioPortal dataset}} \newline % Row Count 1 (+ 1) col = c("HOMDEL" = "blue", "AMP" = "red", "MUT" = "\#008000") \newline % Row Count 3 (+ 2) alter\_fun = list( \newline % Row Count 4 (+ 1) background = function(x, y, w, h) \{ \newline % Row Count 5 (+ 1) grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), \newline % Row Count 7 (+ 2) gp = gpar(fill = "\#CCCCCC", col = NA)) \}, \newline % Row Count 9 (+ 2) HOMDEL = function(x, y, w, h) \{ \newline % Row Count 10 (+ 1) grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), \newline % Row Count 12 (+ 2) gp = gpar(fill = col{[}"HOMDEL"{]}, col = NA)) \}, \newline % Row Count 14 (+ 2) AMP = function(x, y, w, h) \{ \newline % Row Count 15 (+ 1) grid.rect(x, y, w-unit(0.5, "mm"), h-unit(0.5, "mm"), \newline % Row Count 17 (+ 2) gp = gpar(fill = col{[}"AMP"{]}, col = NA))\}, \newline % Row Count 19 (+ 2) MUT = function(x, y, w, h) \{ \newline % Row Count 20 (+ 1) grid.rect(x, y, w-unit(0.5, "mm"), h*0.33, \newline % Row Count 22 (+ 2) gp = gpar(fill = col{[}"MUT"{]}, col = NA)) \}) \newline % Row Count 24 (+ 2) {\bf{7.2.1 Remove empty rows and columns}} \newline % Row Count 25 (+ 1) oncoPrint(mat, \newline % Row Count 26 (+ 1) alter\_fun = alter\_fun, col = col, \newline % Row Count 27 (+ 1) remove\_empty\_columns = TRUE, remove\_empty\_rows = TRUE, \newline % Row Count 29 (+ 2) column\_title = column\_title, heatmap\_legend\_param = heatmap\_legend\_param) \newline % Row Count 31 (+ 2) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{7 OncoPrint (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{7.2.2 Reorder the oncoPrint}} \newline % Row Count 1 (+ 1) sample\_order = \seqsplit{scan(paste0(system.file("extdata"}, package = "ComplexHeatmap"), \newline % Row Count 3 (+ 2) "/sample\_order.txt"), what = "character") \newline % Row Count 4 (+ 1) oncoPrint(mat, \newline % Row Count 5 (+ 1) alter\_fun = alter\_fun, col = col, \newline % Row Count 6 (+ 1) row\_order = 1:nrow(mat), column\_order = sample\_order, \newline % Row Count 8 (+ 2) remove\_empty\_columns = TRUE, remove\_empty\_rows = TRUE, \newline % Row Count 10 (+ 2) column\_title = column\_title, heatmap\_legend\_param = heatmap\_legend\_param) \newline % Row Count 12 (+ 2) {\bf{7.2.3 OncoPrint annotations}} \newline % Row Count 13 (+ 1) oncoPrint(mat, \newline % Row Count 14 (+ 1) alter\_fun = alter\_fun, col = col, \newline % Row Count 15 (+ 1) top\_annotation = HeatmapAnnotation( \newline % Row Count 16 (+ 1) column\_barplot = \seqsplit{anno\_oncoprint\_barplot("MUT"}, border = TRUE, \# only MUT \newline % Row Count 18 (+ 2) height = unit(4, "cm"))), \newline % Row Count 19 (+ 1) right\_annotation = rowAnnotation( \newline % Row Count 20 (+ 1) row\_barplot = \seqsplit{anno\_oncoprint\_barplot(c("AMP"}, "HOMDEL"), \# only AMP and HOMDEL \newline % Row Count 22 (+ 2) border = TRUE, height = unit(4, "cm"), \newline % Row Count 24 (+ 2) axis\_param = list(side = "bottom", labels\_rot = 90))), \newline % Row Count 26 (+ 2) remove\_empty\_columns = TRUE, remove\_empty\_rows = TRUE, \newline % Row Count 28 (+ 2) column\_title = column\_title, heatmap\_legend\_param = heatmap\_legend\_param) \newline % Row Count 30 (+ 2) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{7 OncoPrint (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{add more annotations in HeatmapAnnotation() or rowAnnotation()}} \newline % Row Count 2 (+ 2) oncoPrint(mat, \newline % Row Count 3 (+ 1) alter\_fun = alter\_fun, col = col, \newline % Row Count 4 (+ 1) remove\_empty\_columns = TRUE, remove\_empty\_rows = TRUE, \newline % Row Count 6 (+ 2) top\_annotation = HeatmapAnnotation(cbar = \seqsplit{anno\_oncoprint\_barplot()}, \newline % Row Count 8 (+ 2) foo1 = 1:172, \newline % Row Count 9 (+ 1) bar1 = anno\_points(1:172)), \newline % Row Count 10 (+ 1) left\_annotation = rowAnnotation(foo2 = 1:26), \newline % Row Count 11 (+ 1) right\_annotation = rowAnnotation(bar2 = anno\_barplot(1:26)), \newline % Row Count 13 (+ 2) column\_title = column\_title, heatmap\_legend\_param = heatmap\_legend\_param) \newline % Row Count 15 (+ 2) {\bf{split the heatmap list}} \newline % Row Count 16 (+ 1) ht\_list = oncoPrint(mat, \newline % Row Count 17 (+ 1) alter\_fun = alter\_fun, col = col, \newline % Row Count 18 (+ 1) column\_title = column\_title, heatmap\_legend\_param = heatmap\_legend\_param) + \newline % Row Count 20 (+ 2) \seqsplit{Heatmap(matrix(rnorm(nrow(mat)*10)}, ncol = 10), name = "expr", width = unit(4, "cm")) \newline % Row Count 22 (+ 2) draw(ht\_list, row\_split = sample(c("a", "b"), nrow(mat), replace = TRUE)) \newline % Row Count 24 (+ 2) {\bf{Get the subset of rows and columns}} \newline % Row Count 25 (+ 1) rownames(ht@matrix); colnames(ht@matrix)% Row Count 26 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{5 Legends}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{5.1 Continuous legends}} \newline % Row Count 1 (+ 1) library(circlize) \newline % Row Count 2 (+ 1) col\_fun = colorRamp2(c(0, 0.5, 1), c("blue", "white", "red")) \newline % Row Count 4 (+ 2) lgd = Legend(col\_fun = col\_fun, title = "foo") \newline % Row Count 5 (+ 1) {\bf{5.2 Discrete legends}} \newline % Row Count 6 (+ 1) lgd = Legend(labels = month.name{[}1:6{]}, title = "foo", legend\_gp = gpar(fill = 1:6)) \newline % Row Count 8 (+ 2) {\bf{5.4 Heatmap legends}} \newline % Row Count 9 (+ 1) m = matrix(rnorm(100), 10) \newline % Row Count 10 (+ 1) Heatmap(m, name = "mat", heatmap\_legend\_param = list( \newline % Row Count 12 (+ 2) at = c(-2, 0, 2),labels = c("low", "zero", "high"), \newline % Row Count 14 (+ 2) title = "Some values",legend\_height = unit(4, "cm"), \newline % Row Count 16 (+ 2) title\_position = "lefttop-rot" \newline % Row Count 17 (+ 1) )) \newline % Row Count 18 (+ 1) {\bf{5.4 annotation legends}} \newline % Row Count 19 (+ 1) ha = HeatmapAnnotation(foo = runif(10), bar = sample(c("f", "m"), 10, replace = TRUE), \newline % Row Count 21 (+ 2) \seqsplit{annotation\_legend\_param} = list( \newline % Row Count 22 (+ 1) foo = list(title = "Fooooooh",at = c(0, 0.5, 1), labels = c("zero", "median", "one") ), \newline % Row Count 24 (+ 2) bar = list( title = "Baaaaaaar",at = c("f", "m"),labels = c("Female", "Male")))) \newline % Row Count 26 (+ 2) Heatmap(m, name = "mat", top\_annotation = ha) \newline % Row Count 27 (+ 1) {\bf{5.6 The side of legends}} \newline % Row Count 28 (+ 1) draw(ht\_list, heatmap\_legend\_side = "left", annotation\_legend\_side = "bottom")% Row Count 30 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}