Browse code

Commit made by the Bioconductor Git-SVN bridge. Consists of 1 commit.

Commit information:

Commit id: 9f0522838bdfdb3f0dba8bdd4a513744f8e09da3

calculate angle for fan layout

Committed by: GuangchuangYu
Author Name: GuangchuangYu
Commit date: 2015-01-29 19:53:48 +0800
Author date: 2015-01-29 19:53:48 +0800


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

g.yu authored on 29/01/2015 11:54:10
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: 0.99.6
4
+Version: 0.99.7
5 5
 Author: Guangchuang Yu
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 0.99.7
2
+------------------------
3
+ o add angle information for 'fan' layout <2015-01-29, Thu>
4
+
1 5
 CHANGES IN VERSION 0.99.6
2 6
 ------------------------
3 7
  o read.beast now supports support values of sets such as {x, y, z} <2015-01-19, Mon>
... ...
@@ -23,7 +23,7 @@
23 23
 ggtree <- function(tr, showDistance=FALSE, layout="phylogram", ...) {
24 24
     d <- x <- y <- NULL
25 25
     if (layout == "fan") {
26
-        layout <- "phylogram"
26
+        ## layout <- "phylogram"
27 27
         type <- "fan"
28 28
     } else if (layout == "radial") {
29 29
         layout <- "cladogram"
... ...
@@ -66,7 +66,7 @@ ggtree <- function(tr, showDistance=FALSE, layout="phylogram", ...) {
66 66
 ##' ggplot(tr) + geom_tree()
67 67
 geom_tree <- function(layout="phylogram", ...) {
68 68
     x <- y <- parent <- NULL
69
-    if (layout == "phylogram") {
69
+    if (layout == "phylogram" || layout == "fan") {
70 70
         geom_segment(aes(x=c(x[parent], x[parent]),
71 71
                          xend=c(x, x[parent]),
72 72
                          y=c(y, y[parent]),
... ...
@@ -480,6 +480,13 @@ as.data.frame.phylo_ <- function(x, layout="phylogram",
480 480
         res$length[is.na(res$length)] <- 0
481 481
     }
482 482
     res$branch[is.na(res$branch)] <- 0
483
+    
484
+    if (layout == "fan") {
485
+      idx <- match(1:N, order(res$y))
486
+      angle <- -360/N * 1:N
487
+      angle <- angle[idx]
488
+      res$angle <- angle
489
+    }
483 490
     return(res)
484 491
 }
485 492