Browse code

offset works in align=FFALSE with annotation_image function

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

Guangchuang Yu authored on 23/02/2016 11:37:19
Showing 4 changed files

... ...
@@ -1,5 +1,7 @@
1 1
 CHANGES IN VERSION 1.3.14
2 2
 ------------------------
3
+ o offset works in `align=FFALSE` with `annotation_image` function <2016-02-23, Tue>
4
+   + see https://github.com/GuangchuangYu/ggtree/issues/46
3 5
  o subview and inset now supports annotating with img files <2016-02-23, Tue>
4 6
  
5 7
 CHANGES IN VERSION 1.3.13
... ...
@@ -136,10 +136,6 @@ annotation_image <- function(tree_view, img_info, width=0.1, align=TRUE, linetyp
136 136
     x <- df[idx, "x"]
137 137
     y <- df[idx, "y"]
138 138
 
139
-    EBImage <- "EBImage"
140
-    require(EBImage, character.only = TRUE)
141
-    readImage <- eval(parse(text="readImage"))
142
-    
143 139
     images <- lapply(img_info[,2], readImage)
144 140
 
145 141
     ARs <- sapply(images, getAR)
... ...
@@ -148,11 +144,11 @@ annotation_image <- function(tree_view, img_info, width=0.1, align=TRUE, linetyp
148 144
     if (align) {
149 145
         xmin <- max(df$x) + offset
150 146
         xmin <- rep(xmin, length(x))
151
-        xmax <- xmin + width
152 147
     } else {
153
-        xmin <- x - width/2
154
-        xmax <- x + width/2
148
+        xmin <- x - width/2 + offset
155 149
     }
150
+    xmax <- xmin + width
151
+    
156 152
     ymin <- y - ARs * width/2
157 153
     ymax <- y + ARs * width/2
158 154
     image_layers <- lapply(1:length(xmin), function(i) {
... ...
@@ -30,10 +30,7 @@ subview <- function(mainview, subview, x, y, width=.1, height=.1) {
30 30
     } else if (is(subview, "grob")) {
31 31
         sv <- subview
32 32
     } else if (file.exists(subview)) {
33
-            EBImage <- "EBImage"
34
-            require(EBImage, character.only = TRUE)
35
-            readImage <- eval(parse(text="readImage"))
36
-            sv <- rasterGrob(readImage(subview))
33
+        sv <- rasterGrob(readImage(subview))
37 34
     } else {
38 35
         stop("subview should be a ggplot or grob object, or an image file...")
39 36
     }
... ...
@@ -475,6 +475,9 @@ getCols <- function (n) {
475 475
     colorRampPalette(col3)(n)
476 476
 }
477 477
 
478
-
479
-
480
-
478
+readImage <- function(...) {
479
+    EBImage <- "EBImage"
480
+    require(EBImage, character.only = TRUE)
481
+    EBImage_readImage <- eval(parse(text="readImage"))
482
+    EBImage_readImage(...)
483
+}