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

flip doesn't work as expected #167

Closed
Xeonilian opened this issue Feb 20, 2018 · 1 comment
Closed

flip doesn't work as expected #167

Xeonilian opened this issue Feb 20, 2018 · 1 comment

Comments

@Xeonilian
Copy link

Hi Guangchuang,
Today my computer crashed and I reinstall R, Rstudio and all the packages. I found flip did werid things. After flipping sometimes, the branches were not evenly distribute in my own case. In the following case, the tree even overlaped. Please try this example.

set.seed(20180220)
randtree <- rcoal(20)
plot(randtree)
t <- ggtree(randtree, layout = "rectangular") + geom_tiplab() + geom_nodelab()
t$data$label <-  1:39
t
t1 <- flip(t, 33, 22) # no problem
t1
t2 <- flip(t1, 24, 23) # branches overlap
t2
t$data$y
t2$data$y

The sessioninfo for this result is

sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936

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

other attached packages:
[1] gtable_0.2.0 reshape2_1.4.3 ggtree_1.10.4 treeio_1.2.1 ggplot2_2.2.1 quantreg_5.35 SparseM_1.77
[8] picante_1.6-2 nlme_3.1-131.1 vegan_2.4-6 lattice_0.20-35 permute_0.9-4 ape_5.0

loaded via a namespace (and not attached):
[1] Rcpp_0.12.15 cluster_2.0.6 magrittr_1.5 MASS_7.3-48 munsell_0.4.3 colorspace_1.3-2
[7] rlang_0.1.6 stringr_1.2.0 plyr_1.8.4 tools_3.4.3 parallel_3.4.3 mgcv_1.8-23
[13] MatrixModels_0.4-1 digest_0.6.15 lazyeval_0.2.1 tibble_1.4.2 Matrix_1.2-12 purrr_0.2.4
[19] tidyr_0.8.0 glue_1.2.0 labeling_0.3 stringi_1.1.6 compiler_3.4.3 pillar_1.1.0
[25] rvcheck_0.0.9 scales_0.5.0 jsonlite_1.5

I tried on my Mac where I have not updated for a while, here flip works as I expected.
I can not say which one is the source, they all pretty old, see sessionInfo below.

R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] ggtree_1.8.1 treeio_1.0.2 gtable_0.2.0
[4] ggplot2_2.2.1 reshape2_1.4.2 quantreg_5.33
[7] SparseM_1.77 picante_1.6-2 nlme_3.1-131
[10] vegan_2.4-3 lattice_0.20-35 permute_0.9-4
[13] ape_4.1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.12 cluster_2.0.6 magrittr_1.5
[4] MASS_7.3-47 munsell_0.4.3 colorspace_1.3-2
[7] rlang_0.1.2 stringr_1.2.0 plyr_1.8.4
[10] tools_3.4.1 parallel_3.4.1 mgcv_1.8-18
[13] MatrixModels_0.4-1 lazyeval_0.2.0 tibble_1.3.3
[16] Matrix_1.2-10 tidyr_0.6.3 labeling_0.3
[19] stringi_1.1.5 compiler_3.4.1 rvcheck_0.0.9
[22] scales_0.4.1 jsonlite_1.5

I looked closer at ggtree. In the new version of flip a varieble yy is created. And value of y is changed afterwards.

yy <- df$y[-c(sp1, sp2)]
df$y[-c(sp1, sp2)] <- yy + ((min(sp2.df$y, na.rm = TRUE) - 
    max(yy)) - (min(yy) - max(sp1.df$y, na.rm = TRUE)))/2

I don't quite understand what these line do, but perhaps they are the source.

Actually I'm doing the final check before submission. I really hope it can work, then people get the same figure as in my paper.
Thank you very much for spending time on checking this issue.

Cheers, Xeonilian

@GuangchuangYu
Copy link
Member

fixed in v >= 1.10.5.

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