git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@117703 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
CHANGES IN VERSION 1.5.4 |
2 | 2 |
------------------------ |
3 |
+ o bug fixed in scaleClade, now y positions are (hopefully) always correct. <2016-05-20, Fri> |
|
3 | 4 |
o bug fixed in collapse <2016-05-20, Fri> |
4 | 5 |
+ if user collapse a node that is an offspring of a collapsed node, print warning msg and return the tree directly |
5 | 6 |
o use byte compiler <2016-05-18, Wed> |
... | ... |
@@ -70,16 +70,8 @@ collapse <- function(tree_view=NULL, node) { |
70 | 70 |
df[sp, "x"] <- NA |
71 | 71 |
df[sp, "y"] <- NA |
72 | 72 |
|
73 |
- root <- which(df$node == df$parent) |
|
74 |
- pp <- df[node, "parent"] |
|
75 |
- while(any(pp != root)) { |
|
76 |
- df[pp, "y"] <- mean(df[getChild.df(df, pp), "y"]) |
|
77 |
- pp <- df[pp, "parent"] |
|
78 |
- } |
|
79 |
- j <- getChild.df(df, pp) |
|
80 |
- j <- j[j!=pp] |
|
81 |
- df[pp, "y"] <- mean(df[j, "y"]) |
|
82 |
- |
|
73 |
+ df <- reassign_y_from_node_to_root(df, node) |
|
74 |
+ |
|
83 | 75 |
## re-calculate branch mid position |
84 | 76 |
df <- calculate_branch_mid(df) |
85 | 77 |
|
... | ... |
@@ -260,7 +252,7 @@ scaleClade <- function(tree_view=NULL, node, scale=1, vertical_only=TRUE) { |
260 | 252 |
## new_span <- span * scale |
261 | 253 |
old.sp.df <- sp.df |
262 | 254 |
sp.df$y <- df[node, "y"] + (sp.df$y - df[node, "y"]) * scale |
263 |
- if (vertical_only == FALSE) { |
|
255 |
+ if (! vertical_only) { |
|
264 | 256 |
sp.df$x <- df[node, "x"] + (sp.df$x - df[node, "x"]) * scale |
265 | 257 |
} |
266 | 258 |
|
... | ... |
@@ -284,9 +276,25 @@ scaleClade <- function(tree_view=NULL, node, scale=1, vertical_only=TRUE) { |
284 | 276 |
} |
285 | 277 |
df[sp, "scale"] <- df[sp, "scale"] * scale |
286 | 278 |
|
279 |
+ df <- reassign_y_from_node_to_root(df, node) |
|
280 |
+ |
|
287 | 281 |
## re-calculate branch mid position |
288 | 282 |
df <- calculate_branch_mid(df) |
289 | 283 |
|
290 | 284 |
tree_view$data <- df |
291 | 285 |
tree_view |
292 | 286 |
} |
287 |
+ |
|
288 |
+ |
|
289 |
+reassign_y_from_node_to_root <- function(df, node) { |
|
290 |
+ root <- which(df$node == df$parent) |
|
291 |
+ pp <- df[node, "parent"] |
|
292 |
+ while(any(pp != root)) { |
|
293 |
+ df[pp, "y"] <- mean(df[getChild.df(df, pp), "y"]) |
|
294 |
+ pp <- df[pp, "parent"] |
|
295 |
+ } |
|
296 |
+ j <- getChild.df(df, pp) |
|
297 |
+ j <- j[j!=pp] |
|
298 |
+ df[pp, "y"] <- mean(df[j, "y"]) |
|
299 |
+ return(df) |
|
300 |
+} |