Browse code

geom_hilight options

Guangchuang Yu authored on 06/11/2022 07:48:45
Showing4 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: ggtree
2 2
 Type: Package
3 3
 Title: an R package for visualization of tree and annotation data
4
-Version: 3.7.0
4
+Version: 3.7.0.001
5 5
 Authors@R: c(
6 6
        person("Guangchuang", "Yu",     email = "guangchuangyu@gmail.com", role = c("aut", "cre", "cph"), 
7 7
             comment = c(ORCID = "0000-0002-6485-8781")),
... ...
@@ -26,6 +26,9 @@
26 26
 
27 27
 -->
28 28
 
29
+# ggtree 3.7.0.001
30
+
31
++ allows setting `options(clade_align = TRUE)` to align `geom_hilight()` layer and allows setting `options(clade_width_extend = 0.35)` to set the amount the width extension (in y-axis) of `geom_hilight()`. These two features is designed for `ggtreeDendro::geom_rect_subtree()` layer (2022-11-06, Sun)
29 32
 
30 33
 # ggtree 3.6.0
31 34
 
... ...
@@ -444,10 +444,12 @@ get_clade_position_ <- function(data, node, reverse=FALSE) {
444 444
         xmin <- min(sp.df$branch, na.rm=TRUE)
445 445
         xmax <- max(x, na.rm=TRUE)
446 446
     }
447
+
448
+    w <- getOption("clade_width_extend", default = 0.5)
447 449
     data.frame(xmin=xmin,
448 450
                xmax=xmax,
449
-               ymin=min(y, na.rm=TRUE) - 0.5,
450
-               ymax=max(y, na.rm=TRUE) + 0.5)
451
+               ymin=min(y, na.rm=TRUE) - w,
452
+               ymax=max(y, na.rm=TRUE) + w)
451 453
 }
452 454
 
453 455
 build_align_data <- function(data, align){
... ...
@@ -10,9 +10,13 @@ build_cladeids_df <- function(trdf, nodeids){
10 10
 
11 11
 build_cladeids_df2 <- function(trdf, nodeids){
12 12
     flagreverse <- check_reverse(data=trdf)
13
-    dat <- lapply(nodeids, function(i)get_clade_position_(data=trdf, node=i, reverse=flagreverse))
13
+    dat <- lapply(nodeids, function(i) get_clade_position_(data=trdf, node=i, reverse=flagreverse))
14 14
     dat <- do.call("rbind", dat)
15 15
     dat$clade_root_node <- nodeids
16
+    if (getOption("clade_align", default = FALSE)) {
17
+       dat$xmin <- min(dat$xmin)
18
+       dat$xmax <- max(dat$xmax)         
19
+    }
16 20
     return(dat)
17 21
 }
18 22