SCM

[#582] make identify method work for phylo4 objects

Date:
2009-08-18 19:25
Priority:
3
State:
Open
Submitted by:
Ben Bolker (bbolker)
Assigned to:
Peter Cowan (pdc)
Target Version:
v. 0.6
Summary:
make identify method work for phylo4 objects

Detailed description
will this be tricky with grid graphics?

Comments:

Message  ↓
Date: 2009-08-18 20:13
Sender: Peter Cowan

This is actually on my todo list. And, yes I think it will be fairly difficult.

Here's my first hack at it from a while ago. The problem is that the grid.locator is relative to the last viewport exited, which may or may not be the tree. I think with some improvements to the plotting code this will get there, but it's a little ways off.

myfun <- function(phy) {
plot(phy)
loc <- phyloXXYY(phy)
tLabs <- tipLabels(loc$phy)
click <- grid.locator(unit = 'npc')
clickY <- loc$yy < as.numeric(click$y) + 0.05 & loc$yy > as.numeric(click$y) - 0.05
clickX <- loc$xx < as.numeric(click$x) + 0.05 & loc$xx > as.numeric(click$x) - 0.05
if(sum(clickY & clickX) == 1) {
idNode <- nodeId(loc$phy, which = 'all')[clickY & clickX]
print(dtips <- names(descendants(loc$phy, node = idNode, which = 'tips')))
print(tips_to_drop <- tLabs[!(tLabs %in% dtips)])
phy <- DropTip(loc$phy, tips_to_drop)
myfun(phy)

} else {stop('problems')}
}

Attached Files:

Changes

Field Old Value Date By
Target VersionNone2009-08-18 20:13pdc
assigned_tonone2009-08-18 20:13pdc
Thanks to:
Vienna University of Economics and Business Powered By FusionForge