dendrogram from precomputed distance matrix

14 次查看(过去 30 天)
I have looked around for an answer for this by have not been able to find one so I have come here. I have a precomputed distance matrix from an all vs all comparison of the root mean squared deviation (RMSD) of different protein structures.
0 0.5770 0.4910 1.6840 0.6660 0.8970 1.0920 0.5380 0.6390 0.8100
0.5770 0 0.6540 2.2020 0.2370 0.8790 0.9440 0.6120 0.4030 1.2530
0.4910 0.6540 0 1.7360 0.6300 0.7520 1.4530 0.3460 0.4630 1.1190
1.6840 2.2020 1.7360 0 2.2740 2.0790 2.5400 1.8480 2.1110 1.3380
0.6660 0.2370 0.6300 2.2740 0 0.8560 1.0880 0.5900 0.3360 1.3490
0.8970 0.8790 0.7520 2.0790 0.8560 0 1.4620 0.6840 0.7260 1.4480
1.0920 0.9440 1.4530 2.5400 1.0880 1.4620 0 1.3330 1.2400 1.3950
0.5380 0.6120 0.3460 1.8480 0.5900 0.6840 1.3330 0 0.3260 1.0900
0.6390 0.4030 0.4630 2.1110 0.3360 0.7260 1.2400 0.3260 0 1.2800
0.8100 1.2530 1.1190 1.3380 1.3490 1.4480 1.3950 1.0900 1.2800 0
I want to draw a dendrogram from this matrix:
tree=linkage(matrix,'average')
dengrogram(tree,0)
but if I do this the y-axis distance is all wrong because it's calculating the euclidean distances in the linkage. Is there a way to draw dendrograms directly from a precomputed distance matrix?
  1 个评论
KA
KA 2017-2-13
Found the answer to my own question.
% for a symmetric matrix A
[rows columns] = size(A); v = []; for i = 1:rows-1 v = [v A(i,i+1:columns)]; end

请先登录,再进行评论。

回答(2 个)

KA
KA 2017-2-13
编辑:Guillaume 2017-9-23
Found the answer elsewhere.
% for a symmetric matrix A
[rows columns] = size(A);
v = [];
for i = 1:rows-1
v = [v A(i,i+1:columns)];
end
  1 个评论
Guillaume
Guillaume 2017-9-23
编辑:Guillaume 2017-9-23
Note that a much simpler and faster way to obtain the same result would be:
v = A(tril(true(size(A)), -1))';

请先登录,再进行评论。


crow white
crow white 2017-9-23
I would like to do the same: I have a precomputed distance matrix (calculated on data using the bray-curtis index) and I want to draw a dendogram of the results. I don't see how your solution draws the dendrogram. Thanks for your help
  1 个评论
KA
KA 2017-9-23
I don't know if your problem is the same as mine. The problem I had was clustering and all-v-all distance matrix because you cannot calculate euclidean distances directly from these data in matlab. However, it is possible if you first convert the distance matrix to a linkage vector and then prepare a dendrogram from this vector using standard matlab commands. the script for converting the distance matrix to a vector is below output v_mat - good luck.
% for a symmetric matrix 'name'
[rows,columns] = size(matrix);
v_mat = [];
for i = 1:rows-1
v_mat = [v_mat matrix(i,i+1:columns)];
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by