suppressPackageStartupMessages({
library("iheatmapr")
library("datasets")
library("reshape2")
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
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()