Skip to content

Commit

Permalink
BUG FIX: only convert non-zero length branches to same value in alter…
Browse files Browse the repository at this point in the history
…nate tree for RPD, RPE
  • Loading branch information
joelnitta committed Oct 13, 2021
1 parent e6ed4a0 commit 50ed6e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/cpr_rand_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ cpr_rand_test <- function(comm, phy, null_model = "independentswap", n_reps = 10
# Prepare for calculations ----
# Make alternative tree with equal branch lengths
phy_alt <- phy
phy_alt$edge.length <- rep(x = 1, times = length(phy_alt$edge.length))
# convert **non-zero** branch lengths to same value (1)
non_zero_branches <- purrr::map_lgl(phy_alt$edge.length, ~!isTRUE(all.equal(., 0)))
phy_alt$edge.length[non_zero_branches] <- rep(x = 1, times = length(phy_alt$edge.length[non_zero_branches]))
# rescale so total phy length is 1
phy_alt$edge.length <- phy_alt$edge.length / sum(phy_alt$edge.length)
# rescale original phy so total length is 1
Expand Down

0 comments on commit 50ed6e9

Please sign in to comment.