Points on edges

67 views
Skip to first unread message

Holly Arnold

unread,
Feb 25, 2021, 3:22:59 PM2/25/21
to ggtree
Hello,

I'm working with output from the Evolutionary Placement Algorithm (https://cme.h-its.org/exelixis/web/software/epa/index.html). This algorithm allows a user to "place" a set of reads onto a reference tree resulting in a list of "placements" along edges of a phylogenetic tree. Each placement has a mapping to which particular edge it has been placed along with a distance from the ancestral node for placement. I'm wondering if geom_point() has been extended to edges so that perhaps I could call geom_point() with a list of edges and distance from ancestor node along that edge. Then points could be put along the edges of the tree rather than solely at the nodes. 

+Holly

Chris Owen

unread,
Feb 26, 2021, 7:38:50 AM2/26/21
to ggtree
Hi Holly,

That's very doable. First plot your tree, extract the data, find your node's x-y coordinates, then plot a custom geom_point() using the node's (adjusted x) coordinates. As such:

tree <- ggtree(phy)
tree.dat <- tree$data
tree.dat[tree.dat$node[<node number>], c("x", "y")] # prints node of interest coords
tree + geom_point(data=data.frame(x=<adjusted node x>, y=<node y>), aes(x=x, y=y) # use above coords with adjusted x to move point along edge

Cheers,
Chris
Reply all
Reply to author
Forward
0 new messages