Browse code

bug fixed

Guangchuang Yu authored on 08/07/2022 03:41:17
Showing 2 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: ggtree
2 2
 Type: Package
3 3
 Title: an R package for visualization of tree and annotation data
4
-Version: 3.4.0
4
+Version: 3.4.1
5 5
 Authors@R: c(
6 6
        person("Guangchuang", "Yu",     email = "guangchuangyu@gmail.com", role = c("aut", "cre", "cph"), 
7 7
             comment = c(ORCID = "0000-0002-6485-8781")),
... ...
@@ -81,7 +81,7 @@ layoutEqualAngle <- function(model, branch.length = "branch.length"){
81 81
     ## Get number of tips for each node in tree.
82 82
   ## nb.sp <- sapply(1:N, function(i) length(get.offspring.tip(tree, i)))
83 83
   ## self_include = TRUE to return itself if the input node is a tip
84
-  nb.sp <- vapply(1:N, function(i) length(offspring(tree, i, tiponly = TRUE, self_include = TRUE)), numeric(1))
84
+  nb.sp <- vapply(1:N, function(i) length(offspring(tree, i, type="tips", self_include = TRUE)), numeric(1))
85 85
     ## Get list of node id's.
86 86
     nodes <- getNodes_by_postorder(tree)
87 87
 
... ...
@@ -97,6 +97,9 @@ layoutEqualAngle <- function(model, branch.length = "branch.length"){
97 97
         end <- df[curNode, "end"]
98 98
         cur_x = df[curNode, "x"]
99 99
         cur_y = df[curNode, "y"]
100
+        
101
+        total_angle = end - start
102
+
100 103
         for (child in children) {
101 104
             ## Get the number of tips for child node.
102 105
             ntip.child <- nb.sp[child]
... ...
@@ -104,7 +107,8 @@ layoutEqualAngle <- function(model, branch.length = "branch.length"){
104 107
             ## Calculated in half radians.
105 108
             ## alpha: angle of segment for i-th child with ntips_ij tips.
106 109
             ## alpha = (left_angle - right_angle) * (ntips_ij)/(ntips_current)
107
-            alpha <- (end - start) * ntip.child / curNtip
110
+            ## alpha <- (end - start) * ntip.child / curNtip
111
+            alpha <- total_angle * ntip.child / curNtip
108 112
             ## beta = angle of line from parent node to i-th child.
109 113
             beta <- start + alpha / 2
110 114