Skip to content

Commit

Permalink
added function extend_terminal_branches
Browse files Browse the repository at this point in the history
  • Loading branch information
caseywdunn committed Jul 16, 2017
1 parent b9b60c0 commit 94e181d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export(decompose_tree)
export(descendants)
export(difference_from_calibrated)
export(distance_from_tip)
export(extend_terminal_branches)
export(flip_bipartition)
export(get_bipartitions)
export(get_corresponding_nodes)
Expand Down
14 changes: 14 additions & 0 deletions R/utility_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -464,3 +464,17 @@ connecting_edges = function(phy, node_a, node_b){

return(edges)
}

#' Extends each terminal branch by specified length
#'
#' @param phy A phylogeny in ape::phylo format
#' @param x Amount to extend each branch by
#' @return A phylogeny in ape::phylo format
#' @export
extend_terminal_branches = function( phy, x ){

is_terminal = phy$edge[ , 2 ] %in% 1:length( phy$tip.label )
phy$edge.length[ is_terminal ] = phy$edge.length[ is_terminal ] + x
return( phy )

}
19 changes: 19 additions & 0 deletions man/extend_terminal_branches.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94e181d

Please sign in to comment.