extendtree: Hierarchical clustering with amap::Dist and draw dendrogram...

View source: R/extendtree.R

extendtreeR Documentation

Hierarchical clustering with amap::Dist and draw dendrogram with dendextend

Description

This functions returns the list consit of hclust object and dendrogram object. dendrogram is coloured by factor

Usage

extendtree(dat, extend, distm, clm, lab, gp, vcol, cexlab, blwd, ...)

Arguments

dat

data frame or matrix

extend

use with dendextend or not

distm

distance measure one of the amap::Dist methods "euclidean", "maximum", "manhattan", "canberra", "binary", "pearson", "abspearson", "correlation", "abscorrelation", "spearman" or "kendall". The default is "spearman".

clm

one of the hclust methods "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty"(= WPGMA), "median"(= WPGMC) or "centroid"(= UPGMC). The default is "ward.D2" .

lab

Leaf labels

gp

Group of labels as factor

vcol

A vector of colours corresponding to group of leaves

cexlab

cex of leaf label. The default is 0.8

blwd

line width of edges. The default is 1

...

arbitary option, if not using dendextend. E.g. nodePar = list(pch = NA, lab.cex = 0.8), edgePar = list(lwd = 2), leaflab ="none"

Value

Character vector, length of n

Examples

## Not run:  # minimum usage
res1 <- rsko::extendtree(dat = mtcars, extend = FALSE, lab = rownames(mtcars))
res1[[1]]
plot(res1[[2]])

# using dist object from other distance measure
cos.mat <- rsko::siml_mat(dat = t(iris[,1:4]), method = "cosine", type = "distance")
dist.cos <- as.dist(cos.mat)
res2 <-  rsko::extendtree(dat = iris[,1:4], extend = TRUE, distm = dist.cos, clm = "average",
    lab = as.character(iris$Species), gp = iris$Species, vcol = 1:3, cexlab = 0.5, blwd = 1)
plot(res2[[2]])

# using dendextend with several 'set' options
res3 <- rsko::extendtree(dat = iris[,1:4], extend = TRUE, distm = "euclidean", clm = "average",
    lab = as.character(iris$Species), gp = iris$Species, vcol = 1:3, cexlab = 0.5, blwd = 1.5)
plot(res3[[2]])

## End(Not run)

shkonishi/rsko documentation built on Feb. 21, 2023, 5:12 a.m.