YuLab-SMU/tidytree

ToDataFrameTable does not extract internal nodes

kylekimler opened this issue · 1 comments

Hi!
I'm using the Node class for most tree manipulations. I propagate annotations up the tree from the leaves using the vignette's methods, e.g.

t <- Traverse(divtree, traversal = "post-order")
Do(t, function(x) x$n <- Aggregate(node = x, attribute = "n", aggFun = sum))

and

divtree$Do(function(node) node$samples <- unique(unlist(node$samples)))

I want to merge nodes of a binary tree created this way by pruning nodes that don't meet a threshold for several criteria, then keeping nodes that contain unique ids (currently held as a list per node). Unfortunately, pruning pushes many ids into internal nodes, and I do not want to agglomerate them with children from the second branch (which achieves a higher resolution).
I would like to obtain these nodes in a ToDataFrameTable conversion, but ToDataFrameTable currently leaves them out, and I have to remove them from my downstream analysis. Is there any way to keep internal nodes? Especially those that contain unique attributes?

Thank you!!
Kyle Kimler

I realize now I should've posted this to data.tree, not here! Sorry about that