Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree$edge does not reconcile with phylotree() data.frame #1

Closed
schultzm opened this issue Aug 30, 2016 · 3 comments
Closed

tree$edge does not reconcile with phylotree() data.frame #1

schultzm opened this issue Aug 30, 2016 · 3 comments

Comments

@schultzm
Copy link

schultzm commented Aug 30, 2016

Hi,

Thanks for the software. It looks like it will be very useful for us.

I'm trying to use it to plot an MCC tree with posterior support values overlaid. In the example below, I create the phybreak object using phybreak(data, times). I burnin with 1000 cycles and sample for 10000 cycles.

MCMCstate = phybreak(data=core_tab_chrmsm, times=d3)
MCMCstate = burnin.phybreak(MCMCstate, ncycles = 1000)
MCMCstate = sample.phybreak(MCMCstate, nsample=10000, thin=1)

Then, I get the the phylotree() data.frame and tree:

phylo_tree_matrix = phylotree(MCMCstate, support = "proportion")
phylo_tree = phylotree(MCMCstate, support = "proportion", phylo.class = T)

My aim is to overlay the posterior supports from the phylo_tree_matrix on the phylo_tree, but the phylo_tree$edge matrix and the phylo_tree_matrix$parent columns are irreconcilable, as can be found when comparing the plot of the tree (with tiplabels() and nodelabels()) with the following two tables:

plot(phylo_tree)
nodelabels() #these are the blue squares
tiplabels() #these are the yellow squares

screen shot 2016-08-30 at 14 19 03

That is, the parent-child relationships between the following two tables do not align. Here is the edge table (the blue squares are column 1 and the yellow squares are column 2):

> phylo_tree$edge
      [,1] [,2]
 [1,]   26   27
 [2,]   27   28
 [3,]   28   29
 [4,]   29   30
 [5,]   30   33
 [6,]   33   38
 [7,]   38   36
 [8,]   36   37
 [9,]   37   35
[10,]   35   41
[11,]   41   44
[12,]   44   45
[13,]   45   48
[14,]   48    9
[15,]   48   12
[16,]   45   14
[17,]   44   49
[18,]   49   46
[19,]   46   11
[20,]   46   13
[21,]   49   10
[22,]   41   18
[23,]   35   22
[24,]   37   42
[25,]   42   19
[26,]   42   24
[27,]   36   16
[28,]   38   39
[29,]   39   43
[30,]   43    6
[31,]   43   17
[32,]   39   47
[33,]   47   21
[34,]   47   23
[35,]   33    3
[36,]   30    1
[37,]   29   31
[38,]   31    2
[39,]   31   15
[40,]   28   34
[41,]   34    4
[42,]   34    7
[43,]   27   40
[44,]   40    5
[45,]   40   20
[46,]   26   32
[47,]   32    8
[48,]   32   25

And here is the data.frame (rows 35, 36, 38, 39, 42, 43, 47 have bad parent-child relationships, where child is the row-name and parent is the corresponding cell value in column 1) :

> phylo_tree_matrix
   parent    support node.times.mean node.times.sd node.times.mc.tree
1      30 1.00000000      0.00000000    0.00000000         0.00000000
2      31 1.00000000      0.30000000    0.00000000         0.30000000
3      33 1.00000000      0.40000000    0.00000000         0.40000000
4      34 1.00000000      0.81000000    0.00000000         0.81000000
5      40 1.00000000      0.86000000    0.00000000         0.86000000
6      43 1.00000000      0.90000000    0.00000000         0.90000000
7      34 1.00000000      0.94000000    0.00000000         0.94000000
8      32 1.00000000      1.56000000    0.00000000         1.56000000
9      48 1.00000000      1.88000000    0.00000000         1.88000000
10     49 1.00000000      2.26000000    0.00000000         2.26000000
11     46 1.00000000      2.38000000    0.00000000         2.38000000
12     48 1.00000000      2.52000000    0.00000000         2.52000000
13     46 1.00000000      2.55000000    0.00000000         2.55000000
14     45 1.00000000      2.79000000    0.00000000         2.79000000
15     31 1.00000000      0.71000000    0.00000000         0.71000000
16     38 1.00000000      0.88000000    0.00000000         0.88000000
17     43 1.00000000      0.90000000    0.00000000         0.90000000
18     41 1.00000000      0.90000000    0.00000000         0.90000000
19     42 1.00000000      0.90000000    0.00000000         0.90000000
20     40 1.00000000      0.90000000    0.00000000         0.90000000
21     47 1.00000000      0.91000000    0.00000000         0.91000000
22     35 1.00000000      0.91000000    0.00000000         0.91000000
23     38 1.00000000      0.92000000    0.00000000         0.92000000
24     42 1.00000000      0.92000000    0.00000000         0.92000000
25     32 1.00000000      1.56000000    0.00000000         1.56000000
26      0 1.00000000     -1.51126789    0.90524149        -1.67566591
27     26 0.65118812     -1.42796803    0.61749479        -1.29354997
28     27 0.74316832     -1.11291185    0.59893442        -1.05383677
29     28 0.99732673     -0.49866271    0.39040749        -0.53178046
30     29 0.41752475     -0.29407567    0.17194680        -0.21870728
31     29 0.52405941     -0.21429529    0.25190572        -0.14663459
32     26 0.99940594     -0.04581645    0.65440055        -0.41669197
33     30 0.96425743      0.16568535    0.19175916         0.13751129
34     28 0.99732673     -0.21341553    0.35359052        -0.36316498
35     39 0.09653465      0.78918218    0.07259913         0.78166042
36     33 0.71603960      0.43536170    0.11343933         0.28688438
37     36 0.03366337      0.56681280    0.10266716         0.36312121
38     37 0.08178218      0.63215878    0.11109348         0.76105123
39     37 0.03792079      0.63332049    0.10035708         0.58598696
40     27 0.99930693      0.07795032    0.40078764         0.03305225
41     35 0.21554455      0.88923055    0.01873173         0.89209207
42     39 0.10227723      0.73601620    0.11624829         0.75397219
43     47 0.97485149      0.73915054    0.12418226         0.71125887
44     41 0.80980198      1.28028753    0.26203872         1.01338487
45     44 0.70732673      1.50948099    0.27434150         1.49648718
46     49 0.99782178      2.15139832    0.20358827         1.88874520
47     36 0.06138614      0.50711223    0.31232034         0.48576206
48     45 0.80425743      1.64236086    0.30733507         1.58391568
49     44 0.99930693      1.74499925    0.31908351         1.62513775

