## ---- echo = FALSE--------------------------------------------------------------------------------
library(knitr)
knitr::opts_chunk$set(
    error = FALSE,
    tidy  = FALSE,
    message = FALSE,
    warning = FALSE,
    fig.align = "center",
    dev = "jpeg"
)
options(width = 100)

## ---- fig.width = 7, fig.height = 4---------------------------------------------------------------
library(tm)
data(crude)
term = lapply(content(crude), as.character)[1:10]
mat = matrix(rnorm(100*10), nrow = 100)

split = sample(letters[1:10], 100, replace = TRUE)

names(term) = letters[1:10]  ## names of `term` must be the same as `unique(split)`
str(term, nchar.max = 80)

library(ComplexHeatmap)
library(simplifyEnrichment)

Heatmap(mat, row_split = split, 
	right_annotation = rowAnnotation(wc = anno_word_cloud(split, term))
)

## ---- eval = FALSE--------------------------------------------------------------------------------
#  align_to = split(seq_along(split), split)
#  Heatmap(mat, row_split = split,
#  	right_annotation = rowAnnotation(wc = anno_word_cloud(align_to, term))
#  )

## ---- fig.width = 7, fig.height = 4---------------------------------------------------------------
Heatmap(mat, row_split = split, row_dend_side = "right", row_title_side = "right",
	left_annotation = rowAnnotation(wc = anno_word_cloud(split, term, side = "left"))
)

## -------------------------------------------------------------------------------------------------
load(system.file("extdata", "golub_sig_go.RData", package = "simplifyEnrichment"))
head(km)
str(go_list)

## ---- echo = FALSE--------------------------------------------------------------------------------
ht_opt$message = FALSE

## ---- fig.width = 7, fig.height = 4---------------------------------------------------------------
library(circlize)
Heatmap(t(scale(t(sig_mat))), name = "z-score",
	col = colorRamp2(c(-2, 0, 2), c("green", "white", "red")),
	show_row_names = FALSE, show_column_names = FALSE, 
	row_title = NULL, column_title = NULL,
	show_row_dend = FALSE, show_column_dend = FALSE,
	row_split = km) +
rowAnnotation(go = anno_word_cloud_from_GO(km, go_list, max_words = 30))

## ---- fig.width = 7, fig.height = 4---------------------------------------------------------------
library(circlize)
Heatmap(t(scale(t(sig_mat))), name = "z-score",
	col = colorRamp2(c(-2, 0, 2), c("green", "white", "red")),
	show_row_names = FALSE, show_column_names = FALSE, 
	row_title = NULL, column_title = NULL,
	show_row_dend = FALSE, show_column_dend = FALSE,
	row_split = km) +
rowAnnotation(go = anno_word_cloud_from_GO(km, go_list, max_words = 20,
	exclude_words = c("regulation", "process", "response", "positive", "cell")))

