dendrogram

Colouring branches in a dendrogram in R

这一生的挚爱 提交于 2019-11-30 16:07:53
Dear resident R geniuses, I would like to colour the branches of cluster in a dendrogram where the leaves are not labelled. I found the following script here on Stackoverflow: clusDendro <- as.dendrogram(Clustering) labelColors <- c("red", "blue", "darkgreen", "darkgrey", "purple") ## function to get colorlabels colLab <- function(n) { if(is.leaf(n)) { a <- attributes(n) # clusMember - a vector designating leaf grouping # labelColors - a vector of colors for the above grouping labCol <- labelColors[clusMember[which(names(clusMember) == a$label)]] attr(n, "nodePar") <- c(a$nodePar, lab.col =

Tree/dendrogram with elbow connectors in d3

本小妞迷上赌 提交于 2019-11-30 11:28:20
问题 I'm very new to d3.js (and SVG in general), and I want to do something simple: a tree/dendrogram with angled connectors. I have cannibalised the d3 example from here:http://mbostock.github.com/d3/ex/cluster.html and I want to make it more like the protovis examples here: http://mbostock.github.com/protovis/ex/indent.html http://mbostock.github.com/protovis/ex/dendrogram.html I have made a start here: http://jsbin.com/ugacud/2/edit#javascript,html and I think it's the following snippet that's

Smooth transitioning between tree, cluster, radial tree, and radial cluster layouts

浪子不回头ぞ 提交于 2019-11-30 10:16:18
问题 For a project, I need to interactively change hierarchical data layout of a visualization - without any change of the underlying data whatsoever. The layouts capable of switching between themselves should be tree, cluster, radial tree, and radial cluster. And transitioning should be preferably an animation. I thought that would be relatively easy task with D3 . I started, but I got lost in translations and rotations, data bindings, and similar, so I am asking you for help. Also, probably I am

Custom cluster colors of SciPy dendrogram in Python (link_color_func?)

≡放荡痞女 提交于 2019-11-30 05:07:44
I want to color my clusters with a color map that I made in the form of a dictionary (i.e. {leaf: color} ). I've tried following https://joernhees.de/blog/2015/08/26/scipy-hierarchical-clustering-and-dendrogram-tutorial/ but the colors get messed up for some reason. The default plot looks good, I just want to assign those colors differently. I saw that there was a link_color_func but when I tried using my color map ( D_leaf_color dictionary) I got an error b/c it wasn't a function. I've created D_leaf_color to customize the colors of the leaves associated with particular clusters. In my actual

sklearn agglomerative clustering linkage matrix

好久不见. 提交于 2019-11-30 04:32:24
I'm trying to draw a complete-link scipy.cluster.hierarchy.dendrogram , and I found that scipy.cluster.hierarchy.linkage is slower than sklearn.AgglomerativeClustering . However, sklearn.AgglomerativeClustering doesn't return the distance between clusters and the number of original observations, which scipy.cluster.hierarchy.dendrogram needs. Is there a way to take them? I made a scipt to do it without modifying sklearn and without recursive functions. Before using note that: Merge distance can sometimes decrease with respect to the children merge distance. I added three ways to handle those

scipy linkage format

无人久伴 提交于 2019-11-30 01:22:01
I have written my own clustering routine and would like to produce a dendrogram. The easiest way to do this would be to use scipy dendrogram function. However, this requires the input to be in the same format that the scipy linkage function produces. I cannot find an example of how the output of this is formatted. I was wondering whether someone out there can enlighten me. dkar This is from the scipy.cluster.hierarchy.linkage() function documentation, I think it's a pretty clear description for the output format: A ( n -1) by 4 matrix Z is returned. At the i -th iteration, clusters with

how to convert a data.frame to tree structure object such as dendrogram

痞子三分冷 提交于 2019-11-29 23:12:51
I have a data.frame object. For a simple example: > data.frame(x=c('A','A','B','B','B'), y=c('Ab','Ac','Ba', 'Ba','Bd'), z=c('Abb','Acc','Bad', 'Bae','Bdd')) x y z 1 A Ab Abb 2 A Ac Acc 3 B Ba Bad 4 B Ba Bae 5 B Bd Bdd there are a lot more rows and columns in the actual data. how could I create a nested tree structure object of dendrogram like this: |---Ab---Abb A---| | |---Ac---Acc --| /--Bad | |---Ba-------| B---| \--Bae |---Bb---Bdd data.frame to Newick I did my PhD in computational phylogenetics and somewhere along the way I produced this code, that I used once or twice when I got some

d3.js - how to automatically calculate arc lengths in radial dendrogram

泄露秘密 提交于 2019-11-29 21:50:28
I'm creating a modified version of Mike Bostock's hierarchical edge bundling diagram: http://mbostock.github.com/d3/talk/20111116/bundle.html but I want to make arcs which span certain groups of data, like this: I'm currently just hardcoding the length of the arc, but I want to do it dynamically. How can I accomplish this? Here's my current code: /* MH - USER DEFINED VARIABLES */ var chartConfig = { "Tension" : .85, "canvasSize" : 800, "dataFile" : "../data/projects.json", "linePadding" : 160, "textPadding" : 30, "arcPadding" : 5, "arcWidth" : 30 } var pi = Math.PI; var radius = chartConfig

How can I produce plots like this?

泄露秘密 提交于 2019-11-29 20:21:46
I have come across this kind of a plot that performs hierarchical clustering over a given set of timeseries data. Can someone tell me how to draw such plots? I am open to implementations in R or Javascript, especially using d3.js . Vincent Zoonekynd You can always create the plot by hand: with base graphics, you the fig parameter allows you to add plots inside another plot. # Sample data n <- 100 k <- 6 d <- matrix(rnorm(k*n),nc=k) d[,2] <- d[,1] # To help check the results colnames(d) <- LETTERS[1:k] x <- apply(d,2,cumsum) r <- hclust(dist(t(d))) # Plot op <- par(mar=c(0,0,0,0),oma=c(0,2,0,0)

Smooth transitioning between tree, cluster, radial tree, and radial cluster layouts

倖福魔咒の 提交于 2019-11-29 19:39:23
For a project, I need to interactively change hierarchical data layout of a visualization - without any change of the underlying data whatsoever. The layouts capable of switching between themselves should be tree, cluster, radial tree, and radial cluster. And transitioning should be preferably an animation. I thought that would be relatively easy task with D3 . I started, but I got lost in translations and rotations, data bindings, and similar, so I am asking you for help. Also, probably I am doing something not in the spirit of D3, which is bad since I am seeking a clean solution. I put