#' function for pheatmap
#' @description function for pheatmap
#' @export
cluster_mat = function(mat, distance, method){
if(!(method %in% c("ward.D", "ward.D2", "ward", "single", "complete", "average", "mcquitty", "median", "centroid"))){
stop("clustering method has to one form the list: 'ward', 'ward.D', 'ward.D2', 'single', 'complete', 'average', 'mcquitty', 'median' or 'centroid'.")
}
if(!(distance[1] %in% c("correlation", "euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski")) & class(distance) != "dist"){
stop("distance has to be a dissimilarity structure as produced by dist or one measure form the list: 'correlation', 'euclidean', 'maximum', 'manhattan', 'canberra', 'binary', 'minkowski'")
}
if(distance[1] == "correlation"){
d = as.dist(1 - cor(t(mat)))
}
else{
if(class(distance) == "dist"){
d = distance
}
else{
d = dist(mat, method = distance)
}
}
return(hclust(d, method = method))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.