data.tree icon indicating copy to clipboard operation
data.tree copied to clipboard

ToDataFrameTable does not extract internal nodes

Open kylekimler opened this issue 3 years ago • 0 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 (including unique "sample" id's under which many replicates exist, and lists of their replicates), 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)))

Do(t, function(x) x$ids <- Aggregate(node = x, attribute = "ids", aggFun = c))

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 replicate ids (currently held as a list per node as in the last line above). Unfortunately, pruning pushes many ids into internal nodes, and I do not want to agglomerate them with children from the second branch (I see the child samples as achieving a higher resolution). I would like to obtain these internal 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

kylekimler avatar Feb 16 '22 11:02 kylekimler