I have seen in http://rpackages.ianhowson.com/cran/phybreak/man/phylotree.html that the phylotree data.frame should be: "A data.frame with per item (=node) its parent and support per clade, and optionally summary node times. The first n nodes are the samples, the last n-1 nodes are the internal nodes." But, still, this does not seem to add up correctly.

Is this an error or am I missing something? Could you please add a feature that adds these posterior support values to the tree (phylo) object tree$node.label so that I don't need to manually try to do this myself?

Also, will be adding more to the documentation and providing tutorials? This would also be very helpful.

All the best,

Mark

@schultzm schultzm changed the title tree$edge does not reconcile with phylotree dataframe tree$edge does not reconcile with phylotree() data.frame Aug 30, 2016
@donkeyshot
Copy link
Owner

Dear Mark

Thanks for your comment. Hmm, that seems to go terribly wrong indeed.
Makes me curious if the same goes wrong with 'transtree'. I'll have a
look at it shortly and get back to you this week (I hope).

Cheers
Don

Mark Schultz schreef op 2016-08-30 06:32:

Hi,

Thanks for the software. It looks like it will be very useful for us.

I'm trying to use it to plot a MCC tree with posterior support values
overlaid. In the example below, I create the phybreak object using
phybreak(data, times). I burnin with 1000 cycles, and sample for 10000
cycles.

MCMCstate = phybreak(data=core_tab_chrmsm, times=d3)
MCMCstate = burnin.phybreak(MCMCstate, ncycles = 1000)
MCMCstate = sample.phybreak(MCMCstate, nsample=10000, thin=1)

Then, I get the the phylotree() data.frame and tree:

phylo_tree_matrix = phylotree(MCMCstate, support = "proportion")
phylo_tree = phylotree(MCMCstate, support = "proportion", phylo.class
= T)

My aim is to overlay the posterior supports from the phylo_tree_matrix
on the phylo_tree, but the phylo_tree$edge matrix and the
phylo_tree_matrix$parent columns are irreconcilable, as is seen by
this plot of the tree with tiplabels() and nodelabels().

plot(phylo_tree)
nodelabels() #these are the blue squares
tiplabels() #these are the yellow squares

[1]

That is, the parent-child relationships between the following two
tables do not align. Here is the edge table:

phylo_tree$edge
[,1] [,2]
[1,] 26 27
[2,] 27 28
[3,] 28 29
[4,] 29 30
[5,] 30 33
[6,] 33 38
[7,] 38 36
[8,] 36 37
[9,] 37 35
[10,] 35 41
[11,] 41 44
[12,] 44 45
[13,] 45 48
[14,] 48 9
[15,] 48 12
[16,] 45 14
[17,] 44 49
[18,] 49 46
[19,] 46 11
[20,] 46 13
[21,] 49 10
[22,] 41 18
[23,] 35 22
[24,] 37 42
[25,] 42 19
[26,] 42 24
[27,] 36 16
[28,] 38 39
[29,] 39 43
[30,] 43 6
[31,] 43 17
[32,] 39 47
[33,] 47 21
[34,] 47 23
[35,] 33 3
[36,] 30 1
[37,] 29 31
[38,] 31 2
[39,] 31 15
[40,] 28 34
[41,] 34 4
[42,] 34 7
[43,] 27 40
[44,] 40 5
[45,] 40 20
[46,] 26 32
[47,] 32 8
[48,] 32 25

