dendrogram

Measuring reliability of tree/dendrogram (Traminer)

寵の児 提交于 2019-12-24 03:12:47
问题 I did an analysis using TraMineR in order to measure the similarity among sequences of spatial use (for example Rural(R) vs Urban (U): sequence example -> RRRRRUUURRUUU) A requirement in my analysis is that states are compared at the same moment in time and therefore I used the hamming sequence similarity. Based on the similarity matrix I created a dendrogram, giving the distances among individual sequences, helping to identify "behavioral similarities" in sequential spatial use. Now I am

Create tree diagram

纵饮孤独 提交于 2019-12-23 23:26:50
问题 I have data on a company that I want to visualize by a tree diagram. That means, I have their brands nested in classes, nested in subgroups, nested in divisions (http://www.bayer.com/en/products-from-a-to-z.aspx#B). Even though there are quite some threads on stackoverflow how to create dendrograms, I did not find a code snippet that worked with my data (such as e.g. how to convert a data.frame to tree structure object such as dendrogram). EDIT : If I am right "dendrogram" is in this case not

Subsets of a dataset as separate dendrograms, but in the same plot

有些话、适合烂在心里 提交于 2019-12-23 03:37:16
问题 I know I can plot a dendrogram as follows library(cluster) d <- mtcars d[,8:11] <- lapply(d[,8:11], as.factor) gdist <- daisy(d, metric = c("gower"), stand = FALSE) dendro <- hclust(gdist, method = "average") plot(as.dendrogram(dendro)) However I have some groups identified (eg. by an iterative classification method), given as the last column in d G <- c(1,2,3,3,4,4,5,5,5,5,1,2,1,1,2,4,1,3,4,5,1,7,4,3,3,2,1,1,1,3,5,6) d$Group <- G head(d) mpg cyl disp hp drat wt qsec vs am gear carb Group

Color side bar dendrogram plot

房东的猫 提交于 2019-12-23 02:34:53
问题 Initially I was trying to add the horizontal color side bar to the dendrogram plot (NOT to the whole heat map) using colored_bars from dendextend. The code below (THANK YOU for your help Tal!) works pretty well. The only issue remaining is how to control the distance of the bar from the leaves labels and the bar width? Here is an example, data and code Data (4 variables, 5 cases) df <- read.table(header=T, text="group class v1 v2 1 A 1 3.98 23.2 2 A 2 5.37 18.5 3 C 1 4.73 22.1 4 B 1 4.17 22.3

Heatmap function in R dendrogram failure

喜欢而已 提交于 2019-12-23 02:19:49
问题 For the life of me I cannot understand why this method is failing, I would really appreciate an additional set of eyes here: heatmap.2(TEST,trace="none",density="none",scale="row", ColSideColors=c("red","blue")[data.test.factors], col=redgreen,labRow="", hclustfun=function(x) hclust(x,method="complete"), distfun=function(x) as.dist((1 - cor(x))/2)) The error that I get is: row dendrogram ordering gave index of wrong length If I don't include the distfun, everything works really well and is

drawing heatmap with dendrogram along with sample labels

牧云@^-^@ 提交于 2019-12-22 08:16:58
问题 Using the heatmap function of made4 , I made this heatmap dendrogram from the example file: data(khan) heatplot(khan$train[1:30,], lowcol="blue", highcol="red") How can I add a panel of labels for the samples on the edges of the heatmap, like in this figure? The labels in this case are the squares that are adjacent to the heatmap first col and top row, used to denote a label for each sample so that one can see if the labels correspond with the clustering shown by the heatmap/dendrogram. In

How to convert a tree to a dendrogram in R?

强颜欢笑 提交于 2019-12-21 05:24:10
问题 How can I convert a tree (which is the output of my Java program) to a dendrogram in R? Currently, I am converting the tree into the Newick format, using the suggestion given here. And then I use the ape package in R to read the Newick-formatted tree: library("ape") cPhylo <- read.tree(file = "gc.tree") Finally I use as.hclust in R to convert the tree into a dendrogram: dendrogram <- as.hclust(gcPhylo) However, the dendrogram requires the branch lengths. Although I insert the branch lengths,

scipy linkage format

我的梦境 提交于 2019-12-18 11:02:37
问题 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. 回答1: This is from the scipy.cluster.hierarchy.linkage() function documentation, I think it's a pretty clear description

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

若如初见. 提交于 2019-12-18 10:24:22
问题 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

How can I produce plots like this?

怎甘沉沦 提交于 2019-12-18 10:09:05
问题 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 . 回答1: 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 <