2
$\begingroup$

I have pairwise distance data for single linkage cluster and I would like to convert it to newick format.

I was unable to find a conversion algorithm.

I require newick format for visualization and annotation of a phylogeny.

Here is the output.

INFO  : ======================================
INFO  : Pairwise single linkage clustering
INFO  : ======================================
INFO  : Hierarchical Tree
INFO  : ======================================
INFO  : Node     Item 1   Item 2      Distance
INFO  :     0 :       53       52        0.001  5zxf  5z02
INFO  :    -1 :       64       60        0.002  7bj6  7bir
INFO  :    -2 :       62       -1        0.002  7biv          
INFO  :    -3 :       34       26        0.002  4wt2  4ode
INFO  :    -4 :       65       -2        0.003  7bmg          
INFO  :    -5 :       25       13        0.003  4occ  4erf
INFO  :    -6 :       29       -3        0.009  4ogt          
INFO  :    -7 :       39       38        0.010  4zyi  4zyf
INFO  :    -8 :       50       48        0.011  5oc8  5ln2
INFO  :    -9 :       54       -8        0.012  6ggn          
INFO  :   -10 :       42       41        0.015  5hmi  5hmh
INFO  :   -11 :       -4       61        0.020            7bit
INFO  :   -12 :       70       40        0.028  7qdq  5c5a
INFO  :   -13 :       47       68        0.032  5laz  7na3
INFO  :   -14 :       -9       45        0.035            5law
INFO  :   -15 :       49       59        0.038  5oai  6q9o
INFO  :   -16 :       32       -5        0.039  4qo4          
INFO  :   -17 :      -15        8        0.044            3uu1
INFO  :   -18 :       23      -16        0.047  4oas          
INFO  :   -19 :      -14       -7        0.053                    
INFO  :   -20 :       24      -18        0.057  4oba          
INFO  :   -21 :      -19        6        0.057            3lbl
INFO  :   -22 :       43      -10        0.058  5hmk          
INFO  :   -23 :       44       19        0.059  5lav  4jvr
INFO  :   -24 :      -23      -20        0.061                    
INFO  :   -25 :      -11       15        0.061            4hg7
INFO  :   -26 :       57      -24        0.062  6q9h          
INFO  :   -27 :       27       -6        0.065  4odf          
INFO  :   -28 :      -25      -17        0.067                    
INFO  :   -29 :       14      -28        0.067  4hbm          
INFO  :   -30 :      -13      -21        0.067                    
INFO  :   -31 :      -27      -29        0.067                    
INFO  :   -32 :      -26      -30        0.068                    
INFO  :   -33 :       58       21        0.068  6q9l  4mdn
INFO  :   -34 :      -31      -32        0.070                    
INFO  :   -35 :       17        5        0.071  4jv9  3lbk
INFO  :   -36 :       30      -34        0.074  4ogv          
INFO  :   -37 :      -33        2        0.077            1t4e
INFO  :   -38 :       35      -36        0.079  4zfi          
INFO  :   -39 :       20      -38        0.086  4jwr          
INFO  :   -40 :      -39      -37        0.094                    
INFO  :   -41 :        7      -40        0.106  3tj2          
INFO  :   -42 :       51      -41        0.111  5trf          
INFO  :   -43 :       69      -42        0.112  7na4          
INFO  :   -44 :       56      -43        0.113  6q96          
INFO  :   -45 :        4      -44        0.127  3jzk          
INFO  :   -46 :       33      -45        0.129  4qoc          
INFO  :   -47 :       22      -46        0.137  4mdq          
INFO  :   -48 :      -12      -47        0.151                    
INFO  :   -49 :       37      -48        0.155  4zyc          
INFO  :   -50 :       31      -49        0.156  4oq3          
INFO  :   -51 :       12      -50        0.158  4ere          
INFO  :   -52 :      -22       46        0.161            5lay
INFO  :   -53 :      -35      -51        0.182                    
INFO  :   -54 :       55      -53        0.186  6i29          
INFO  :   -55 :       10      -54        0.224  3w69          
INFO  :   -56 :       18      -55        0.238  4jve          
INFO  :   -57 :        9      -56        0.265  3vzv          
INFO  :   -58 :       28      -57        0.271  4ogn          
INFO  :   -59 :      -58        1        1.000            1rv1
INFO  :   -60 :       66      -59        1.000  7na1          
INFO  :   -61 :        0      -60        1.000                    
INFO  :   -62 :      -52      -61        1.000                    
INFO  :   -63 :       11      -62        1.000  4dij          
INFO  :   -64 :       67      -63        1.000  7na2          
INFO  :   -65 :       16      -64        1.000  4jv7          
INFO  :   -66 :       36      -65        1.000  4zgk          
INFO  :   -67 :        3      -66        1.000  2lzg          
$\endgroup$

1 Answer 1

2
$\begingroup$

The problem with the tree format presented is that it does not conform to a known standard. Whilst its possible to write a parser I don't think its a good idea.

This output is hierarchical clustering, UPGMA, that sort of thing. Its not phylogenetics because this is a linkage tree.

Can you access the distance matrix prior to the clustering? If so the information below the line will help.

The output should provide the raw distance matrix prior to hierarchical clustering and will certainly have generated it in the calculation. BTW that particular clustering method isn't cool compared with nj (below) for complex reasons.

The calculation will be:

  1. Perform pairwise linkage analysis
  2. Perform cluster analysis on the resulting matrix

You need neighbor-joining to convert the distance matrix into a newick-format. There is no possibility of a direct conversion.

If you are using R its in the ape library via treenk <- nj(M) with M is the matrix. The treenk will be a format that can be read straight into ggtree

Briefly, a distance matrix requires a clustering algorithm and neighbor-joining is by far the best clustering method developed in phylogenetics.

The following is a phylogenetics example ... this is different from the example you have 'cause thats about linkage.

data(mynucleotides)
tr <- nj(dist.dna(mynucleotides))
plot(tr)

I your case the final line will be something like ggtree(tr) ... with various options.

$\endgroup$
1
  • 1
    $\begingroup$ Thank for the idea. It helps so much. $\endgroup$ Commented Nov 12, 2022 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.