Browse code

byte compiler

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@117653 bc3139a8-67e5-0310-9ffc-ced21a209358

Guangchuang Yu authored on 19/05/2016 01:22:50
Showing 4 changed files

... ...
@@ -32,6 +32,7 @@ Suggests:
32 32
     scales,
33 33
     testthat
34 34
 VignetteBuilder: knitr
35
+ByteCompile: true
35 36
 License: Artistic-2.0
36 37
 URL: http://guangchuangyu.github.io/ggtree
37 38
 BugReports: https://github.com/GuangchuangYu/ggtree/issues
... ...
@@ -1,5 +1,7 @@
1 1
 CHANGES IN VERSION 1.5.4
2 2
 ------------------------
3
+ o use byte compiler <2016-05-18, Wed>
4
+ o change any(is.na()) to anyNA() which is more efficient <2016-05-18, Wed> 
3 5
  o https://github.com/Bioconductor-mirror/ggtree/commit/559548c66b51253e8ccb983d353385838a81f106
4 6
 
5 7
 CHANGES IN VERSION 1.5.3
... ...
@@ -471,7 +471,7 @@ fortify.phylo <- function(model, data, layout="rectangular",
471 471
     }
472 472
 
473 473
     if (! is.null(tree$edge.length)) {
474
-        if (any(is.na(tree$edge.length))) {
474
+        if (anyNA(tree$edge.length)) {
475 475
             warning("'edge.length' contains NA values...\n## setting 'edge.length' to NULL automatically when plotting the tree...")
476 476
             tree$edge.length <- NULL
477 477
         }
... ...
@@ -16,7 +16,7 @@ reroot_node_mapping <- function(tree, tree2) {
16 16
         
17 17
         cc <- getChild(tree, ip)
18 18
         node2 <- node_map[cc,2]
19
-        if (any(is.na(node2))) {
19
+        if (anyNA(node2)) {
20 20
             node <- c(node, k)
21 21
             next
22 22
         }
... ...
@@ -341,7 +341,7 @@ getXcoord2 <- function(x, root, parent, child, len, start=0, rev=FALSE) {
341 341
     if (rev == TRUE) {
342 342
         direction <- -1
343 343
     }
344
-    while(any(is.na(x))) {
344
+    while(anyNA(x)) {
345 345
         idx <- which(parent %in% currentNode)
346 346
         newNode <- child[idx]
347 347
         x[newNode] <- x[parent[idx]]+len[idx] * direction
... ...
@@ -369,7 +369,7 @@ getXcoord_no_length <- function(tr) {
369 369
     child_list <- list()
370 370
     child_list[as.numeric(names(cl))] <- cl
371 371
     
372
-    while(any(is.na(x))) {
372
+    while(anyNA(x)) {
373 373
         idx <- match(currentNode, child)
374 374
         pNode <- parent[idx]
375 375
         ## child number table
... ...
@@ -450,7 +450,7 @@ getYcoord <- function(tr, step=1) {
450 450
     y[-tip.idx] <- NA
451 451
 
452 452
     currentNode <- 1:Ntip
453
-    while(any(is.na(y))) {
453
+    while(anyNA(y)) {
454 454
         pNode <- unique(parent[child %in% currentNode])
455 455
         ## piping of magrittr is slower than nested function call.
456 456
         ## pipeR is fastest, may consider to use pipeR
... ...
@@ -490,7 +490,7 @@ getYcoord_scale <- function(tr, df, yscale) {
490 490
     child <- edge[,2]
491 491
 
492 492
     currentNodes <- root
493
-    while(any(is.na(y))) {
493
+    while(anyNA(y)) {
494 494
         newNodes <- c()
495 495
         for (currentNode in currentNodes) {
496 496
             idx <- which(parent %in% currentNode)
... ...
@@ -564,7 +564,7 @@ getYcoord_scale2 <- function(tr, df, yscale) {
564 564
     child <- df[, "node"]
565 565
     
566 566
     currentNodes <- root
567
-    while(any(is.na(y))) {
567
+    while(anyNA(y)) {
568 568
         newNodes <- c()
569 569
         for (currentNode in currentNodes) {
570 570
             idx <- which(parent %in% currentNode)
... ...
@@ -594,7 +594,7 @@ getYcoord_scale_numeric <- function(tr, df, yscale, ...) {
594 594
     
595 595
     y <- df[, yscale]
596 596
 
597
-    if (any(is.na(y))) {
597
+    if (anyNA(y)) {
598 598
         warning("NA found in y scale mapping, all were setting to 0")
599 599
         y[is.na(y)] <- 0
600 600
     }
... ...
@@ -674,7 +674,7 @@ getYcoord_scale_category <- function(tr, df, yscale, yscale_mapping=NULL, ...) {
674 674
     
675 675
     y <- df[, yscale]
676 676
 
677
-    if (any(is.na(y))) {
677
+    if (anyNA(y)) {
678 678
         warning("NA found in y scale mapping, all were setting to 0")
679 679
         y[is.na(y)] <- 0
680 680
     }
... ...
@@ -753,7 +753,7 @@ set_branch_length <- function(tree_object, branch.length) {
753 753
 
754 754
 
755 755
 re_assign_ycoord_df <- function(df, currentNode) {
756
-    while(any(is.na(df$y))) {
756
+    while(anyNA(df$y)) {
757 757
         pNode <- with(df, parent[match(currentNode, node)]) %>% unique
758 758
         idx <- sapply(pNode, function(i) with(df, all(node[parent == i & parent != node] %in% currentNode)))
759 759
         newNode <- pNode[idx]