Title: | Colorful Hierarchical Clustering Dendrograms |
---|---|
Description: | Build dendrograms with sample groups highlighted by different colors. Visualize results of hierarchical clustering analyses as dendrograms whose leaves and labels are colored according to sample grouping. Assess whether data point grouping aligns to naturally occurring clusters. |
Authors: | Damiano Fantini |
Maintainer: | Damiano Fantini <[email protected]> |
License: | GPL-2 |
Version: | 1.3.1 |
Built: | 2024-11-18 05:09:14 UTC |
Source: | https://github.com/cran/colorhcplot |
This is a simple one-function package. Please, refer to the colorhcplot() function manual to check how the function works.
This package contains the function colorhcplot. This function generates simple colorful dendrograms and requires only 2 mandatory arguments: hc and fac. The argument hc is the result of a hclust() call, while fac is a factor defining the groups. Therefore, the number of leaves of the dendrogram has to be identical to the length of fac (i.e., length(hc$labels) == length(fac) has to be TRUE). The function colorhcplot() employs a custom color palette. However, users can specify a custom list of colors.
Damiano Fantini
Maintainer: Damiano Fantini <[email protected]>
This function takes a "hclust-class" object and a factor describing the groups as arguments and generates colorful dendrograms in which leaves belonging to different groups are identified by colors. This function produces a plot that allows to easily detect if leaves that clustered together also belong to the same group.
colorhcplot(hc, fac, hang = 0.1, main = "Cluster Dendrogram", colors = NULL, lab.cex = 1, ylim = NULL, lwd = 3, las = 1, lab.mar = 0.55)
colorhcplot(hc, fac, hang = 0.1, main = "Cluster Dendrogram", colors = NULL, lab.cex = 1, ylim = NULL, lwd = 3, las = 1, lab.mar = 0.55)
hc |
hclust-class object, typically the result of a 'hclust()' function call. |
fac |
factor that defines the grouping. |
hang |
hang value, as in |
main |
title of the dendrogram plot. |
colors |
NULL or a character vector of length 1 or having the same length as the number of levels in fac. This argument defines the palette for the plot. |
lab.cex |
numeric value for adjusting the font size of the leaf labels (and legend text). |
ylim |
numeric, defines the minimum and maximum value of the y-axis of the plot. |
lwd |
numeric value that defines the width (in points) of the lines of the dendogram. |
las |
graphic parameter for the orientation of the y-axis tick labels. |
lab.mar |
fraction of the plot area that is reserved for the labels (at the bottom of the plot). |
In order to generate a colorful dendrogram, the colorhcplot() function requires 2 mandatory arguments: hc and fac. hc is the result of a hclust() call, while fac is a factor defining the groups. The number of leaves of the dendrogram has to be identical to the length of fac.
Calling colorhcplot() returns a colorful dendrogram plot
Online colorhcplot() function reference at: http://www.biotechworld.it/bioinf/2015/09/30/colorful-hierarchical-clustering-dendrograms-with-r
Damiano Fantini <[email protected]>
### Example 1, using the USArrests dataset data(USArrests) hc <- hclust(dist(USArrests), "ave") fac <- as.factor(c(rep("group 1", 10), rep("group 2", 10), rep("unknown", 30))) plot(hc) colorhcplot(hc, fac) colorhcplot(hc, fac, hang = -1, lab.cex = 0.8) ### Example 2: use the "ward.D2" algorithm and ### the UScitiesD dataset data(UScitiesD) hcity.D2 <- hclust(UScitiesD, "ward.D2") fac.D2 <-as.factor(c(rep("group1", 3), rep("group2", 7))) plot(hcity.D2, hang=-1) colorhcplot(hcity.D2, fac.D2, color = c("chartreuse2", "orange2")) colorhcplot(hcity.D2, fac.D2, color = "gray30", lab.cex = 1.2, lab.mar = 0.75) ### Example 3: use gene expression data data(geneData, package="colorhcplot") exprs <- geneData$exprs fac <- geneData$fac hc <- hclust(dist(t(exprs))) colorhcplot(hc, fac, main ="default", col = "gray10") colorhcplot(hc, fac, main="Control vs. Tumor Samples")
### Example 1, using the USArrests dataset data(USArrests) hc <- hclust(dist(USArrests), "ave") fac <- as.factor(c(rep("group 1", 10), rep("group 2", 10), rep("unknown", 30))) plot(hc) colorhcplot(hc, fac) colorhcplot(hc, fac, hang = -1, lab.cex = 0.8) ### Example 2: use the "ward.D2" algorithm and ### the UScitiesD dataset data(UScitiesD) hcity.D2 <- hclust(UScitiesD, "ward.D2") fac.D2 <-as.factor(c(rep("group1", 3), rep("group2", 7))) plot(hcity.D2, hang=-1) colorhcplot(hcity.D2, fac.D2, color = c("chartreuse2", "orange2")) colorhcplot(hcity.D2, fac.D2, color = "gray30", lab.cex = 1.2, lab.mar = 0.75) ### Example 3: use gene expression data data(geneData, package="colorhcplot") exprs <- geneData$exprs fac <- geneData$fac hc <- hclust(dist(t(exprs))) colorhcplot(hc, fac, main ="default", col = "gray10") colorhcplot(hc, fac, main="Control vs. Tumor Samples")
This is a gene expression dataset simulating information about 499 gene probes and 13 samples, from an Affymetrix U95v2 chip. Data are made up, as well as sample labels. This is adapted from the Biobase-package, version 2.32.0.
data("geneData")
data("geneData")
A list of 2, including gene expression data ('$exprs') and the corresponding grouping factor ('$fac').
Data were adapted from the Biobase package version 2.32.0, and prepared by the J. Ritz Laboratory (S. Chiaretti).