How to use scaleClade and collapse for multiple clades

450 views
Skip to first unread message

Mansa Srivastav

unread,
Feb 2, 2022, 3:55:35 PM2/2/22
to ggtree
Hi,

First of all thank you for making this package. Its awesome.
I am new to ggtree and I probably have a simple question.

I want to combine scaleClade with collapse function to have small and not large triangles for the collapsed clades and I want to do it for 11 clades.
When I scale down one clade and then collapse it, it works fine but when I try to do it on another clade, I get an error.
Do you have any suggestion how to resolve it?

Here's my code and the error in the end and I have attached the tree:
phy <- read.tree("tree.tree")
y <- ggtree(phy, colour="yellow")+theme_tree("black")

y <- scaleClade(y, 122, 0.3)%>% collapse(122, 'min', fill="#4B0092")
y <- scaleClade(y, 114, 0.3)%>% collapse(114, 'min', fill="#D41159")
#error:Error in if (sum(ii) > 0) { : missing value where TRUE/FALSE needed

The class of y remains same after reading with ggtree and after running the first scaleClade and collpase command. So, I am not sure what's the root of the error.

Thank you!

Yu, Guangchuang

unread,
Jun 11, 2022, 5:23:53 AM6/11/22
to Mansa Srivastav, ggtree
can you provide the example tree file?

--
1. G Yu*. Using ggtree to visualize data on tree-like structures. Current Protocols in Bioinformatics. 2020, 69:e96. https://doi.org/10.1002/cpbi.96
2. LG Wang, TTY Lam, S Xu, Z Dai, L Zhou, T Feng, P Guo, CW Dunn, BR Jones, T Bradley, H Zhu, Y Guan, Y Jiang, G Yu*. treeio: an R package for phylogenetic tree input and output with richly annotated and associated data. Molecular Biology and Evolution. 2020, 37(2):599-603. http://dx.doi.org/10.1093/molbev/msz240
3. G Yu*, TTY Lam, H Zhu, Y Guan*. Two methods for mapping and visualizing associated data on phylogeny using ggtree. Molecular Biology and Evolution, 2018, 35(2):3041-3043. https://doi.org/10.1093/molbev/msy194
4. G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data, Methods in Ecology and Evolution, 2017, 8(1):28-36. https://doi.org/10.1111/2041-210X.12628
5. Book: https://yulab-smu.top/treedata-book/
---
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/1a288008-a008-4b42-a2c6-f3afa42cb5aan%40googlegroups.com.


--
--~--~---------~--~----~------------~-------~--~----~
Guangchuang Yu PhD
Professor, Director
Department of Bioinformatics
School of Basic Medical Sciences
Southern Medical University
Guangzhou, China
-~----------~----~----~----~------~----~------~--~---

Jan Strauss

unread,
Jan 6, 2023, 6:19:28 AM1/6/23
to ggtree
Hi,

I'm running into the same problem and have reported an issue at https://github.com/YuLab-SMU/ggtree/issues/534.
It includes a reproducible example with an example tree file.

I really appreciate any help you can provide.

Reply all
Reply to author
Forward
0 new messages