An example of a default Clustergram component without any extra properties.
library(dash)
library(dashCoreComponents)
library(dashHtmlComponents)
library(dashBio)
library(heatmaply)
library(data.table)
app <- Dash$new()
df = read.table("https://git.io/clustergram_mtcars.tsv",
skip = 4, sep ="\t", row.names = 1, header = TRUE)
# The following lines generate the options list for the dropdown we will be using.
all_options <- rownames(df)
options_list <- list()
for (x in 1:length(all_options)){
option = list("label" = all_options[x], "value" = all_options[x])
options_list[[x]] = option
}
app$layout(htmlDiv(list(
"Rows to display: ",
dccDropdown(
id = 'my-default-clustergram-rows-to-display',
options = options_list,
value = c("Mazda RX4", "Valiant"),
multi = TRUE
),
htmlDiv(id = "my-default-clustergram-output")
)))
app$callback(
output(id = "my-default-clustergram-output", property = "children"),
params = list(
input(id = 'my-default-clustergram-rows-to-display', property = "value")
),
update_clustergram <- function(value) {
if (length(value) < 2) {
return("Please select at least two rows to display.")
}
else {
df <- subset(df, rownames(df) %in% value)
return(
dccGraph(figure = heatmaply(df,
row_labels = list(row.names(data)),
hide_labels = list("row"),
column_labels = as.list(colnames(data)),
color_threshold = list(
"row" = 150,
"col" = 700
)
))
)
}
}
)
app$run_server()
Change the color scale by specifying values and colors.
library(dash)
library(dashCoreComponents)
library(dashHtmlComponents)
library(dashBio)
library(heatmaply)
library(data.table)
df = read.table("https://git.io/clustergram_mtcars.tsv",
skip = 4, sep =" ", row.names = 1, header = TRUE)
dccGraph(figure = heatmaply(
df,
row_labels = list(row.names(data)),
hide_labels = list("row"),
column_labels = as.list(colnames(data)),
color_threshold = list(
"row" = 150,
"col" = 700
),
colors = BrBG,
limits = c(0, 500),
midpoint = 200
))
Change the colors of the dendrogram traces that are used to represent clusters, and configure their line widths.
library(dash)
library(dashCoreComponents)
library(dashHtmlComponents)
library(dashBio)
library(heatmaply)
library(data.table)
df = read.table("https://git.io/clustergram_mtcars.tsv",
skip = 4, sep =" ", row.names = 1, header = TRUE)
# The following is a color palette.
rc <- colorspace::rainbow_hcl(nrow(df))
dccGraph(figure = heatmaply(
df,
row_labels = list(row.names(data)),
hide_labels = list("row"),
column_labels = as.list(colnames(data)),
color_threshold = list(
"row" = 250,
"col" = 700
),
seriate = "mean",
RowSideColors = rc,
k_col = 2,
k_row = 2
))
Change the relative width and height of, respectively, the row and column dendrograms compared to the width and height of the heatmap.
library(dash)
library(dashCoreComponents)
library(dashHtmlComponents)
library(dashBio)
library(heatmaply)
library(data.table)
df = read.table("https://git.io/clustergram_mtcars.tsv",
skip = 4, sep =" ", row.names = 1, header = TRUE)
dccGraph(figure = heatmaply(
df,
row_labels = list(row.names(data)),
hide_labels = list("row"),
column_labels = as.list(colnames(data)),
color_threshold = list(
"row" = 250,
"col" = 700
),
height = 800,
width = 700,
display_ratio=list(0.1, 0.7)
))
Hide the labels along one or both dimensions.
library(dash)
library(dashCoreComponents)
library(dashHtmlComponents)
library(dashBio)
library(heatmaply)
library(data.table)
df = read.table("https://git.io/clustergram_mtcars.tsv",
skip = 4, sep =" ", row.names = 1, header = TRUE)
dccGraph(figure = heatmaply(
df,
row_labels = list(row.names(data)),
hide_labels = list("row"),
column_labels = as.list(colnames(data)),
color_threshold = list(
"row" = 250,
"col" = 700
),
showticklabels = c(T,F)
))
Annotate the clustergram by highlighting specific clusters.
library(dash)
library(dashCoreComponents)
library(dashHtmlComponents)
library(dashBio)
library(heatmaply)
library(data.table)
df = read.table("https://git.io/clustergram_mtcars.tsv",
skip = 4, sep =" ", row.names = 1, header = TRUE)
dccGraph(figure = heatmaply(
df[, -c(8,9)],
row_labels = list(row.names(data)),
hide_labels = list("row"),
column_labels = as.list(colnames(data)),
color_threshold = list(
"row" = 250,
"col" = 700
),
seriate = "mean",
col_side_colors = c(rep(0,5), rep(1,4)),
row_side_colors = df[,8:9],
))
dash_bio.Clustergram
is a Python-based component,
and may not be available in other languages.