
Dendrogram with amalgamated heatmap (Comparisons' comparability for transitivity evaluation)
Source:R/dendro.heatmap_function.R
dendro_heatmap.Rd
dendro_heatmap
creates a dendrogram alongside the heatmap of
Gower dissimilarities among the trials in the network for a specific
linkage method and number of clusters.
Arguments
- input
An object of S3 class
comp_clustering
. See 'Value' incomp_clustering
.- label_size
A positive integer for the font size of the heatmap elements.
label_size
determines the size argument found in the geom's aesthetic properties in the R-package ggplot2.- axis_text_size
A positive integer for the font size of row and column names of the heatmap.
axis_text_size
determines the axis.text argument found in the theme's properties in the R-package ggplot2.
Value
dendro_heatmap
uses the heatmaply
function of the R-package
heatmaply to create a
cluster heatmap for a selected linkage method and number of clusters. The
function uses different colours to indicate the clusters directly on the
dendrogram, specified using the R-package
dendextend. The names
of the leaves refer to the trials and corresponding pairwise comparison.
@details
The function inherits the linkage method and number of optimal clusters by
the comp_clustering
function.
Remember: when using the comp_clustering
function, inspect
the average silhouette width for a wide range of clusters to decide on the
optimal number of clusters.
Examples
# \donttest{
# Fictional dataset
data_set <- data.frame(Trial_name = as.character(1:7),
arm1 = c("1", "1", "1", "1", "1", "2", "2"),
arm2 = c("2", "2", "2", "3", "3", "3", "3"),
sample = c(140, 145, 150, 40, 45, 75, 80),
age = c(18, 18, 18, 48, 48, 35, 35),
blinding = factor(c("yes", "yes", "yes", "no", "no", "no", "no")))
# Apply hierarchical clustering (informative = FALSE)
hier <- comp_clustering(input = data_set,
drug_names = c("A", "B", "C"),
threshold = 0.13, # General research setting
informative = FALSE,
optimal_clusters = 3,
get_plots = TRUE)
#> - 3 observed comparisons (0 single-study comparisons)
#> - Dropped characteristics: none
#> - Cophenetic coefficient: 0.968
#> - Optimal linkage method: single
#> $Trials_diss_table
#> 1 B-A 2 B-A 3 B-A 4 C-A 5 C-A 6 C-B 7 C-B
#> 1 B-A 0.000 NA NA NA NA NA NA
#> 2 B-A 0.015 0.000 NA NA NA NA NA
#> 3 B-A 0.030 0.015 0.000 NA NA NA NA
#> 4 C-A 0.970 0.985 1.000 0.000 NA NA NA
#> 5 C-A 0.955 0.970 0.985 0.015 0.000 NA NA
#> 6 C-B 0.719 0.734 0.749 0.251 0.235 0.000 NA
#> 7 C-B 0.704 0.719 0.734 0.266 0.251 0.015 0
#>
#> $Comparisons_diss_table
#> B-A C-A C-B
#> B-A 0.02 NA NA
#> C-A 0.98 0.02 NA
#> C-B 0.73 0.25 0.02
#>
#> $Total_dissimilarity
#> comparison total_dissimilarity index_type
#> 5 C-A vs C-B 0.25 Between-comparison
#> 3 B-A vs C-B 0.73 Between-comparison
#> 2 B-A vs C-A 0.98 Between-comparison
#> 1 B-A 0.02 Within-comparison
#> 4 C-A 0.02 Within-comparison
#> 6 C-B 0.02 Within-comparison
#>
#> $Types_used
#> characteristic type
#> 1 sample double
#> 2 age double
#> 3 blinding integer
#>
#> $Total_missing
#> [1] "0%"
#>
#> $Table_average_silhouette_width
#> clusters silhouette
#> 1 2 0.872
#> 2 3 0.953
#> 3 4 0.684
#> 4 5 0.417
#> 5 6 0.071
#>
#> $Table_cophenetic_coefficient
#> linkage_methods results
#> 3 single 0.968
#> 4 complete 0.968
#> 5 average 0.968
#> 6 mcquitty 0.968
#> 7 median 0.968
#> 8 centroid 0.968
#> 2 ward.D2 0.967
#> 1 ward.D 0.965
#>
#> $Optimal_link
#> [1] "single"
#>
#> $Cluster_comp
#> study cluster sil_width
#> 1 1 1 0.9680625
#> 2 2 1 0.9791522
#> 3 3 1 0.9693669
#> 4 4 2 0.9412916
#> 5 5 2 0.9376299
#> 6 6 3 0.9376299
#> 7 7 3 0.9412916
#>
#> $Within_comparison_dissimilarity
#>
#> $Between_comparison_dissimilarity
#>
#> $Profile_plot
#>
#> $Silhouette_width_plot
#>
#> $Barplot_comparisons_cluster
#>
#> attr(,"class")
#> [1] "comp_clustering"
# Create the dendrogram with integrated heatmap
dendro_heatmap(hier)
# }