vignettes/8_iheatmapr.R

## ---- echo = FALSE-------------------------------------------------------
suppressPackageStartupMessages(library("iheatmapr"))
suppressPackageStartupMessages(library("datasets"))
suppressPackageStartupMessages(library("reshape2"))
suppressPackageStartupMessages(library("magrittr"))

Indometh_matrix <- acast(Indometh, Subject ~ time, value.var = "conc")
Indometh_matrix <- Indometh_matrix[as.character(1:6),]
rownames(Indometh_matrix) <- paste("Patient",rownames(Indometh_matrix))
Indometh_patient_cor <- cor(t(Indometh_matrix))

patient_max_conc <- apply(Indometh_matrix,1,max)
patient_min_conc <- apply(Indometh_matrix,1,min)
patient_groups <- c("A","A","B","A","B","A") # Arbitrary groups

## ---- fig.caption = "iheatmapr vignette example"-------------------------
iheatmap(Indometh_patient_cor, 
         cluster_cols = "hclust", 
         cluster_rows = "hclust",
         col_title = "Patients",
         row_title = "Patients",
         name = "Correlation",
         row_k = 3,
         row_annotation = data.frame("Max" = patient_max_conc,
                                     "Min" = patient_min_conc,
                                     "Groups" = patient_groups)) %>%
  add_iheatmap(Indometh_matrix,
               name = "Indometacin<br>Concentration", # html <br> tag used to split lines
               col_title = "Time",
               col_labels = TRUE) %>% 
  add_col_summary()
Alanocallaghan/EdinbrPlotly documentation built on Jan. 22, 2018, 3:33 a.m.