Visualize lineage tree using ggtree
3
0
Entering edit mode
yun YAN ▴ 20
@yun-yan-6355
Last seen 4.7 years ago
Canada

I was wondering is it possible to visualize tree structure, in particular the branch nodes are shown.

 

The example is from wikipedia (https://en.wikipedia.org/wiki/Newick_format) and tree in the newick format is: (A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F;

I can visualize tree by ggtree, but I did not know which parameters can highlight the branch nodes.

v <- '(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F;'

ggtree(read.tree(text=v)) + geom_tiplab() 

 

My motivation of using ggtree is to visualize lineage tree, e.g. C.elegans, thus I care more about branching nodes (e.g. E and F in the example) and their child nodes.

@YGC

Thanks,

Yun

 

 

 

ggtree lineage • 2.3k views
ADD COMMENT
2
Entering edit mode
Guangchuang Yu ★ 1.2k
@guangchuang-yu-5419
Last seen 27 days ago
China/Guangzhou/Southern Medical Univer…
root = 5
ggtree(read.tree(text=v)) + geom_point() + geom_text(aes(label=label), hjust=-.5) + geom_label2(aes(x=branch, label=branch.length, subset=(node != root))) -> p
rotate(p, root)

ADD COMMENT
0
Entering edit mode

Amazing ;-)

ADD REPLY
0
Entering edit mode
Guangchuang Yu ★ 1.2k
@guangchuang-yu-5419
Last seen 27 days ago
China/Guangzhou/Southern Medical Univer…
ggtree(read.tree(text=v)) + geom_point() + geom_text(aes(label=label), hjust=-.5)

the above code should work.

 

ADD COMMENT
0
Entering edit mode
v <- '((D,E)C,((((((((((((LONGGGGG,SHORT)LOVE, HATE)Y,Z)W,X)U,V)S,T)Q,R)O,P)L,M)I,J)H,K)F,G)B)A;'
ggtree(read.tree(text=v)) +
  # theme(plot.margin=unit(c(1,5,1.5,1.2),"cm")) +
  geom_point() +
  geom_text(aes(label=label), hjust=-.5)
plot(read.tree(text=v), show.node=TRUE, cex=.5)

 

The labels of end nodes are not displayed properly. Could you help me to set the correct parameter? I guess it might be `margin` but I still did not figure it out.

The default `plot` would not 'eat' the labels.

 

ADD REPLY
0
Entering edit mode

checkout the FAQ.

ADD REPLY

Login before adding your answer.

Traffic: 907 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