dendrogram

Draw dendrogram in python manually

拜拜、爱过 提交于 2019-12-10 02:36:42
问题 I have implemented an algorithm to solve the problem of clustering in a graph. I used the python library "python-graph" to represent the graph. Now, at each step of my computation (the algorithm is iterative) I have to draw a part of the dendrogram. In fact, the algorithm is divisive, in the sense that starting from the original graph calculates the clusters. Now, I don't know what to use to draw the dendrogram (someone suggested PIL, but I'm looking for something easy and I don't know how to

Dendrogram or Other Plot from Distance Matrix

廉价感情. 提交于 2019-12-09 18:03:08
问题 I have three matrices to compare. Each of them is 5x6. I originally wanted to use hierarchical clustering to cluster the matrices, such that the most similar matrices are grouped, given a threshold of similarity. I could not find any such functions in python, so I implemented the distance measure by hand, (p-norm where p=2). Now I have a 3x3 distance matrix (which I believe is also a similarity matrix in this case). I am now trying to produce a dendrogram. This is my code, and this is what is

Exporting dendrogram as table in R

拜拜、爱过 提交于 2019-12-09 04:55:06
问题 I would like to export an hclust-dendrogram from R into a data table in order to subsequently import it into another ("home-made") software. str(unclass(fit)) provides a text overview for the dendrogram, but what I'm looking for is really a numeric table. I've looked at the Bioconductor ctc package, but the output it's producing looks somewhat cryptical. I would like to have something similar to this table: http://stn.spotfire.com/spotfire_client_help/heat/heat_importing_exporting_dendrograms

Dendrogram generated by scipy-cluster does not show

≯℡__Kan透↙ 提交于 2019-12-09 04:39:32
问题 I am using scipy-cluster to generate a hierarchical clustering on some data. As a final step of the application, I call the dendrogram function to plot the clustering. I am running on Mac OS X Snow Leopard using the built-in Python 2.6.1 and this matplotlib package. The program runs fine, but at the end the Rocket Ship icon (as I understand, this is the launcher for GUI applications in python) shows up and vanishes immediately without doing anything. Nothing is shown. If I add a 'raw_input'

Color side bar dendrogram plot

别说谁变了你拦得住时间么 提交于 2019-12-08 20:25:33
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 5 C 2 4.47 22.4 ") car_type <- factor(df[,c(1)]) # groups codes (A,B,C) cols_4 <- heat.colors(3) col

Color dendrogram branches based on external labels uptowards the root until the label matches

喜欢而已 提交于 2019-12-07 14:42:31
问题 From question Color branches of dendrogram using an existing column, I can color the branches near the leaf of the dendrogram. The code: x<-1:100 dim(x)<-c(10,10) set.seed(1) groups<-c("red","red", "red", "red", "blue", "blue", "blue","blue", "red", "blue") x.clust<-as.dendrogram(hclust(dist(x))) x.clust.dend <- x.clust labels_colors(x.clust.dend) <- groups x.clust.dend <- assign_values_to_leaves_edgePar(x.clust.dend, value = groups, edgePar = "col") # add the colors. x.clust.dend <- assign

larger font and spacing between leaves in R dendrogram

∥☆過路亽.° 提交于 2019-12-07 06:51:57
问题 I have a dendrogram in R that I just can't get it right. I'll show you what the problem is, please check this: http://img.photobucket.com/albums/v699/rica01/Rplot-1.png How can I make the labels on the leaves, bigger and more spaced between them? Thanks. -Ricardo 回答1: Solution: use the set function, with the "labels_cex" parameter from the dendextend package. # install.packages("dendextend") library(dendextend) dend <- as.dendrogram(hclust(dist(USArrests[1:5,]))) # Like: # dend <- USArrests[1

How to hierarchically cluster a data matrix in R?

点点圈 提交于 2019-12-06 12:02:52
问题 I am trying to cluster a data matrix produced from scientific data. I know how I want the clustering done, but am not sure how to accomplish this feat in R. Here is what the data looks like: A1 A2 A3 B1 B2 B3 C1 C2 C3 sample1 1 9 10 2 1 29 2 5 44 sample2 8 1 82 2 8 2 8 2 28 sample3 9 9 19 2 8 1 7 2 27 Please consider A1,A2,A3 to be three replicates of a single treatment, and likewise with B and C. Sample1 are different tested variables. So, I want to hierarchically cluster this matrix in

Interpreting the output of SciPy's hierarchical clustering dendrogram? (maybe found a bug…)

末鹿安然 提交于 2019-12-06 04:10:18
I am trying to figure out how the output of scipy.cluster.hierarchy.dendrogram works... I thought I knew how it worked and I was able to use the output to reconstruct the dendrogram but it seems as if I am not understanding it anymore or there is a bug in Python 3 's version of this module. This answer, how do I get the subtrees of dendrogram made by scipy.cluster.hierarchy , implies that the dendrogram output dictionary gives dict_keys(['icoord', 'ivl', 'color_list', 'leaves', 'dcoord']) w/ all of the same size so you can zip them and plt.plot them to reconstruct the dendrogram. Seems simple

drawing heatmap with dendrogram along with sample labels

大憨熊 提交于 2019-12-05 15:13:52
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 this particular plot they chose to make those labels correspond exactly to the colors of the dendrogram