And here is the data.frame (rows 35, 36, 38, 39, 42, 43, 47 have bad
parent-child relationships, where child is the row-name and parent is
the corresponding cell value in column 1) :

phylo_tree_matrix
parent support node.times.mean node.times.sd node.times.mc.tree
1 30 1.00000000 0.00000000 0.00000000 0.00000000
2 31 1.00000000 0.30000000 0.00000000 0.30000000
3 33 1.00000000 0.40000000 0.00000000 0.40000000
4 34 1.00000000 0.81000000 0.00000000 0.81000000
5 40 1.00000000 0.86000000 0.00000000 0.86000000
6 43 1.00000000 0.90000000 0.00000000 0.90000000
7 34 1.00000000 0.94000000 0.00000000 0.94000000
8 32 1.00000000 1.56000000 0.00000000 1.56000000
9 48 1.00000000 1.88000000 0.00000000 1.88000000
10 49 1.00000000 2.26000000 0.00000000 2.26000000
11 46 1.00000000 2.38000000 0.00000000 2.38000000
12 48 1.00000000 2.52000000 0.00000000 2.52000000
13 46 1.00000000 2.55000000 0.00000000 2.55000000
14 45 1.00000000 2.79000000 0.00000000 2.79000000
15 31 1.00000000 0.71000000 0.00000000 0.71000000
16 38 1.00000000 0.88000000 0.00000000 0.88000000
17 43 1.00000000 0.90000000 0.00000000 0.90000000
18 41 1.00000000 0.90000000 0.00000000 0.90000000
19 42 1.00000000 0.90000000 0.00000000 0.90000000
20 40 1.00000000 0.90000000 0.00000000 0.90000000
21 47 1.00000000 0.91000000 0.00000000 0.91000000
22 35 1.00000000 0.91000000 0.00000000 0.91000000
23 38 1.00000000 0.92000000 0.00000000 0.92000000
24 42 1.00000000 0.92000000 0.00000000 0.92000000
25 32 1.00000000 1.56000000 0.00000000 1.56000000
26 0 1.00000000 -1.51126789 0.90524149 -1.67566591
27 26 0.65118812 -1.42796803 0.61749479 -1.29354997
28 27 0.74316832 -1.11291185 0.59893442 -1.05383677
29 28 0.99732673 -0.49866271 0.39040749 -0.53178046
30 29 0.41752475 -0.29407567 0.17194680 -0.21870728
31 29 0.52405941 -0.21429529 0.25190572 -0.14663459
32 26 0.99940594 -0.04581645 0.65440055 -0.41669197
33 30 0.96425743 0.16568535 0.19175916 0.13751129
34 28 0.99732673 -0.21341553 0.35359052 -0.36316498
35 39 0.09653465 0.78918218 0.07259913 0.78166042
36 33 0.71603960 0.43536170 0.11343933 0.28688438
37 36 0.03366337 0.56681280 0.10266716 0.36312121
38 37 0.08178218 0.63215878 0.11109348 0.76105123
39 37 0.03792079 0.63332049 0.10035708 0.58598696
40 27 0.99930693 0.07795032 0.40078764 0.03305225
41 35 0.21554455 0.88923055 0.01873173 0.89209207
42 39 0.10227723 0.73601620 0.11624829 0.75397219
43 47 0.97485149 0.73915054 0.12418226 0.71125887
44 41 0.80980198 1.28028753 0.26203872 1.01338487
45 44 0.70732673 1.50948099 0.27434150 1.49648718
46 49 0.99782178 2.15139832 0.20358827 1.88874520
47 36 0.06138614 0.50711223 0.31232034 0.48576206
48 45 0.80425743 1.64236086 0.30733507 1.58391568
49 44 0.99930693 1.74499925 0.31908351 1.62513775

Thank you for your help.

Also, will be adding more to the documentation and providing
tutorials?

All the best,

Mark

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub [2], or mute the
thread [3].

Links:

[1]
https://cloud.githubusercontent.com/assets/5474971/18076105/4c90ce26-6ebe-11e6-942f-288c70e13a85.png
[2] #1
[3]
https://github.com/notifications/unsubscribe-auth/APGTUaw1lGBMjCOphePoX-NRh1f-kx8fks5qk7JVgaJpZM4JwIuE

@donkeyshot
Copy link
Owner

donkeyshot commented Aug 30, 2016 via email

@schultzm
Copy link
Author

Fixed! Thanks Don.

donkeyshot pushed a commit that referenced this issue Mar 28, 2022
Merge fix for sequence likelihood calculation at root coalescent node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants