Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- datos <- read.table("morphclustersred.csv",header=T,sep="t")
- head(datos)
- distfunc <- function(x) daisy(x,metric="gower")
- d <- distfunc(datos)
- hclustfunc <- function(x) hclust(x, method="complete")
- fit <- hclustfunc(d)
- plot(fit)
- plot(fit, labels=datos$Species,main='Morphological Clustering')
- rect.hclust(fit, k=5, border="red")
- library(ape)
- class(fit) # must be hclust class
- my_tree <- as.phylo(fit)
- write.tree(phy=my_tree, file="exported_tree.newick") # look for the file in your working directory
- # Heatmap of data frame 'data' saved as 'heat'
- heat <- heatmap.2(as.matrix(data))
- # Extract dendrograms for rows and columns from 'heat'
- row.dendro <- heat$rowDendrogram
- col.dendro <- heat$colDendrogram
- # Convert dendrograms to nwk (via .hcclust and .phylo formats!)
- as.hclust (row.dendro) ->row.hcclust
- as.phylo (row.hcclust) ->row.phylo
- write.tree(row.phylo) ->row.nwk
- as.hclust (col.dendro) ->col.hcclust
- as.phylo (col.hcclust) ->col.phylo
- write.tree(col.phylo) ->col.nwk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement