PoonLab / clustuneR

Implementing clustering algorithms on genetic data and finding optimal parameters through the performance of predictive growth models.
GNU General Public License v3.0
0 stars 0 forks source link

step.cluster fails to "step back" down path to meet bootstrap criterion #18

Closed ArtPoon closed 9 months ago

ArtPoon commented 10 months ago

The problem occurs here: https://github.com/PoonLab/clustuneR/blob/353d3fae1357de6eff597c61713e13e9465c6738/R/tree.clustering.R#L32-L49

I'm working with the na.nwk example file. If I set branch.thresh to 0.005 and boot.thresh to 0.5, then there are two nodes where the path stopping point has a bootstrap value below the threshold:

> i
[1] 1092 1608
> j <- 1092
> path.stop[,j]
        Node         Boot BranchLength       Height 
1.092000e+03 3.800000e-01 6.591797e-03 1.000000e+00 

The above tells us that the path goes no further than the terminal branch.

>     p <- t$path.info[[j]]
>     p.boots <- p["Boot", 1:path.stop["Height", j]]
>     new.h <- which(p.boots >= boot.thresh)[1]
> p.boots
Boot 
0.38
> new.h
<NA> 
  NA

I think this is an edge case because we will seldom choose such a strict branch (path) length threshold, but the outcome is that the column in path.stop is replaced with all NA values.

ArtPoon commented 9 months ago

I've refactored step.cluster and I don't think this is an issue anymore