YuLab-SMU / ProjectYulab

:next_track_button: Small coding tasks that enable you to participate in our development
33 stars 3 forks source link

introduce the `height` parameter in `collapse()` #4

Open GuangchuangYu opened 1 year ago

GuangchuangYu commented 1 year ago

This is a feature request posted on https://github.com/YuLab-SMU/ggtree/issues/409.

I have posted the requirement of this parameter, see https://github.com/YuLab-SMU/ggtree/issues/409#issuecomment-944034311.

In the same thread, there is a prototype by incorporating scaleClade() with collapse(), see https://github.com/YuLab-SMU/ggtree/issues/409#issuecomment-1069215382.

ZhaiJiaZhai commented 1 year ago

Hello, I have tried to reconstruct the course on http://yulab-smu.top/treedata-book/chapter6.html#collapsing-and-expanding-clade, and add a parameter height = NULL to ggtree::collapse() to see how it work.

This is the problem.

p2 <- p + geom_tiplab() node <- 17 collapse(p2, node, 'max', height = 1) %>% expand(node)

Then, it return "Ignoring unknown parameters: height" I have updata my ggtree to v3.4.4, just now.

ZhaiJiaZhai commented 1 year ago

另外我尝试了结合使用scaleClade() 和 collapse(), https://github.com/YuLab-SMU/ggtree/issues/409#issuecomment-1069215382 相较于说明文档做出了更好的等比缩小,实现了宽度统一。 666 两个三角因为缩放方式的原因仍存在细微区别,这个区别会因为原本形状的差异而更突出。

GuangchuangYu commented 1 year ago

Then, it return "Ignoring unknown parameters: height"

so me the code.

ZhaiJiaZhai commented 1 year ago

library(ggtree) nwk <- system.file("extdata", "sample.nwk", package="treeio") tree <- read.tree(nwk) p <- ggtree(tree) + geom_tiplab() node <- 17 collapse(p, node, 'max', height = 1) %>% expand(node)

GuangchuangYu commented 1 year ago

you need to modify the collapse() function to introduce this new parameter.