fixed R check

guangchuang yu authored on 11/04/2017 01:56:07
Showing 24 changed files

 ... ... @@ -172,9 +172,9 @@ layout.unrooted <- function(tree, branch.length="branch.length", layout.method=" 172 172   173 173  ##' 'Equal-angle layout algorithm for unrooted trees' 174 174  ##' 175 -##' @references  175 +##' @references 176 176  ##' "Inferring Phylogenies" by Joseph Felsenstein. 177 -##'  177 +##' 178 178  ##' @title layoutEqualAngle 179 179  ##' @param tree phylo object 180 180  ##' @param branch.length set to 'none' for edge length of 1. Otherwise the phylogenetic tree edge length is used. ... ... @@ -183,9 +183,9 @@ layoutEqualAngle <- function(tree, branch.length ){ 183 183  root <- getRoot(tree) 184 184  # Convert Phylo tree to data.frame. 185 185  df <- as.data.frame.phylo_(tree) 186 -  186 + 187 187  # NOTE: Angles (start, end, angle) are in half-rotation units (radians/pi or degrees/180) 188 -  188 + 189 189  # create and assign NA to the following fields. 190 190  df$x <- NA 191 191  df$y <- NA ... ... @@ -198,75 +198,75 @@ layoutEqualAngle <- function(tree, branch.length ){ 198 198  df[root, "start"] <- 0 # 0-degrees 199 199  df[root, "end"] <- 2 # 360-degrees 200 200  df[root, "angle"] <- 0 # Angle label. 201 -  201 + 202 202  N <- getNodeNum(tree) 203 203   204 204  # Get number of tips for each node in tree. 205 205  nb.sp <- sapply(1:N, function(i) length(get.offspring.tip(tree, i))) 206 206  # Get list of node id's. 207 207  nodes <- getNodes_by_postorder(tree) 208 -  209 - for(curNode in nodes) {  208 + 209 + for(curNode in nodes) { 210 210  # Get number of tips for current node. 211 211  curNtip <- nb.sp[curNode] 212 212  # Get array of child node indexes of current node. 213 213  children <- getChild(tree, curNode) 214 -  214 + 215 215  # Get "start" and "end" angles of a segment for current node in the data.frame. 216 216  start <- df[curNode, "start"] 217 217  end <- df[curNode, "end"] 218 -  218 + 219 219  if (length(children) == 0) { 220 220  ## is a tip 221 221  next 222 222  } 223 -  223 + 224 224  for (i in seq_along(children)) { 225 225  child <- children[i] 226 226  # Get the number of tips for child node. 227 - ntip.child <- nb.sp[child]  228 -  227 + ntip.child <- nb.sp[child] 228 + 229 229  # Calculated in half radians. 230 230  # alpha: angle of segment for i-th child with ntips_ij tips. 231 231  # alpha = (left_angle - right_angle) * (ntips_ij)/(ntips_current) 232 232  alpha <- (end - start) * ntip.child / curNtip 233 233  # beta = angle of line from parent node to i-th child. 234 234  beta <- start + alpha / 2 235 -  235 + 236 236  if (branch.length == "none") { 237 237  length.child <- 1 238 238  } else { 239 239  length.child <- df[child, "length"] 240 240  } 241 -  241 + 242 242  # update geometry of data.frame. 243 243  # Calculate (x,y) position of the i-th child node from current node. 244 244  df[child, "x"] <- df[curNode, "x"] + cospi(beta) * length.child 245 245  df[child, "y"] <- df[curNode, "y"] + sinpi(beta) * length.child 246 - # Calculate orthogonal angle to beta.  246 + # Calculate orthogonal angle to beta. 247 247  df[child, "angle"] <- -90 - 180 * beta * sign(beta - 1) 248 248  # Update the start and end angles of the childs segment. 249 249  df[child, "start"] <- start 250 250  df[child, "end"] <- start + alpha 251 251  start <- start + alpha 252 - }  252 + } 253 253   254 254  } 255 -  255 + 256 256  return(df) 257 -  257 + 258 258  } 259 259   260 260  ##' Equal daylight layout method for unrooted trees. 261 -##'  261 +##' 262 262  ##' #' @title 263 263  ##' @param tree phylo object 264 264  ##' @param branch.length set to 'none' for edge length of 1. Otherwise the phylogenetic tree edge length is used. 265 265  ##' @return tree as data.frame with equal angle layout. 266 -##' @references  266 +##' @references 267 267  ##' The following aglorithm aims to implement the vague description of the "Equal-daylight Algorithm" 268 268  ##' in "Inferring Phylogenies" pp 582-584 by Joseph Felsenstein. 269 -##'  269 +##' 270 270  ##'  271 271  ##' Leafs are subtrees with no children 272 272  ##' Initialise tree using equal angle algorithm ... ... @@ -274,14 +274,14 @@ layoutEqualAngle <- function(tree, branch.length ){ 274 274  ##' 275 275  ##' nodes = get list of nodes in tree_df breadth-first 276 276  ##' nodes = remove tip nodes. 277 -##'  277 +##' 278 278  ##'  279 279  layoutDaylight <- function( tree, branch.length ){ 280 280   281 281  # How to set optimal 282 282  MAX_COUNT <- 100 283 283  MINIMUM_AVERAGE_ANGLE_CHANGE <- 0.01 284 -  284 + 285 285   286 286  # Initialize tree. 287 287  tree_df <- layoutEqualAngle(tree, branch.length) ... ... @@ -290,16 +290,16 @@ layoutDaylight <- function( tree, branch.length ){ 290 290  # Get list of node id's. 291 291  #nodes <- getNodes_by_postorder(tree) 292 292  # nodes <- GetSubtree.df(tree_df, root) 293 -  293 + 294 294  # Get list of internal nodes 295 295  #nodes <- tree_df[tree_df$IsTip != TRUE]$nodes 296 -  296 + 297 297  nodes <- getNodesBreadthFirst.df(tree_df) 298 298  # select only internal nodes 299 299  internal_nodes <- tree_df[!tree_df$isTip,]$node 300 300  # Remove tips from nodes list, but keeping order. 301 301  nodes <- intersect(nodes, internal_nodes) 302 -  302 + 303 303  i <- 1 304 304  ave_change <- 1.0 305 305  while( i <= MAX_COUNT & ave_change > MINIMUM_AVERAGE_ANGLE_CHANGE ){ ... ... @@ -307,75 +307,75 @@ layoutDaylight <- function( tree, branch.length ){ 307 307   308 308  # Reset max_change after iterating over tree. 309 309  total_max <- 0.0 310 -  310 + 311 311  # for node in nodes { 312 312  for( j in seq_along(nodes)){ 313 313  currentNode_id <- nodes[j] 314 -  314 + 315 315  result <- applyLayoutDaylight(tree_df, currentNode_id) 316 316  tree_df <- result$tree 317 317  total_max <- total_max + result$max_change 318 -  318 + 319 319  } 320 -  320 + 321 321  ave_change <- total_max / length(nodes) 322 -  322 + 323 323  cat('Average angle change', ave_change,'\n') 324 -  324 + 325 325  i <- i + 1 326 326  } 327 -  327 + 328 328  return(tree_df) 329 -  329 + 330 330  } 331 331   332 332  ##' Apply the daylight alorithm to adjust the spacing between the subtrees and tips of the 333 333  ##' specified node. 334 -##'  334 +##' 335 335  ##' @title applyLayoutDaylight 336 336  ##' @param df tree data.frame 337 337  ##' @param node_id is id of the node from which daylight is measured to the other subtrees. 338 -##' @return list with tree data.frame with updated layout using daylight algorithm and max_change angle . 339 -##'  340 -##' 341 -##'  342 -##' for node in nodes { 343 -##' if node is a leaf { 344 -##' next 345 -##' } 346 -##'  347 -##' subtrees = get subtrees of node 348 -##'  349 -##' for i-th subtree in subtrees { 350 -##' [end, start] = get left and right angles of tree from node id. 351 -##' angle_list[i, 'left'] = end 352 -##' angle_list[i, 'beta'] = start - end # subtree arc angle 353 -##' angle_list[i, 'index'] = i-th # index of subtree/leaf  354 -##' } 355 -##' 356 -##' sort angle_list by 'left' column in ascending order. 357 -##' 358 -##' D = 360 - sum( angle_list['beta'] ) # total daylight angle 359 -##' d = D / |subtrees| # equal daylight angle. 360 -##'  361 -##' new_L = left angle of first subtree. 362 -##' 363 -##' for n-th row in angle_list{ 364 -##' # Calculate angle to rotate subtree/leaf to create correct daylight angle. 365 -##' new_left_angle = new_left_angle + d + angle_list[n, 'beta'] 366 -##' Calculate the difference between the old and new left angles. 367 -##' adjust_angle = new_left_angle - angle_list[n, 'left']  368 -##'  369 -##' index = angle_list['index'] 370 -##' rotate subtree[index] wrt n-th node by adjust_angle 371 -##' } 372 -##' } 373 -##' } 374 -##'  338 +##' @return list with tree data.frame with updated layout using daylight algorithm and max_change angle. 339 +## 340 +## 341 +##  342 +## for node in nodes { 343 +## if node is a leaf { 344 +## next 345 +## } 346 +## 347 +## subtrees = get subtrees of node 348 +## 349 +## for i-th subtree in subtrees { 350 +## [end, start] = get left and right angles of tree from node id. 351 +## angle_list[i, 'left'] = end 352 +## angle_list[i, 'beta'] = start - end # subtree arc angle 353 +## angle_list[i, 'index'] = i-th # index of subtree/leaf 354 +## } 355 +## 356 +## sort angle_list by 'left' column in ascending order. 357 +## 358 +## D = 360 - sum( angle_list['beta'] ) # total daylight angle 359 +## d = D / |subtrees| # equal daylight angle. 360 +## 361 +## new_L = left angle of first subtree. 362 +## 363 +## for n-th row in angle_list{ 364 +## # Calculate angle to rotate subtree/leaf to create correct daylight angle. 365 +## new_left_angle = new_left_angle + d + angle_list[n, 'beta'] 366 +## Calculate the difference between the old and new left angles. 367 +## adjust_angle = new_left_angle - angle_list[n, 'left'] 368 +## 369 +## index = angle_list['index'] 370 +## rotate subtree[index] wrt n-th node by adjust_angle 371 +## } 372 +## } 373 +## } 374 +##  375 375  applyLayoutDaylight <- function(df, node_id ){ 376 -  376 + 377 377  max_change <- 0.0 378 -  378 + 379 379  # Get lists of node ids for each subtree, including rest of unrooted tree. 380 380  subtrees <- getSubtreeUnrooted.df(df, node_id) 381 381  angle_list <- data.frame(left=numeric(0), beta=numeric(0), subtree_id=integer(0) ) ... ... @@ -384,14 +384,14 @@ applyLayoutDaylight <- function(df, node_id ){ 384 384  if(length(subtrees) <= 2){ 385 385  return( list(tree = df, max_change = max_change) ) 386 386  } 387 -  387 + 388 388  # Find start and end angles for each subtree. 389 389  # subtrees = get subtrees of node 390 390  # for i-th subtree in subtrees { 391 391  for (i in seq_along(subtrees) ) { 392 392  subtree <- subtrees[[i]] 393 393  # [end, start] = get start and end angles of tree. 394 -  394 + 395 395  angles <- getTreeArcAngles(df, node_id, subtree) 396 396  angle_list[ i, 'subtree_id'] <- i 397 397  angle_list[ i, 'left'] <- angles['left'] ... ... @@ -399,15 +399,15 @@ applyLayoutDaylight <- function(df, node_id ){ 399 399  # If subtree arc angle is -ve, then + 2 (360). 400 400  if(angle_list[ i, 'beta'] < 0 ){ 401 401  angle_list[ i, 'beta'] <- angle_list[ i, 'beta'] + 2 402 - }  402 + } 403 403  } 404 404  # sort angle_list by 'left angle' column in ascending order. 405 405  angle_list <- angle_list[with(angle_list, order(left)), ] 406 406  # D = 360 - sum( angle_list['beta'] ) # total day 407 407  # d = D / |subtrees| # equal daylight angle. 408 - total_daylight <- 2 - colSums(angle_list['beta'])  408 + total_daylight <- 2 - colSums(angle_list['beta']) 409 409  d <- total_daylight / length(subtrees) 410 -  410 + 411 411  # Initialise new left-angle as first subtree left-angle. 412 412  new_left_angle <- angle_list[1, 'left'] 413 413   ... ... @@ -419,25 +419,25 @@ applyLayoutDaylight <- function(df, node_id ){ 419 419  new_left_angle <- new_left_angle + d + angle_list[i, 'beta'] 420 420  # Calculate the difference between the old and new left angles. 421 421  adjust_angle <- new_left_angle - angle_list[i, 'left'] 422 -  422 + 423 423  max_change <- max(max_change, abs(adjust_angle)) 424 424  #cat('Adjust angle:', abs(adjust_angle), ' Max change:', max_change ,'\n') 425 -  425 + 426 426  # rotate subtree[index] wrt current node 427 427  subtree_id <- angle_list[i, 'subtree_id'] 428 428  subtree_nodes <- subtrees[[subtree_id]]$subtree 429 429  # update tree_df for all subtrees with rotated points. 430 430  df <- rotateTreePoints.df(df, node_id, subtree_nodes, adjust_angle) 431 431  } 432 -  433 - return( list(tree = df, max_change = max_change) )  434 -  432 + 433 + return( list(tree = df, max_change = max_change) ) 434 + 435 435  } 436 436   437 437   438 -##' Find the right (clockwise rotation, angle from +ve x-axis to furthest subtree nodes) and  438 +##' Find the right (clockwise rotation, angle from +ve x-axis to furthest subtree nodes) and 439 439  ##' left (anti-clockwise angle from +ve x-axis to subtree) 440 -##'  440 +##' 441 441  ##' @title getTreeArcAngles 442 442  ##' @param df tree data.frame 443 443  ##' @param origin_id node id from which to calculate left and right hand angles of subtree. ... ... @@ -448,7 +448,7 @@ getTreeArcAngles <- function(df, origin_id, subtree) { 448 448  theta_child <- 0.0 449 449  subtree_root_id <- subtree$node 450 450  subtree_node_ids <- subtree$subtree 451 -  451 + 452 452  # Initialise angle from origin node to parent node. 453 453  # If subtree_root_id is child of origin_id 454 454  if( any(subtree_root_id == getChild.df(df, origin_id)) ){ ... ... @@ -457,22 +457,22 @@ getTreeArcAngles <- function(df, origin_id, subtree) { 457 457  # get the real root of df tree to initialise left and right angles. 458 458  theta_parent <- getNodeAngle.df(df, origin_id, getRoot.df(df)) 459 459  } 460 -  460 + 461 461  # create vector with named columns 462 462  # left-hand and right-hand angles between origin node and the extremities of the tree nodes. 463 463  arc <- c('left' = theta_parent, 'right' = theta_parent) 464 -  464 + 465 465  # Subtree has to have 1 or more nodes to compare. 466 466  if (length(subtree_node_ids) == 0 ){ 467 467  return(0) 468 - }  468 + } 469 + 469 470   470 -  471 471  # Remove tips from nodes list, but keeping order. 472 472  # internal_nodes <- df[!df$isTip,]$node 473 473  # subtree_node_ids <- intersect(subtree_node_ids, internal_nodes) 474 -  475 -  474 + 475 + 476 476  # Calculate the angle from the origin node to each child node. 477 477  # Moving from parent to children in depth-first traversal. 478 478  for( i in seq_along(subtree_node_ids) ){ ... ... @@ -482,9 +482,9 @@ getTreeArcAngles <- function(df, origin_id, subtree) { 482 482  if(isTip.df(df, parent_id) ){ next } 483 483   484 484  theta_parent <- getNodeAngle.df(df, origin_id, parent_id) 485 -  485 + 486 486  children_ids <- getChild.df(df, parent_id) 487 -  487 + 488 488  for( j in seq_along(children_ids)){ 489 489  #delta_x <- df[subtree_node_id, 'x'] - df[origin_id, 'x'] 490 490  #delta_y <- df[subtree_node_id, 'y'] - df[origin_id, 'y'] ... ... @@ -494,7 +494,7 @@ getTreeArcAngles <- function(df, origin_id, subtree) { 494 494  if( child_id == origin_id ){ 495 495  next 496 496  } 497 -  497 + 498 498  theta_child <- getNodeAngle.df(df, origin_id, child_id) 499 499   500 500  # Skip if child node is already inside arc. ... ... @@ -505,8 +505,8 @@ getTreeArcAngles <- function(df, origin_id, subtree) { 505 505  # child node inside arc. 506 506  next 507 507  } 508 -  509 -  508 + 509 + 510 510  delta <- theta_child - theta_parent 511 511  delta_adj <- delta 512 512  # Correct the delta if parent and child angles cross the 180/-180 half of circle. ... ... @@ -517,12 +517,12 @@ getTreeArcAngles <- function(df, origin_id, subtree) { 517 517  }else if( delta < -1){ # Edge between parent and child cross upper and lower quadrants of cirlce 518 518  delta_adj <- delta + 2 # delta' = delta - 360 519 519  } 520 -  520 + 521 521  theta_child_adj <- theta_child 522 522   523 523  # If angle change from parent to node is positive (anti-clockwise), check left angle 524 524  if(delta_adj > 0){ 525 - # If child/parent edges cross the -180/180 quadrant (angle between them is > 180),  525 + # If child/parent edges cross the -180/180 quadrant (angle between them is > 180), 526 526  # check if right angle and child angle are different signs and adjust if needed. 527 527  if( abs(delta) > 1){ 528 528  if( arc['left'] > 0 & theta_child < 0){ ... ... @@ -531,14 +531,14 @@ getTreeArcAngles <- function(df, origin_id, subtree) { 531 531  theta_child_adj <- theta_child - 2 532 532  } 533 533  } 534 -  534 + 535 535  # check if left angle of arc is less than angle of child. Update if true. 536 536  if( arc['left'] < theta_child_adj ){ 537 537  arc['left'] <- theta_child 538 538  } 539 - # If angle change from parent to node is negative (clockwise), check right angle  539 + # If angle change from parent to node is negative (clockwise), check right angle 540 540  }else if(delta_adj < 0){ 541 - # If child/parent edges cross the -180/180 quadrant (angle between them is > 180),  541 + # If child/parent edges cross the -180/180 quadrant (angle between them is > 180), 542 542  # check if right angle and child angle are different signs and adjust if needed. 543 543  if( abs(delta) > 1){ 544 544  # Else change in angle from parent to child is negative, then adjust child angle if right angle is a different sign. ... ... @@ -551,20 +551,20 @@ getTreeArcAngles <- function(df, origin_id, subtree) { 551 551  # check if right angle of arc is greater than angle of child. Update if true. 552 552  if( arc['right'] > theta_child_adj ){ 553 553  arc['right'] <- theta_child 554 - }  555 -  554 + } 555 + 556 556  } 557 557  } 558 558   559 - }  559 + } 560 560  # Convert arc angles of [1, -1] to [2,0] domain. 561 561  arc[arc<0] <- arc[arc<0] + 2 562 562  return(arc) 563 -  563 + 564 564  } 565 565   566 566  ##' Rotate the points in a tree data.frame around a pivot node by the angle specified. 567 -##'  567 +##' 568 568  ##' @title rotateTreePoints.data.fram 569 569  ##' @param df tree data.frame 570 570  ##' @param pivot_node is the id of the pivot node. ... ... @@ -575,7 +575,7 @@ rotateTreePoints.df <- function(df, pivot_node, nodes, angle){ 575 575  # Rotate nodes around pivot_node. 576 576  # x' = cos(angle)*delta_x - sin(angle)*delta_y + delta_x 577 577  # y' = sin(angle)*delta_x + cos(angle)*delta_y + delta_y 578 -  578 + 579 579  cospitheta <- cospi(angle) 580 580  sinpitheta <- sinpi(angle) 581 581  for(node in nodes){ ... ... @@ -584,7 +584,7 @@ rotateTreePoints.df <- function(df, pivot_node, nodes, angle){ 584 584  delta_y <- df[node, 'y'] - df[pivot_node, 'y'] 585 585  df[node, 'x'] <- cospitheta * delta_x - sinpitheta * delta_y + df[pivot_node, 'x'] 586 586  df[node, 'y'] <- sinpitheta * delta_x + cospitheta * delta_y + df[pivot_node, 'y'] 587 -  587 + 588 588  # Update label angle if not root node. 589 589  # get parent 590 590  parent_id <- getParent.df(df, node) ... ... @@ -596,13 +596,13 @@ rotateTreePoints.df <- function(df, pivot_node, nodes, angle){ 596 596  df[node, 'angle'] <- -90 - 180 * theta_parent_child * sign(theta_parent_child - 1) 597 597  } 598 598  } 599 -  599 + 600 600  } 601 601  return(df) 602 602  } 603 603   604 604  ##' Get the angle between the two nodes specified. 605 -##'  605 +##' 606 606  ##' @title getNodeAngle.df 607 607  ##' @param df tree data.frame 608 608  ##' @param origin_node_id origin node id number ... ... @@ -622,13 +622,13 @@ getNodeAngle.df <- function(df, origin_node_id, node_id){ 622 622   623 623   624 624  ##' Get all children of node from tree, including start_node. 625 -##'  625 +##' 626 626  ##' @title getSubtree 627 627  ##' @param tree ape phylo tree object 628 628  ##' @param node is the tree node id from which the tree is derived. 629 629  ##' @return list of all child node id's from starting node. 630 630  getSubtree <- function(tree, node){ 631 -  631 + 632 632  subtree <- c(node) 633 633  i <- 1 634 634  while( i <= length(subtree)){ ... ... @@ -640,13 +640,12 @@ getSubtree <- function(tree, node){ 640 640  return(subtree) 641 641  } 642 642   643 -# Get all children of node from df tree using breath-first. 644 -# 643 +##' Get all children of node from df tree using breath-first. 644 +##' 645 645  ##' @title GetSubtree.df 646 646  ##' @param df tree data.frame 647 647  ##' @param node id of starting node. 648 648  ##' @return list of all child node id's from starting node. 649 -##' @examples 650 649  GetSubtree.df <- function(df, node){ 651 650  subtree <- c(node) 652 651  i <- 1 ... ... @@ -659,9 +658,9 @@ GetSubtree.df <- function(df, node){ 659 658  return(subtree) 660 659  } 661 660   662 -##' Get all subtrees of specified node. This includes all ancestors and relatives of node and  661 +##' Get all subtrees of specified node. This includes all ancestors and relatives of node and 663 662  ##' return named list of subtrees. 664 -##'  663 +##' 665 664  ##' @title GetSubtreeUnrooted 666 665  ##' @param tree ape phylo tree object 667 666  ##' @param node is the tree node id from which the subtrees are derived. ... ... @@ -672,17 +671,17 @@ GetSubtreeUnrooted <- function(tree, node){ 672 671  # return NA 673 672  return(NA) 674 673  } 675 -  674 + 676 675  subtrees <- list() 677 -  676 + 678 677  # get subtree for each child node. 679 678  children_ids <- getChild(tree, node) 680 -  679 + 681 680  remaining_nodes <- getNodes_by_postorder(tree) 682 681  # Remove current node from remaining_nodes list. 683 682  remaining_nodes <- setdiff(remaining_nodes, node) 684 -  685 -  683 + 684 + 686 685  for( child in children_ids ){ 687 686  # Append subtree nodes to list if not 0 (root). 688 687  subtree <- getSubtree(tree, child) ... ... @@ -690,7 +689,7 @@ GetSubtreeUnrooted <- function(tree, node){ 690 689  # remove subtree nodes from remaining nodes. 691 690  remaining_nodes <- setdiff(remaining_nodes, as.integer(unlist(subtrees[[length(subtrees)]]['subtree']) )) 692 691  } 693 -  692 + 694 693  # The remaining nodes that are not found in the child subtrees are the remaining subtree nodes. 695 694  # ie, parent node and all other nodes. We don't care how they are connect, just their ids. 696 695  parent_id <- getParent(tree, node) ... ... @@ -698,7 +697,7 @@ GetSubtreeUnrooted <- function(tree, node){ 698 697  if( parent_id != 0 & length(remaining_nodes) >= 1){ 699 698  subtrees[[length(subtrees)+1]] <- list( node = parent_id, subtree = remaining_nodes) 700 699  } 701 -  700 + 702 701  return(subtrees) 703 702  } 704 703   ... ... @@ -714,18 +713,18 @@ getSubtreeUnrooted.df <- function(df, node){ 714 713  if( isTip.df(df, node) ){ 715 714  return(NA) 716 715  } 717 -  716 + 718 717  subtrees <- list() 719 -  718 + 720 719  # get subtree for each child node. 721 720  children_ids <- getChild.df(df, node) 722 -  721 + 723 722  # remaining_nodes <- getNodes_by_postorder(tree) 724 723  remaining_nodes <- df$node 725 -  724 + 726 725  # Remove current node from remaining_nodes list. 727 726  remaining_nodes <- setdiff(remaining_nodes, node) 728 -  727 + 729 728  for( child in children_ids ){ 730 729  subtree <- GetSubtree.df(df, child) 731 730  # Append subtree nodes to list if more than 1 node in subtree (i.e. not a tip) ... ... @@ -738,7 +737,7 @@ getSubtreeUnrooted.df <- function(df, node){ 738 737  # remaining_nodes <- setdiff(remaining_nodes, subtree) 739 738  #} 740 739  } 741 -  740 + 742 741  # The remaining nodes that are not found in the child subtrees are the remaining subtree nodes. 743 742  # ie, parent node and all other nodes. We don't care how they are connected, just their id. 744 743  parent_id <- getParent.df(df, node) ... ... @@ -746,7 +745,7 @@ getSubtreeUnrooted.df <- function(df, node){ 746 745  if( parent_id != 0 & length(remaining_nodes) >= 1){ 747 746  subtrees[[length(subtrees)+1]] <- list( node = parent_id, subtree = remaining_nodes) 748 747  } 749 -  748 + 750 749  return(subtrees) 751 750  } 752 751   ... ... @@ -1032,7 +1031,7 @@ getNodes_by_postorder <- function(tree) { 1032 1031  #} 1033 1032   1034 1033  ##' Get the nodes of tree from root in breadth-first order. 1035 -##'  1034 +##' 1036 1035  ##' @title getNodesBreadthFirst.df 1037 1036  ##' @param df tree data.frame 1038 1037  ##' @return list of node id's in breadth-first order. ... ... @@ -1046,27 +1045,27 @@ getNodesBreadthFirst.df <- function(df){ 1046 1045  tree_size <- nrow(df) 1047 1046  # initialise list of nodes 1048 1047  res <- root 1049 -  1048 + 1050 1049  i <- 1 1051 1050  while(length(res) < tree_size){ 1052 1051  parent <- res[i] 1053 1052  i <- i + 1 1054 -  1053 + 1055 1054  # Skip if parent is a tip. 1056 1055  if(isTip.df(df, parent)){ 1057 1056  next 1058 1057  } 1059 -  1058 + 1060 1059  # get children of current parent. 1061 1060  children <- getChild.df(df,parent) 1062 1061   1063 1062  # add children to result 1064 1063  res <- c(res, children) 1065 -  1064 + 1066 1065  } 1067 -  1066 + 1068 1067  return(res) 1069 -  1068 + 1070 1069  } 1071 1070   1072 1071   ... ... @@ -1426,7 +1425,7 @@ add_angle_slanted <- function(res) { 1426 1425  theta <- atan(dy/dx) 1427 1426  theta[is.na(theta)] <- 0 ## root node 1428 1427  res$angle <- theta/pi * 180 1429 -  1428 + 1430 1429  branch.y <- (res[res$parent, "y"] + res[, "y"])/2 1431 1430  idx <- is.na(branch.y) 1432 1431  branch.y[idx] <- res[idx, "y"]
 ... ... @@ -4,9 +4,9 @@ ggtree: an R package for visualization and annotation of phylogenetic trees with 4 4   5 5   6 6   7 -[![](https://img.shields.io/badge/release%20version-1.6.11-green.svg?style=flat)](https://bioconductor.org/packages/ggtree) [![](https://img.shields.io/badge/devel%20version-1.7.10-green.svg?style=flat)](https://github.com/guangchuangyu/ggtree) [![Bioc](http://www.bioconductor.org/shields/years-in-bioc/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#since) [![](https://img.shields.io/badge/download-13681/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![](https://img.shields.io/badge/download-967/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) 7 +[![](https://img.shields.io/badge/release%20version-1.6.11-green.svg?style=flat)](https://bioconductor.org/packages/ggtree) [![](https://img.shields.io/badge/devel%20version-1.7.10-green.svg?style=flat)](https://github.com/guangchuangyu/ggtree) [![Bioc](http://www.bioconductor.org/shields/years-in-bioc/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#since) [![](https://img.shields.io/badge/download-13972/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![](https://img.shields.io/badge/download-1385/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) 8 8   9 -[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![codecov](https://codecov.io/gh/GuangchuangYu/ggtree/branch/master/graph/badge.svg)](https://codecov.io/gh/GuangchuangYu/ggtree) [![Last-changedate](https://img.shields.io/badge/last%20change-2017--04--03-green.svg)](https://github.com/GuangchuangYu/ggtree/commits/master) [![GitHub forks](https://img.shields.io/github/forks/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/network) [![GitHub stars](https://img.shields.io/github/stars/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/stargazers) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://awesome-r.com/#awesome-r-graphic-displays) 9 +[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![codecov](https://codecov.io/gh/GuangchuangYu/ggtree/branch/master/graph/badge.svg)](https://codecov.io/gh/GuangchuangYu/ggtree) [![Last-changedate](https://img.shields.io/badge/last%20change-2017--04--11-green.svg)](https://github.com/GuangchuangYu/ggtree/commits/master) [![GitHub forks](https://img.shields.io/github/forks/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/network) [![GitHub stars](https://img.shields.io/github/stars/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/stargazers) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://awesome-r.com/#awesome-r-graphic-displays) 10 10   11 11  [![platform](http://www.bioconductor.org/shields/availability/devel/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#archives) [![Build Status](http://www.bioconductor.org/shields/build/devel/bioc/ggtree.svg)](https://bioconductor.org/checkResults/devel/bioc-LATEST/ggtree/) [![Linux/Mac Travis Build Status](https://img.shields.io/travis/GuangchuangYu/ggtree/master.svg?label=Mac%20OSX%20%26%20Linux)](https://travis-ci.org/GuangchuangYu/ggtree) [![AppVeyor Build Status](https://img.shields.io/appveyor/ci/Guangchuangyu/ggtree/master.svg?label=Windows)](https://ci.appveyor.com/project/GuangchuangYu/ggtree) [![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-green.svg?style=flat)](http://bioconda.github.io/recipes/bioconductor-ggtree/README.html) 12 12   ... ... @@ -20,7 +20,7 @@ Please cite the following article when using ggtree: 20 20   21 21  **G Yu**, DK Smith, H Zhu, Y Guan, TTY Lam\*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. ***Methods in Ecology and Evolution***. 2017, 8(1):28-36. 22 22   23 -[![](https://img.shields.io/badge/doi-10.1111/2041--210X.12628-green.svg?style=flat)](http://dx.doi.org/10.1111/2041-210X.12628) [![citation](https://img.shields.io/badge/cited%20by-12-green.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) [![](https://img.shields.io/badge/Altmetric-349-green.svg?style=flat)](https://www.altmetric.com/details/10533079) 23 +[![](https://img.shields.io/badge/doi-10.1111/2041--210X.12628-green.svg?style=flat)](http://dx.doi.org/10.1111/2041-210X.12628) [![citation](https://img.shields.io/badge/cited%20by-14-green.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) [![](https://img.shields.io/badge/Altmetric-349-green.svg?style=flat)](https://www.altmetric.com/details/10533079) 24 24   25 25  ------------------------------------------------------------------------ 26 26   ... ... @@ -33,15 +33,15 @@ For details, please visit our project website,
 ... ... @@ -220,7 +220,7 @@ 220 220 

 221 221 

Let us know if you have 222 222  published using ggtree and your publication will be featured here.

 223 -

 223 +

 224 224   225 225   226 226   ... ... @@ -234,12 +234,12 @@ published using ggtree and your publication will be featured here.< 234 234  height: 300px; 235 235  }
 236 236   237 -

 237 +

 238 238 
 239 239   240 240 
 ... ... @@ -218,7 +218,7 @@ 218 218   219 219   220 220 

221 -

221 +

222 222   223 223   224 224 

Journal Articles

 ... ... @@ -234,8 +234,8 @@ 234 234 

235 235 

236 236   237 - 238 -

237 + 238 +

239 239 

The ggtree package extending the ggplot2 package. It based on 240 240  grammar of graphics and takes all the good parts of ggplot2. ggtree 241 241  is designed for not only viewing phylogenetic tree but also displaying ... ... @@ -256,8 +256,8 @@ University of Hong Kong.

256 256 

Citation

257 257 

Please cite the following article when using ggtree:

258 258 

259 - 260 -

259 + 260 +

261 261 

G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R 262 262  package for visualization and annotation of phylogenetic trees with 263 263  their covariates and other associated data. Methods in Ecology and

 ... ... @@ -217,7 +217,7 @@ 217 217  },  218 218  { 219 219  "location": "/featuredArticles/",  220 - "text": "Let us know\n if you have\npublished using \nggtree\n and your publication will be featured here.\n\n\n\n\n\n\n\n\n\n\n\n\n\n .rChart {\n display: block;\n margin-left: auto; \n margin-right: auto;\n width: 800px;\n height: 300px;\n }
\n \n\n\n\n\n\n\n\n\n var chartParams = {\n \"element\": \"chart8461435aeb07\",\n\"width\": 800,\n\"height\": 400,\n\"xkey\": \"year\",\n\"ykeys\": [\n \"cites\" \n],\n\"data\": [\n {\n \"year\": 2016,\n\"cites\": 1,\n\"pubid\": \"HtEfBTGE9r8C\" \n},\n{\n \"year\": 2017,\n\"cites\": 10,\n\"pubid\": \"HtEfBTGE9r8C\" \n} \n],\n\"id\": \"chart8461435aeb07\",\n\"labels\": \"cites\" \n},\n chartType = \"Bar\"\n new Morris[chartType](chartParams)\n\n\n\n\n\n\n\n\n\n\n 2017\n\n\nPhylogenetic analysis of the human antibody repertoire reveals\nquantitative signatures of immune senescence and\naging\n. \nPNAS\n, 2017\n\n\nGut metagenomes of type 2 diabetic patients have characteristic\nsingle-nucleotide polymorphism distribution in \nBacteroides\ncoprocola\n.\n\nMicrobiome\n, 2017, 5:15\n\n\n 2016\n\n\nFunction and Phylogeny of Bacterial Butyryl Coenzyme A:Acetate\nTransferases and Their Diversity in the Proximal Colon of\nSwine\n. \nApplied and\nEnvironmental Microbiology\n. 2016,82(22):6788-6798.",  220 + "text": "Let us know\n if you have\npublished using \nggtree\n and your publication will be featured here.\n\n\n\n\n\n\n\n\n\n\n\n\n\n .rChart {\n display: block;\n margin-left: auto; \n margin-right: auto;\n width: 800px;\n height: 300px;\n }
\n \n\n\n\n\n\n\n\n\n var chartParams = {\n \"element\": \"chart8dd434d08fe\",\n\"width\": 800,\n\"height\": 400,\n\"xkey\": \"year\",\n\"ykeys\": [\n \"cites\" \n],\n\"data\": [\n {\n \"year\": 2016,\n\"cites\": 1,\n\"pubid\": \"HtEfBTGE9r8C\" \n},\n{\n \"year\": 2017,\n\"cites\": 13,\n\"pubid\": \"HtEfBTGE9r8C\" \n} \n],\n\"id\": \"chart8dd434d08fe\",\n\"labels\": \"cites\" \n},\n chartType = \"Bar\"\n new Morris[chartType](chartParams)\n\n\n\n\n\n\n\n\n\n\n 2017\n\n\nPhylogenetic analysis of the human antibody repertoire reveals\nquantitative signatures of immune senescence and\naging\n. \nPNAS\n, 2017\n\n\nGut metagenomes of type 2 diabetic patients have characteristic\nsingle-nucleotide polymorphism distribution in \nBacteroides\ncoprocola\n.\n\nMicrobiome\n, 2017, 5:15\n\n\n 2016\n\n\nFunction and Phylogeny of Bacterial Butyryl Coenzyme A:Acetate\nTransferases and Their Diversity in the Proximal Colon of\nSwine\n. \nApplied and\nEnvironmental Microbiology\n. 2016,82(22):6788-6798.",  221 221  "title": "Featured Articles" 222 222  },  223 223  {
 ... ... @@ -4,7 +4,7 @@ 4 4   5 5   6 6  https://guangchuangyu.github.io/ggtree/ 7 - 2017-03-21 7 + 2017-04-11 8 8  daily 9 9   10 10   ... ... @@ -12,7 +12,7 @@ 12 12   13 13   14 14  https://guangchuangyu.github.io/ggtree/documentation/ 15 - 2017-03-21 15 + 2017-04-11 16 16  daily 17 17   18 18   ... ... @@ -20,7 +20,7 @@ 20 20   21 21   22 22  https://guangchuangyu.github.io/ggtree/faq/ 23 - 2017-03-21 23 + 2017-04-11 24 24  daily 25 25   26 26   ... ... @@ -28,7 +28,7 @@ 28 28   29 29   30 30  https://guangchuangyu.github.io/ggtree/featuredArticles/ 31 - 2017-03-21 31 + 2017-04-11 32 32  daily 33 33   34 34   ... ... @@ -36,7 +36,7 @@ 36 36   37 37   38 38  https://guangchuangyu.github.io/ggtree/gallery/ 39 - 2017-03-21 39 + 2017-04-11 40 40  daily 41 41   42 42   ... ... @@ -45,55 +45,55 @@ 45 45   46 46   47 47  https://guangchuangyu.github.io/ggtree/ChIPseeker/ 48 - 2017-03-21 48 + 2017-04-11 49 49  daily 50 50   51 51   52 52   53 53  https://guangchuangyu.github.io/ggtree/clusterProfiler/ 54 - 2017-03-21 54 + 2017-04-11 55 55  daily 56 56   57 57   58 58   59 59  https://guangchuangyu.github.io/ggtree/DOSE/ 60 - 2017-03-21 60 + 2017-04-11 61 61  daily 62 62   63 63   64 64   65 65  https://guangchuangyu.github.io/ggtree/emojifont/ 66 - 2017-03-21 66 + 2017-04-11 67 67  daily 68 68   69 69   70 70   71 71  https://guangchuangyu.github.io/ggtree/ggtree/ 72 - 2017-03-21 72 + 2017-04-11 73 73  daily 74 74   75 75   76 76   77 77  https://guangchuangyu.github.io/ggtree/GOSemSim/ 78 - 2017-03-21 78 + 2017-04-11 79 79  daily 80 80   81 81   82 82   83 83  https://guangchuangyu.github.io/ggtree/meshes/ 84 - 2017-03-21 84 + 2017-04-11 85 85  daily 86 86   87 87   88 88   89 89  https://guangchuangyu.github.io/ggtree/ReactomePA/ 90 - 2017-03-21 90 + 2017-04-11 91 91  daily 92 92   93 93   94 94   95 95  https://guangchuangyu.github.io/ggtree/treeio/ 96 - 2017-03-21 96 + 2017-04-11 97 97  daily 98 98   99 99 
 100 100 new file mode 100644 ... ... @@ -0,0 +1,20 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{GetSubtree.df} 4 +\alias{GetSubtree.df} 5 +\title{GetSubtree.df} 6 +\usage{ 7 +GetSubtree.df(df, node) 8 +} 9 +\arguments{ 10 +\item{df}{tree data.frame} 11 + 12 +\item{node}{id of starting node.} 13 +} 14 +\value{ 15 +list of all child node id's from starting node. 16 +} 17 +\description{ 18 +Get all children of node from df tree using breath-first. 19 +} 20 +
 0 21 new file mode 100644 ... ... @@ -0,0 +1,21 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{GetSubtreeUnrooted} 4 +\alias{GetSubtreeUnrooted} 5 +\title{GetSubtreeUnrooted} 6 +\usage{ 7 +GetSubtreeUnrooted(tree, node) 8 +} 9 +\arguments{ 10 +\item{tree}{ape phylo tree object} 11 + 12 +\item{node}{is the tree node id from which the subtrees are derived.} 13 +} 14 +\value{ 15 +named list of subtrees with the root id of subtree and list of node id's making up subtree. 16 +} 17 +\description{ 18 +Get all subtrees of specified node. This includes all ancestors and relatives of node and 19 +return named list of subtrees. 20 +} 21 +
 0 22 new file mode 100644 ... ... @@ -0,0 +1,21 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{applyLayoutDaylight} 4 +\alias{applyLayoutDaylight} 5 +\title{applyLayoutDaylight} 6 +\usage{ 7 +applyLayoutDaylight(df, node_id) 8 +} 9 +\arguments{ 10 +\item{df}{tree data.frame} 11 + 12 +\item{node_id}{is id of the node from which daylight is measured to the other subtrees.} 13 +} 14 +\value{ 15 +list with tree data.frame with updated layout using daylight algorithm and max_change angle. 16 +} 17 +\description{ 18 +Apply the daylight alorithm to adjust the spacing between the subtrees and tips of the 19 +specified node. 20 +} 21 +
 0 22 new file mode 100644 ... ... @@ -0,0 +1,20 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{getChild.df} 4 +\alias{getChild.df} 5 +\title{getChild.df} 6 +\usage{ 7 +getChild.df(df, node) 8 +} 9 +\arguments{ 10 +\item{df}{tree data.frame} 11 + 12 +\item{node}{is the node id of child in tree.} 13 +} 14 +\value{ 15 +list of child node ids of parent 16 +} 17 +\description{ 18 +Get list of child node id numbers of parent node 19 +} 20 +
 0 21 new file mode 100644 ... ... @@ -0,0 +1,22 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{getNodeAngle.df} 4 +\alias{getNodeAngle.df} 5 +\title{getNodeAngle.df} 6 +\usage{ 7 +getNodeAngle.df(df, origin_node_id, node_id) 8 +} 9 +\arguments{ 10 +\item{df}{tree data.frame} 11 + 12 +\item{origin_node_id}{origin node id number} 13 + 14 +\item{node_id}{end node id number} 15 +} 16 +\value{ 17 +angle in range [-1, 1], i.e. degrees/180, radians/pi 18 +} 19 +\description{ 20 +Get the angle between the two nodes specified. 21 +} 22 +
 0 23 new file mode 100644 ... ... @@ -0,0 +1,18 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{getNodesBreadthFirst.df} 4 +\alias{getNodesBreadthFirst.df} 5 +\title{getNodesBreadthFirst.df} 6 +\usage{ 7 +getNodesBreadthFirst.df(df) 8 +} 9 +\arguments{ 10 +\item{df}{tree data.frame} 11 +} 12 +\value{ 13 +list of node id's in breadth-first order. 14 +} 15 +\description{ 16 +Get the nodes of tree from root in breadth-first order. 17 +} 18 +
 0 19 new file mode 100644 ... ... @@ -0,0 +1,20 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{getParent.df} 4 +\alias{getParent.df} 5 +\title{getParent.df} 6 +\usage{ 7 +getParent.df(df, node) 8 +} 9 +\arguments{ 10 +\item{df}{tree data.frame} 11 + 12 +\item{node}{is the node id of child in tree.} 13 +} 14 +\value{ 15 +integer node id of parent 16 +} 17 +\description{ 18 +Get parent node id of child node. 19 +} 20 +
 0 21 new file mode 100644 ... ... @@ -0,0 +1,20 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{getSubtree} 4 +\alias{getSubtree} 5 +\title{getSubtree} 6 +\usage{ 7 +getSubtree(tree, node) 8 +} 9 +\arguments{ 10 +\item{tree}{ape phylo tree object} 11 + 12 +\item{node}{is the tree node id from which the tree is derived.} 13 +} 14 +\value{ 15 +list of all child node id's from starting node. 16 +} 17 +\description{ 18 +Get all children of node from tree, including start_node. 19 +} 20 +
 0 21 new file mode 100644 ... ... @@ -0,0 +1,21 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{getSubtreeUnrooted.df} 4 +\alias{getSubtreeUnrooted.df} 5 +\title{GetSubtreeUnrooted} 6 +\usage{ 7 +getSubtreeUnrooted.df(df, node) 8 +} 9 +\arguments{ 10 +\item{df}{tree data.frame} 11 + 12 +\item{node}{is the tree node id from which the subtrees are derived.} 13 +} 14 +\value{ 15 +named list of subtrees with the root id of subtree and list of node id's making up subtree. 16 +} 17 +\description{ 18 +Get all subtrees of node, as well as remaining branches of parent (ie, rest of tree structure as subtree) 19 +return named list of subtrees with list name as starting node id. 20 +} 21 +
 0 22 new file mode 100644 ... ... @@ -0,0 +1,23 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{getTreeArcAngles} 4 +\alias{getTreeArcAngles} 5 +\title{getTreeArcAngles} 6 +\usage{ 7 +getTreeArcAngles(df, origin_id, subtree) 8 +} 9 +\arguments{ 10 +\item{df}{tree data.frame} 11 + 12 +\item{origin_id}{node id from which to calculate left and right hand angles of subtree.} 13 + 14 +\item{subtree}{named list of root id of subtree and list of node ids for given subtree.} 15 +} 16 +\value{ 17 +named list with right and left angles in range [0,2] i.e 1 = 180 degrees, 1.5 = 270 degrees. 18 +} 19 +\description{ 20 +Find the right (clockwise rotation, angle from +ve x-axis to furthest subtree nodes) and 21 +left (anti-clockwise angle from +ve x-axis to subtree) 22 +} 23 +
 ... ... @@ -8,8 +8,9 @@ 8 8  \title{visualizing phylogenetic tree and heterogenous associated data based on grammar of graphics 9 9  \code{ggtree} provides functions for visualizing phylogenetic tree and its associated data in R.} 10 10  \usage{ 11 -ggtree(tr, mapping = NULL, layout = "rectangular", open.angle = 0, 12 - mrsd = NULL, as.Date = FALSE, yscale = "none", yscale_mapping = NULL, 11 +ggtree(tr, mapping = NULL, layout = "rectangular", 12 + layout.method = "equal_angle", open.angle = 0, mrsd = NULL, 13 + as.Date = FALSE, yscale = "none", yscale_mapping = NULL, 13 14  ladderize = TRUE, right = FALSE, branch.length = "branch.length", 14 15  ndigits = NULL, ...) 15 16  } ... ... @@ -20,6 +21,8 @@ ggtree(tr, mapping = NULL, layout = "rectangular", open.angle = 0, 20 21   21 22  \item{layout}{one of 'rectangular', 'slanted', 'fan', 'circular', 'radial' or 'unrooted'} 22 23   24 +\item{layout.method}{of 'equal_angle', 'daylight'.} 25 + 23 26  \item{open.angle}{open angle, only for 'fan' layout} 24 27   25 28  \item{mrsd}{most recent sampling date}
 26 29 new file mode 100644 ... ... @@ -0,0 +1,34 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{layoutDaylight} 4 +\alias{layoutDaylight} 5 +\title{Equal daylight layout method for unrooted trees.} 6 +\usage{ 7 +layoutDaylight(tree, branch.length) 8 +} 9 +\arguments{ 10 +\item{tree}{phylo object} 11 + 12 +\item{branch.length}{set to 'none' for edge length of 1. Otherwise the phylogenetic tree edge length is used.} 13 +} 14 +\value{ 15 +tree as data.frame with equal angle layout. 16 +} 17 +\description{ 18 +#' @title 19 +} 20 +\references{ 21 +The following aglorithm aims to implement the vague description of the "Equal-daylight Algorithm" 22 +in "Inferring Phylogenies" pp 582-584 by Joseph Felsenstein. 23 + 24 + 25 +Leafs are subtrees with no children 26 +Initialise tree using equal angle algorithm 27 +tree_df = equal_angle(tree) 28 + 29 +nodes = get list of nodes in tree_df breadth-first 30 +nodes = remove tip nodes. 31 + 32 + 33 +} 34 +
 0 35 new file mode 100644 ... ... @@ -0,0 +1,23 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{layoutEqualAngle} 4 +\alias{layoutEqualAngle} 5 +\title{layoutEqualAngle} 6 +\usage{ 7 +layoutEqualAngle(tree, branch.length) 8 +} 9 +\arguments{ 10 +\item{tree}{phylo object} 11 + 12 +\item{branch.length}{set to 'none' for edge length of 1. Otherwise the phylogenetic tree edge length is used.} 13 +} 14 +\value{ 15 +tree as data.frame with equal angle layout. 16 +} 17 +\description{ 18 +'Equal-angle layout algorithm for unrooted trees' 19 +} 20 +\references{ 21 +"Inferring Phylogenies" by Joseph Felsenstein. 22 +} 23 +
 0 24 new file mode 100644 ... ... @@ -0,0 +1,24 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/tidytree.R 3 +\name{rotateTreePoints.df} 4 +\alias{rotateTreePoints.df} 5 +\title{rotateTreePoints.data.fram} 6 +\usage{ 7 +rotateTreePoints.df(df, pivot_node, nodes, angle) 8 +} 9 +\arguments{ 10 +\item{df}{tree data.frame} 11 + 12 +\item{pivot_node}{is the id of the pivot node.} 13 + 14 +\item{nodes}{list of node numbers that are to be rotated by angle around the pivot_node} 15 + 16 +\item{angle}{in range [0,2], ie degrees/180, radians/pi} 17 +} 18 +\value{ 19 +updated tree data.frame with points rotated by angle 20 +} 21 +\description{ 22 +Rotate the points in a tree data.frame around a pivot node by the angle specified. 23 +} 24 +
 ... ... @@ -24,7 +24,7 @@ output: 24 24  [Let us know](https://github.com/GuangchuangYu/featured_img) if you have 25 25  published using ggtree and your publication will be featured here. 26 26   27 -[![citation](https://img.shields.io/badge/cited%20by-11-blue.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) 27 +[![citation](https://img.shields.io/badge/cited%20by-14-blue.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) 28 28   29 29   30 30   ... ... @@ -38,13 +38,13 @@ published using ggtree and your publication will be featured here. 38 38  height: 300px; 39 39  }  40 40   41 -
41 +
42 42   43 43 
44 44   45 45 
 ... ... @@ -21,7 +21,7 @@ output: 21 21   22 22   23 23   24 -[![citation](https://img.shields.io/badge/cited%20by-11-blue.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) 24 +[![citation](https://img.shields.io/badge/cited%20by-14-blue.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) 25 25   26 26   27 27  Journal Articles
 ... ... @@ -29,8 +29,8 @@ ggtree: visualization and annotation of phylogenetic trees 29 29   30 30  [![](https://img.shields.io/badge/release%20version-1.6.11-blue.svg?style=flat)](https://bioconductor.org/packages/ggtree) 31 31  [![](https://img.shields.io/badge/devel%20version-1.7.10-blue.svg?style=flat)](https://github.com/guangchuangyu/ggtree) 32 -[![](https://img.shields.io/badge/download-13085/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) 33 -[![](https://img.shields.io/badge/download-967/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) 32 +[![](https://img.shields.io/badge/download-13972/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) 33 +[![](https://img.shields.io/badge/download-1385/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) 34 34   35 35  The ggtree package extending the *ggplot2* package. It based on 36 36  grammar of graphics and takes all the good parts of *ggplot2*. *ggtree* ... ... @@ -60,8 +60,8 @@ University of Hong Kong. 60 60  Please cite the following article when using ggtree: 61 61   62 62  [![](https://img.shields.io/badge/doi-10.1111/2041--210X.12628-blue.svg?style=flat)](http://dx.doi.org/10.1111/2041-210X.12628) 63 -[![citation](https://img.shields.io/badge/cited%20by-11-blue.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) 64 -[![](https://img.shields.io/badge/Altmetric-348-blue.svg?style=flat)](https://www.altmetric.com/details/10533079) 63 +[![citation](https://img.shields.io/badge/cited%20by-14-blue.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) 64 +[![](https://img.shields.io/badge/Altmetric-349-blue.svg?style=flat)](https://www.altmetric.com/details/10533079) 65 65   66 66  **G Yu**, DK Smith, H Zhu, Y Guan, TTY Lam\*. ggtree: an R 67 67  package for visualization and annotation of phylogenetic trees with`