Browse code

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

Commit information:

Commit id: e73db7b44a8c7b26082d00a054884c208733d90d

angle for unrooted layout

Committed by: Guangchuang Yu
Author Name: Guangchuang Yu
Commit date: 2015-01-30 00:01:26 +0800
Author date: 2015-01-30 00:01:26 +0800


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

g.yu authored on 29/01/2015 16:01:28
Showing 2 changed files

  • NEWS index abb3e327..ae053e8b 100644
  • R/tree.R index 73f4c3ef..2615eaa3 100644
... ...
@@ -1,6 +1,6 @@
1 1
 CHANGES IN VERSION 0.99.7
2 2
 ------------------------
3
- o add angle information for 'fan' layout <2015-01-29, Thu>
3
+ o add angle information for 'fan' & 'unrooted' layout <2015-01-29, Thu>
4 4
 
5 5
 CHANGES IN VERSION 0.99.6
6 6
 ------------------------
... ...
@@ -156,11 +156,13 @@ layout.unrooted <- function(tree) {
156 156
     df$x <- NA
157 157
     df$y <- NA
158 158
     df$start <- NA
159
-    df$end <- NA
159
+    df$end   <- NA
160
+    df$angle <- NA
160 161
     df[root, "x"] <- 0
161 162
     df[root, "y"] <- 0
162
-    df[root, "start"] <- 0
163
-    df[root, "end"] <- 2
163
+    df[root, "start"] <- -1
164
+    df[root, "end"]   <- 1
165
+    df[root, "angle"] <- 0
164 166
     
165 167
     nb.sp <- sapply(1:N, function(i) length(get.offspring.tip(tree, i)))
166 168
 
... ...
@@ -188,6 +190,7 @@ layout.unrooted <- function(tree) {
188 190
             length.child <- df[child, "length"]
189 191
             df[child, "x"] <- df[curNode, "x"] + cospi(beta) * length.child
190 192
             df[child, "y"] <- df[curNode, "y"] + sinpi(beta) * length.child
193
+            df[child, "angle"] <- -180 * abs(beta)
191 194
             df[child, "start"] <- start
192 195
             df[child, "end"] <- start + alpha
193 196
             start <- start + alpha