Browse code

bug fixed in collapse

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

g.yu authored on 20/05/2016 06:04:12
Showing 2 changed files

... ...
@@ -1,5 +1,7 @@
1 1
 CHANGES IN VERSION 1.5.4
2 2
 ------------------------
3
+ o bug fixed in collapse <2016-05-20, Fri>
4
+   + if user collapse a node that is an offspring of a collapsed node, print warning msg and return the tree directly
3 5
  o use byte compiler <2016-05-18, Wed>
4 6
  o change any(is.na()) to anyNA() which is more efficient <2016-05-18, Wed> 
5 7
  o https://github.com/Bioconductor-mirror/ggtree/commit/559548c66b51253e8ccb983d353385838a81f106
... ...
@@ -47,10 +47,16 @@ viewClade <- function(tree_view=NULL, node, xmax_adjust=0) {
47 47
 ##' @export
48 48
 ##' @seealso expand
49 49
 ##' @author Guangchuang Yu
50
-collapse <- function(tree_view=NULL, node) {
50
+collapse <- function(tree_view=NULL, node) {    
51 51
     tree_view %<>% get_tree_view
52 52
     
53 53
     df <- tree_view$data
54
+
55
+    if (is.na(df$x[df$node == node])) {
56
+        warning("specific node was already collapsed...")
57
+        return(tree_view)
58
+    }
59
+    
54 60
     sp <- get.offspring.df(df, node)
55 61
     sp.df <- df[sp,]
56 62
     df[node, "isTip"] <- TRUE