python,scipy,dendrogram,hcluster

Here's the solution. Turns out the SimMatrix needs to be first converted into a condensed matrix (the diagonal, upper right or bottom left, of this matrix). You can see this in the code below: import scipy.spatial.distance as ssd distVec = ssd.squareform(SimMatrix) linkage = hcluster.linkage(1 - distVec) dendro = hcluster.dendrogram(linkage) show()...

r,colors,data.frame,dendrogram

It's easier to change colors for a dendrogram than an hclust object, but it's pretty straightforward to convert. You can do drg1 <- dendrapply(as.dendrogram(hcl1, hang=.1), function(n){ if(is.leaf(n)){ labelCol <- c(a="red", b="blue")[substr(attr(n,"label"),1,1)]; attr(n, "nodePar") <- list(pch = NA, lab.col = labelCol); attr(n, "edgePar") <- list(col = labelCol); # to color branch...

Thanks to @Vlo and @lukeA I'm able to implement a loop. However, I am just posting this for a starting point and certainly open to a more elegant solution. unnest <- function(x) { # from Vlo's answer if(is.null(names(x))) x else c(list(all=unname(unlist(x))), do.call(c, lapply(x, unnest))) } cuts <- hc$height + 1e-9...

This is not impossible to render in Bokeh (as of 0.4.4) but there is no built-in support to help with graphs and graph layout yet. You would have to compute or use a library to compute the line points for the edges, etc. and then pass those to Bokeh. Graph...

From heatmap help you can read: Typically, reordering of the rows and columns according to some set of values (row or column means) within the restrictions imposed by the dendrogram is carried out. In fact the reorder using Rowmeans/Colmeans is applied to the clustres. This is done internally in 2...

r,cluster-analysis,hierarchical-clustering,dendrogram,dendextend

If you want to color the branches of a dendrogram based on a certain variable then the following code (largely taken from the help for the dendrapply function) should give the desired result: x<-1:100 dim(x)<-c(10,10) groups<-sample(c("red","blue"), 10, replace=TRUE) x.clust<-as.dendrogram(hclust(dist(x))) local({ colLab <<- function(n) { if(is.leaf(n)) { a <- attributes(n) i...

matlab,cluster-analysis,hierarchy,dendrogram

To see interesting parts of the dendrogram and heatmap more clearly, you can use the zoom button on the toolbar to select regions of interest and zoom in on them. To find out which genes/variables are in a particular cluster, right-click on a point in one of the dendrograms that...

As far as I understand, you are asking two questions, and I'll try to answer both: 1) How do you control the names of items in a dist object? The easiest way is to control the rownames of the matrix/data.frame that is used to produce the dist. For example: >...

python,scipy,hierarchical-clustering,dendrogram

Here's the answer - I didn't add 'distance' as an option to fcluster. With it, I get the correct (3) cluster assignments. assignments = fcluster(linkage(distanceMatrix, method='complete'),4,'distance') print assignments [3 2 2 2 2 2 2 2 2 2 2 2 1 2 1 2 1 1 1 1 1 1...

r,plot,cluster-analysis,dendrogram,hclust

If you want to mimic the last few graphs, you can do something like this: N <- max(G) layout(matrix(c(0,1:N,0),nc=1)) gdist <- as.matrix(gdist) for (i in 1:N){ par(mar=c(0,3,0,7)) rc_tokeep <- row.names(subset(d, G==i)) if(length(rc_tokeep)>2){ #The idea is to catch the groups with one single element to plot them differently dis <- as.dist(gdist[rc_tokeep,...

r,colors,plot,dendrogram,dendextend

Try # ... your code colLab <- function(n) { if(is.leaf(n)) { a <- attributes(n) attr(n, "label") <- labs[a$label] attr(n, "nodePar") <- c(a$nodePar, lab.col = varCol[a$label]) } n } plot(dendrapply(hcd, colLab)) (via)...