dash_bioClustergram Examples and Reference

see Clustergram in action.

Clustergram

An example of a default Clustergram component without any extra properties.

Rows to display
1005_at 
1039_s_at 
103_at 
1052_s_at 
1058_at 
1063_s_at 
1072_g_at 
1091_at 
1101_at 
1104_s_at 
×
Brain_CG_10Brain_CG_13Brain_CG_14Brain_CG_2Brain_CG_3Brain_CG_9Brain_NG_13Brain_CG_11Brain_NG_8Brain_CG_8Brain_CG_7Brain_CG_12Brain_NG_4Brain_NG_7Brain_NG_10Brain_CG_4Brain_NG_5Brain_CG_6Brain_NG_3Brain_NG_9Brain_NG_12Brain_NG_6Brain_CG_1Brain_NG_2Brain_NG_1Brain_NG_14Brain_CG_5Brain_NG_11
020040060080010001200
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()

Customization

Heatmap Color Scale

Change the color scale by specifying values and colors.

Brain_CG_10Brain_CG_13Brain_CG_2Brain_CG_14Brain_CG_3Brain_NG_13Brain_CG_11Brain_CG_9Brain_CG_8Brain_CG_5Brain_NG_11Brain_NG_12Brain_CG_1Brain_NG_6Brain_NG_14Brain_NG_1Brain_NG_2Brain_CG_4Brain_NG_3Brain_NG_9Brain_CG_6Brain_NG_10Brain_NG_5Brain_NG_8Brain_NG_4Brain_NG_7Brain_CG_12Brain_CG_71091_at1063_s_at1336_s_at1039_s_at1242_at1058_at1101_at1217_g_at1251_g_at103_at1126_s_at1237_at1321_s_at120_at1230_g_at1262_s_at1319_at1198_at1327_s_at1333_f_at113_i_at1269_at1072_g_at1277_at1153_f_at1124_at1136_at1005_at1052_s_at1104_s_at
020040060080010001200
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
))

Dendrogram Cluster Colors/Line Widths

Change the colors of the dendrogram traces that are used to represent clusters, and configure their line widths.

Brain_CG_10Brain_CG_13Brain_CG_2Brain_CG_14Brain_CG_3Brain_NG_13Brain_CG_11Brain_CG_9Brain_CG_8Brain_CG_5Brain_NG_11Brain_NG_12Brain_CG_1Brain_NG_6Brain_NG_14Brain_NG_1Brain_NG_2Brain_CG_4Brain_NG_3Brain_NG_9Brain_CG_6Brain_NG_10Brain_NG_5Brain_NG_8Brain_NG_4Brain_NG_7Brain_CG_12Brain_CG_71091_at1063_s_at1336_s_at1039_s_at1242_at1058_at1101_at1217_g_at1251_g_at103_at1126_s_at1237_at1321_s_at120_at1230_g_at1262_s_at1319_at1198_at1327_s_at1333_f_at113_i_at1269_at1072_g_at1277_at1153_f_at1124_at1136_at1005_at1052_s_at1104_s_at
020040060080010001200
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
))

Relative Dendrogram Size

Change the relative width and height of, respectively, the row and column dendrograms compared to the width and height of the heatmap.

Brain_CG_10Brain_CG_13Brain_CG_2Brain_CG_14Brain_CG_3Brain_NG_13Brain_CG_11Brain_CG_9Brain_CG_8Brain_CG_5Brain_NG_11Brain_NG_12Brain_CG_1Brain_NG_6Brain_NG_14Brain_NG_1Brain_NG_2Brain_CG_4Brain_NG_3Brain_NG_9Brain_CG_6Brain_NG_10Brain_NG_5Brain_NG_8Brain_NG_4Brain_NG_7Brain_CG_12Brain_CG_71091_at1063_s_at1336_s_at1039_s_at1242_at1058_at1101_at1217_g_at1251_g_at103_at1126_s_at1237_at1321_s_at120_at1230_g_at1262_s_at1319_at1198_at1327_s_at1333_f_at113_i_at1269_at1072_g_at1277_at1153_f_at1124_at1136_at1005_at1052_s_at1104_s_at
020040060080010001200
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)
))

Hidden Labels

Hide the labels along one or both dimensions.

Brain_CG_10Brain_CG_13Brain_CG_2Brain_CG_14Brain_CG_3Brain_NG_13Brain_CG_11Brain_CG_9Brain_CG_8Brain_CG_5Brain_NG_11Brain_NG_12Brain_CG_1Brain_NG_6Brain_NG_14Brain_NG_1Brain_NG_2Brain_CG_4Brain_NG_3Brain_NG_9Brain_CG_6Brain_NG_10Brain_NG_5Brain_NG_8Brain_NG_4Brain_NG_7Brain_CG_12Brain_CG_7
020040060080010001200
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)
))

Annotations

Annotate the clustergram by highlighting specific clusters.

Brain_CG_10Brain_CG_13Brain_CG_2Brain_CG_14Brain_CG_3Brain_NG_13Brain_CG_11Brain_CG_9Brain_CG_8Brain_CG_5Brain_NG_11Brain_NG_12Brain_CG_1Brain_NG_6Brain_NG_14Brain_NG_1Brain_NG_2Brain_CG_4Brain_NG_3Brain_NG_9Brain_CG_6Brain_NG_10Brain_NG_5Brain_NG_8Brain_NG_4Brain_NG_7Brain_CG_12Brain_CG_7
020040060080010001200cluster 2largest column cluster
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.

Example Data