YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/treedata-book/
832 stars 173 forks source link

phylip format #85

Closed crazyhottommy closed 7 years ago

crazyhottommy commented 7 years ago

Hi Guangchuan,

I am testing ggtree for tumor evolution. I am still learning phylogenetics. Forgive me if it sounds naive.

I have sequenced say 20 patients using whole exome and identified mutations across the samples. what I can do is to make a binary table to indicate whether a certain mutations is present or absent in each sample:

           sample 1  sample2  sample3...
mutation1      1           1             1 
mutation2      1           0             1
mutation3      0           0             0
......

Then, I could use http://evolution.genetics.washington.edu/phylip/doc/pars.html in phylip package to construct a tree. How can I import the tree output from par to ggtree?

Two outputs from par:

outfile:

Discrete character parsimony algorithm, version 3.695

One most parsimonious tree found:

  +NORM-A22-2
  |  
  |                     +------------------------MET-A23-20
  2--------------------14  
  |                     +----------------MET-A10-9-
  |  
  |        +-----------------MET-A13-14
  |        |  
  |        |    +----------------MET-A13-13
  |  +-----6    |  
  |  |     |    |              +-----------------------MET-A12-12
  |  |     |    |        +-----4  
  |  |     +----5        |     |  +------------------MET-A21-19
  |  |          |        |     +-13  
  |  |          |        |        |  +--------------MET-A18-17
  |  |          |        |        +--9  
  |  |          |        |           |  +------------------MET-A14-15
  |  |          +--------3           +--7  
  |  |                   |              |  +---------------------MET-A19-18
  |  |                   |              +-10  
  +--1                   |                 |   +----------------MET-A16-16
     |                   |                 +---8  
     |                   |                     +--------------MET-A11-11
     |                   |  
     |                   +-----------------MET-A10-10
     |  
     |                            +-----------------MET-A3-4-T
     |                        +--15  
     |    +------------------12   +--------------------MET-A2-3-T
     |    |                   |  
     |    |                   +----------MET-A2-2-T
     |    |  
     +---11                 +-------------MET-A6-6-T
          |           +----17  
          |           |     |      +------------------MET-A7-7-T
          |           |     +-----18  
          +----------16            +-------------------MET-A5-5-T
                      |  
                      |      +---------------------MET-A9-8-T
                      +-----19  
                             +-----------------MET-A1-1-T

requires a total of   3628.000

  between      and       length
  -------      ---       ------
     2      NORM-A22-2     1.67
     2          14         89.00
    14      MET-A23-20     1742.33
    14      MET-A10-9-     67.67
     2           1         2.33
     1           6         23.50
     6      MET-A13-14     73.50
     6           5         20.00
     5      MET-A13-13     68.17
     5           3         38.25
     3           4         23.75
     4      MET-A12-12     95.83
     4          13         11.08
    13      MET-A21-19     77.25
    13           9         11.58
     9      MET-A18-17     61.17
     9           7         10.08
     7      MET-A14-15     76.42
     7          10         13.08
    10      MET-A19-18     87.67
    10           8         15.42
     8      MET-A16-16     69.58
     8      MET-A11-11     62.42
     3      MET-A10-10     72.92
     1          11         20.17
    11          12         81.33
    12          15         14.17
    15      MET-A3-4-T     72.00
    15      MET-A2-3-T     84.00
    12      MET-A2-2-T     44.83
    11          16         46.50
    16          17         26.00
    17      MET-A6-6-T     55.67
    17          18         27.83
    18      MET-A7-7-T     76.17
    18      MET-A5-5-T     78.83
    16          19         26.83
    19      MET-A9-8-T     88.17
    19      MET-A1-1-T     70.83

outtree:

cat outtree 
(NORM-A22-2:1.67,(MET-A23-20:1742.33,MET-A10-9-:67.67):89.00,((MET-A13-14:73.50,(MET-A13-13:68.17,
((MET-A12-12:95.83,(MET-A21-19:77.25,(MET-A18-17:61.17,(MET-A14-15:76.42,(MET-A19-18:87.67,
(MET-A16-16:69.58,MET-A11-11:62.42):15.42):13.08):10.08):11.58):11.08):23.75,MET-A10-10:72.92):38.25):20.00):23.50,(((MET-A3-4-T:72.00,MET-A2-3-T:84.00):14.17,
MET-A2-2-T:44.83):81.33,((MET-A6-6-T:55.67,(MET-A7-7-T:76.17,MET-A5-5-T:78.83):27.83):26.00,(MET-A9-8-T:88.17,
MET-A1-1-T:70.83):26.83):46.50):20.17):2.33);

Thanks, Tommy

GuangchuangYu commented 7 years ago
library(ggtree)
tree <- read.tree('outtree')
ggtree(tree)

should works.

crazyhottommy commented 7 years ago

Thanks! was using read.phlip... A side question is that what's the real differences between a phylogenetic tree constructed by par or packages such as ape and phangorn and a hierarchal clustering dendrogram using hclust?

I know the underlying algorithms are different. but in my case the phylogenetic trees look very similar to the dendrogram. (for binary values, I used dist for binary distance and use hclust for clustering)

Thanks, Tommy

GuangchuangYu commented 7 years ago

read.phylip is for phylip tree format (phylip sequence + tree text). Your tree is actually in newick format.

dendrogram is currently not supported by ggtree.