Browse code

update paml_rst to compatible with only marginal ancestral sequence or joint ancestral sequence available

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

g.yu authored on 07/08/2015 08:40:30
Showing 4 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: ggtree
2 2
 Type: Package
3 3
 Title: a phylogenetic tree viewer for different types of tree annotations
4
-Version: 1.1.13
4
+Version: 1.1.14
5 5
 Author: Guangchuang Yu and Tommy Tsan-Yuk Lam
6 6
 Maintainer: Guangchuang Yu <guangchuangyu@gmail.com>
7 7
 Description: ggtree extends the ggplot2 plotting system which implemented the
... ...
@@ -1,3 +1,7 @@
1
+CHANGES IN VERSION 1.1.14
2
+------------------------
3
+ o update paml_rst to compatible with only marginal ancestral sequence or joint ancestral sequence available <2015-08-07, Fri>
4
+ 
1 5
 CHANGES IN VERSION 1.1.13
2 6
 ------------------------
3 7
  o implement annotation_image <2015-08-01, Sat>
... ...
@@ -322,6 +322,9 @@ set.paml_rst_ <- function(object) {
322 322
     types <- get.fields(object)
323 323
     for (type in types) {
324 324
         value <- subs_paml_rst(object, type)
325
+        if (all(is.na(value)))
326
+            next
327
+        
325 328
         if (type == "marginal_subs") {
326 329
             object@marginal_subs <- value
327 330
         } else if (type == "marginal_AA_subs") {
... ...
@@ -364,9 +367,11 @@ subs_paml_rst <- function(x, type, ...) {
364 367
         stop("tip sequences is not available...")
365 368
     }
366 369
     if (type %in% c("marginal_subs", "marginal_AA_subs")) {
367
-        seqs <- c(seqs, x@marginal_ancseq)
370
+        ancseq <- x@marginal_ancseq
371
+        ## seqs <- c(seqs, x@marginal_ancseq)
368 372
     } else if (type %in% c("joint_subs", "joint_AA_subs")){
369
-        seqs <- c(seqs, x@joint_ancseq)
373
+        ancseq <- x@joint_ancseq
374
+        ## seqs <- c(seqs, x@joint_ancseq)
370 375
     } else {
371 376
         stop("type should be one of 'marginal_subs',
372 377
                              'marginal_AA_subs', 'joint_subs' or 'joint_AA_subs'. ")
... ...
@@ -376,6 +381,10 @@ subs_paml_rst <- function(x, type, ...) {
376 381
     } else {
377 382
         translate <- TRUE
378 383
     }
379
-    
384
+
385
+    if (all(ancseq == "")) {
386
+        return(NA)
387
+    }
388
+    seqs <- c(seqs, ancseq)
380 389
     get.subs_(x@phylo, seqs, translate=translate, ...)
381 390
 }
... ...
@@ -114,11 +114,22 @@ setMethod("show", signature(object = "paml_rst"),
114 114
               ## } else {
115 115
               ##     cat(".\n\n")
116 116
               ## }
117
+              fields <- get.fields(object)
118
+
119
+              if (nrow(object@marginal_subs) == 0) {
120
+                  fields <- fields[fields != "marginal_subs"]
121
+                  fields <- fields[fields != "marginal_AA_subs"]
122
+              }
123
+              if (nrow(object@joint_subs) == 0) {
124
+                  fields <- fields[fields != "joint_subs"]
125
+                  fields <- fields[fields != "joint_AA_subs"]
126
+              }
127
+              
117 128
               cat("...@ tree:")
118 129
               print.phylo(get.tree(object))                  
119 130
               cat("\nwith the following features available:\n")
120 131
               cat("\t", paste0("'",
121
-                               paste(get.fields(object), collapse="',\t'"),
132
+                               paste(fields, collapse="',\t'"),
122 133
                                "'."),
123 134
                   "\n")
124 135
           })
... ...
@@ -130,7 +141,7 @@ setMethod("get.fields", signature(object = "paml_rst"),
130 141
               if (length(object@tip_seq) == 0) {
131 142
                   warning("tip sequence not available...\n")
132 143
               } else {
133
-                  get.fields.tree(object)
144
+                  get.fields.tree(object) 
134 145
               }
135 146
           }
136 147
           )