Multiple tree tanglegram

19 views
Skip to first unread message

alex

unread,
Dec 6, 2024, 9:57:09 AM12/6/24
to ggtree
Hello,

I really enjoy the package and the extensive manual, thanks a lot. Here is something I am struggling with and need some help with: I am trying to build a tanglegram (hope it's the right word in this case) of 4 gene trees from a segmented virus genome. I have followed the package manual as per subcap. 2.6 
but I am getting connecting lines not only between tips, but nodes as well.
Tree files and plot attached.

The code: 
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 
  ) 

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.
best wishes,
Alex
jingmen_s2_pool1.fasta.treefile
jingmen_s4_pool1.fasta.treefile
jingmen_s3_pool1.fasta.treefile
jingmen_s1_pool1.fasta.treefile
jmtv.png
Reply all
Reply to author
Forward
0 new messages