How to connect the tips of several phylogenetic trees with ggtree?
1
0
Entering edit mode
9 weeks ago
Luca Arbore ▴ 10

I am trying to build a tanglegram of 4 gene trees from a segmented virus genome. I have followed the package manual as per subcap. 2.6: https://yulab-smu.top/treedata-book/chapter2.html but I am getting connecting lines not only between tips, but nodes as well.

I suspect it has to do with filtering of label, since I tried in fortify() to use only is.Tip, and I get the correct labels and lines, but no trees.

Any help would be greatly appreaciated.

s1 <- read.tree(here("data/jingmen_s1_pool1.fasta.treefile"))
s2 <- read.tree(here("data/jingmen_s2_pool1.fasta.treefile"))
s3 <- read.tree(here("data/jingmen_s3_pool1.fasta.treefile"))
s4 <- read.tree(here("data/jingmen_s4_pool1.fasta.treefile"))

tree1 <- fortify(s1)
tree2 <- fortify(s2)
tree3 <- fortify(s3)
tree4 <- fortify(s4)
tree2$x <- tree2$x + max(tree1$x) +.1
tree3$x <- tree3$x + max(tree2$x) +.1
tree4$x <- tree4$x + max(tree3$x) +.1
jingmen_s <- bind_rows(tree1, tree2, tree3, tree4) %>%
filter(!is.na(label))

p <- ggtree(tree1) +
geom_tree(data = tree2) +
geom_tree(data = tree3) +
geom_tree(data = tree4) +
geom_tiplab(data = tree1) +
geom_tiplab(data = tree2, hjust = 0) +
geom_tiplab(data = tree3, hjust = 0) +
geom_tiplab(data = tree4, hjust = 0) +
geom_line( 
aes(x, y, group = label),
data = jingmen_s,
alpha = 0.5 
)

enter image description here

R tanglegram phylogenetic tree ggtree • 564 views
ADD COMMENT
0
Entering edit mode

Can you please share the data that's stored in jingmen_s? My guess is that the filter() function hasn't worked here as intended.

ADD REPLY
0
Entering edit mode

I could not find an attach button so here they are. thank you.

jingmen_s1_pool1.fasta.treefile:  
(141_03-Ixodes:0.0058790622,(141_31-Amblyomma:0.0048478844,141_22-Amblyomma:0.0067408617)44:0.0006327728,((141_11-Amblyomma:0.0022375969,141_24-Amblyomma:0.0025573326)99:0.0037176841,((143_56-Amblyomma:0.0067582270,143_58-Amblyomma:0.0074819674)50:0.0003078880,((((141_20-Amblyomma:0.0064174548,141_30-Amblyomma:0.0064542266)100:0.0120856690,(143_76-Amblyomma:0.0048197795,143_97-Ixodes:0.0094804061)100:0.0065997540)95:0.0036604520,143_51-Ixodes:0.0221693904)78:0.0014915317,(141_45-Amblyomma:0.0169051121,(141_32-Amblyomma:0.0297678872,141_38-Amblyomma:0.0143533575)100:0.0190918589)62:0.0018350031)100:0.0224227073)54:0.0003599291)41:0.0000010000);

jingmen_s2_pool1.fasta.treefile:
(141_03-Ixodes:0.0083569432,(((141_11-Amblyomma:0.0044526766,((((((141_20-Amblyomma:0.0138174359,141_30-Amblyomma:0.0111721230)100:0.0072570030,(143_51-Ixodes:0.0130237457,(143_76-Amblyomma:0.0044946052,143_97-Ixodes:0.0040635289)98:0.0038309260)97:0.0043972545)98:0.0057358005,141_45-Amblyomma:0.0152997386)100:0.0346705100,141_32-Amblyomma:0.0059771409)87:0.0035729200,(141_31-Amblyomma:0.0060252413,141_38-Amblyomma:0.0078595820)89:0.0027194542)76:0.0009500542,141_22-Amblyomma:0.0059485391)73:0.0008345897)69:0.0013085051,141_24-Amblyomma:0.0055641651)60:0.0009751494,143_58-Amblyomma:0.0059794758)43:0.0008332118,143_56-Amblyomma:0.0050462446);

jingmen_s3_pool1.fasta.treefile:
(141_03-Ixodes:0.0061443854,(((141_11-Amblyomma:0.0283177144,141_24-Amblyomma:0.0003156453)99:0.0023094277,(((((((141_20-Amblyomma:0.0086982000,141_30-Amblyomma:0.0078430199)100:0.0070082674,(143_76-Amblyomma:0.0074656681,143_97-Ixodes:0.0327668676)72:0.0004674880)99:0.0044802711,143_51-Ixodes:0.0036352988)99:0.0042266426,141_32-Amblyomma:0.0325733571)88:0.0024957315,(141_45-Amblyomma:0.0122030800,143_58-Amblyomma:0.0125810341)76:0.0011932194)96:0.0026569622,141_38-Amblyomma:0.0077671160)93:0.0016380152,141_31-Amblyomma:0.0084611791)98:0.0038790835)74:0.0006385019,141_22-Amblyomma:0.0053788355)99:0.0032965711,143_56-Amblyomma:0.0037627578);

jingmen_s4_pool1.fasta.treefile:
(141_03-Ixodes:0.0028255604,(((((141_11-Amblyomma:0.0061816798,141_38-Amblyomma:0.0047904531)99:0.0049092032,(((((141_20-Amblyomma:0.0140752466,143_97-Ixodes:0.0125111638)86:0.0025622480,143_76-Amblyomma:0.0213522193)96:0.0085784636,143_51-Ixodes:0.0344050862)97:0.0081899459,(141_30-Amblyomma:0.0167873007,141_45-Amblyomma:0.0099544344)100:0.0165199255)100:0.0100142165,141_24-Amblyomma:0.0076510655)79:0.0012183343)96:0.0032101202,143_56-Amblyomma:0.0076468089)99:0.0039165629,(141_31-Amblyomma:0.0056549381,141_32-Amblyomma:0.0021457820)72:0.0003747946)98:0.0023547931,143_58-Amblyomma:0.0037407301)60:0.0003084861,141_22-Amblyomma:0.0018630146);
ADD REPLY
1
Entering edit mode
9 weeks ago
Luca Arbore ▴ 10

Solved! Tips have to be included in the filter

jingmen_s <- bind_rows(tree1, tree2, tree3, tree4) %>%
filter(!is.na(label) & isTip == TRUE)
ADD COMMENT

Login before adding your answer.

Traffic: 1699 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6