view scripts_R/radial_dendro.R @ 70:cc028157502a branch-tests

scripts R
author Maria Panteli
date Fri, 22 Sep 2017 16:29:32 +0100
parents
children
line wrap: on
line source
library(ape)
library(cluster) 

df = read.csv("data/cluster_freq.csv")
data = df[,2:dim(df)[2]]
rownames(data) <- df$labels
distMahal = as.dist(apply(data, 1, function(i) mahalanobis(data, i, cov = cov(data),tol=1e-18)))
hc=hclust(distMahal, method="average")
mypal = c("#000000", "#9B0000", "#9B0000", "#9B0000", "#9B0000")
clus5 = cutree(hc, 5)
pdf('data/hierarchical_cluster_R.pdf')
par(mar=c(1,1,1,1))
plot(as.phylo(hc),type="fan",tip.color=mypal[clus5], cex=.5, label.offset=.5)
dev.off()