ggtree - trouble displaying longer label names
1
2
Entering edit mode
Alan Smith ▴ 150
@alan-smith-5987
Last seen 7.0 years ago
United States

Hello,

Trying ggtree for the first time, it is very impressive.

However, I'm having trouble to get longer labels displayed

library(ggtree)
tree<-read.tree(text="(Organism1.006G249400.1:0.03977,(Organism2.022118m:0.01337,(Organism3.J34265.1:0.00284,Organism4.G02633.1:0.00468)0.51:0.0104):0.02469);")
jpeg("ggtree_phyltree.jpg")
ggtree(tree) + geom_tiplab(size=2)
dev.off()

And tried this:
ggtree(tree, aes(color=branch.length)) +
scale_color_continuous(low="green", high="red") +
geom_text(aes(label=label), size=2, color="purple", hjust=-0.3) +
        theme(legend.position="bottom") + geom_text(aes(label=node))

but it only displays till "Organism".  Also tried adjusting margins with
mar() and par(mai=c(2,0.82,0.82,6)) still no luck.

Don't know how to go about getting the full Gene names displayed on the
tree.

Thanks in advance,
Alan

sessionInfo()

R version 3.2.2 Patched (2015-08-16 r69094)
Platform: x86_64-suse-linux-gnu (64-bit)
Running under: openSUSE 13.1 (Bottle) (x86_64)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] ggplot2_1.0.1 ggtree_1.0.20

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.1         XVector_0.8.0       magrittr_1.5
 [4] MASS_7.3-44         BiocGenerics_0.14.0 zlibbioc_1.14.0
 [7] IRanges_2.2.7       munsell_0.4.2       colorspace_1.2-6
[10] EBImage_4.10.1      lattice_0.20-33     ape_3.3
[13] jpeg_0.1-8          stringr_1.0.0       plyr_1.8.3
[16] tools_3.2.2         parallel_3.2.2      grid_3.2.2
[19] nlme_3.1-122        gtable_0.1.2        png_0.1-7
[22] abind_1.4-3         digest_0.6.8        gridExtra_2.0.0
[25] reshape2_1.4.1      S4Vectors_0.6.5     fftwtools_0.9-7
[28] tiff_0.1-5          labeling_0.3        stringi_0.5-5
[31] scales_0.3.0        Biostrings_2.36.4   stats4_3.2.2
[34] locfit_1.5-9.1      jsonlite_0.9.17     proto_0.3-10
 

ggtree • 12k views
ADD COMMENT
3
Entering edit mode
Guangchuang Yu ★ 1.2k
@guangchuang-yu-5419
Last seen 4 hours ago
China/Guangzhou/Southern Medical Univer…

This is because the units are in two different spaces (data & pixel).

you can use xlim to get more space for text.

try:

ggtree(tree) + geom_tiplab() + ggplot2::xlim(0, 0.06)

 

ADD COMMENT
0
Entering edit mode
ADD REPLY
0
Entering edit mode

Thanks a lot. It worked. 

ADD REPLY

Login before adding your answer.

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