Skip to content

Commit f888c7c

Browse files
committedDec 3, 2019
updates to fix issue created by changes to ggtree
1 parent 637c943 commit f888c7c

16 files changed

+91
-39
lines changed
 

‎.Rbuildignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
^CRAN-RELEASE$
12
^.*\.Rproj$
23
^\.Rproj\.user$
34
cran-comments.md

‎DESCRIPTION

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: rhierbaps
22
Type: Package
33
Title: Clustering Genetic Sequence Data Using the HierBAPS Algorithm
4-
Version: 1.1.2
4+
Version: 1.1.3
55
Authors@R: person("Gerry", "Tonkin-Hill", email = "g.tonkinhill@gmail.com", role = c("cre", "aut"))
66
Description: Implements the hierarchical Bayesian analysis of populations structure (hierBAPS)
77
algorithm of Cheng et al. (2013) <doi:10.1093/molbev/mst028> for clustering DNA sequences
@@ -17,8 +17,9 @@ Imports:
1717
utils,
1818
ggplot2,
1919
gmp,
20-
matrixStats
21-
RoxygenNote: 6.1.1
20+
matrixStats,
21+
patchwork
22+
RoxygenNote: 7.0.1
2223
Suggests: knitr,
2324
rmarkdown,
2425
ggtree,

‎NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export(hierBAPS)
44
export(load_fasta)
55
export(plot_sub_cluster)
66
export(save_lml_logs)
7+
import(patchwork)

‎R/plot_sub_cluster.R

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#' plot_sub_cluster
22
#'
33
#' Creates a zoom plot using ggtree focusing on a cluster.
4+
#'
5+
#' @import patchwork
46
#'
57
#'
68
#' @param hb.object The resulting object from running hierBAPS
@@ -25,26 +27,27 @@ plot_sub_cluster <- function(hb.object, tree, level, sub.cluster){
2527
if ((!is.numeric(level)) || (level<1)) stop("Invalid level! Must be a positive integer.")
2628
if ((!is.numeric(sub.cluster)) || (sub.cluster<1)) stop("Invalid sub.cluster! Must be a positive integer.")
2729

28-
2930
level <- level+1
3031
if(!("ggtree" %in%
3132
rownames(utils::installed.packages()))) stop("This function requires ggtree to be installed")
3233

3334
cluster.isolate <- hb.object$partition.df$Isolate[hb.object$partition.df[,level]==sub.cluster]
34-
35-
#Need to create a tempfile to supress the output of gzoom
36-
ff <- tempfile()
37-
grDevices::png(filename=ff)
38-
gg2 <- ggtree::gzoom(tree, focus=which(tree$tip.label %in% cluster.isolate))
39-
grDevices::dev.off()
40-
unlink(ff)
41-
35+
36+
# Plot the full tree with the clade highlighted
37+
hb.object$partition.df$is_in_cluster <- hb.object$partition.df$Isolate %in% cluster.isolate
38+
full_tree <- ggtree::`%<+%`(ggtree::ggtree(tree), hb.object$partition.df) +
39+
ggtree::geom_tippoint(ggplot2::aes_string(color="is_in_cluster"), size=0.5) +
40+
ggplot2::theme(legend.position = "none") +
41+
ggplot2::scale_colour_manual(values=c("#000000", "#e31a1c"))
42+
43+
# Subset the tree
4244
temp_column_id <- paste(c("factor(`level ", level, "`)"), collapse = "")
45+
sub_tree <- ape::drop.tip(tree, tree$tip.label[!tree$tip.label %in% cluster.isolate])
46+
sub_tree <- ggtree::`%<+%`(ggtree::ggtree(sub_tree), hb.object$partition.df) +
47+
ggtree::geom_tippoint(ggplot2::aes_string(color=temp_column_id)) +
48+
ggplot2::labs(color=temp_column_id) +
49+
ggplot2::theme(legend.position="right") +
50+
ggplot2::scale_color_discrete(name=paste("level ", level, collapse = ""))
4351

44-
p2 <- gg2$p2
45-
p2 <- ggtree::`%<+%`(p2, hb.object$partition.df)
46-
p2 <- p2 + ggtree::geom_tippoint(ggplot2::aes_string(color=temp_column_id))
47-
p2 <- p2+ ggplot2::labs(color=temp_column_id) + ggplot2::theme(legend.position="right")
48-
49-
return(ggtree::multiplot(gg2$p1, p2, ncol = 2))
52+
return(full_tree+sub_tree+patchwork::plot_layout(nrow = 1))
5053
}

‎README.Rmd

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ knitr::opts_chunk$set(
2323

2424
# rhierbaps
2525

26+
We have recently developed a faster verion of the BAPs clustering method. It can be found [here](https://github.com/gtonkinhill/fastbaps).
27+
2628
## Installation
2729
`rhierbaps` is available on CRAN.
2830
```{r, eval=FALSE}

‎README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
rhierbaps
66
=========
77

8+
We have recently developed a faster verion of the BAPs clustering method. It can be found [here](https://github.com/gtonkinhill/fastbaps).
9+
810
Installation
911
------------
1012

@@ -127,7 +129,7 @@ We can also check how long hierBAPS takes to run on the test dataset of 515 samp
127129
``` r
128130
system.time(hierBAPS(snp.matrix, max.depth = 2, n.pops = 20, quiet = TRUE))
129131
#> user system elapsed
130-
#> 79.411 12.454 98.874
132+
#> 89.755 10.111 117.755
131133
```
132134

133135
Plotting results
@@ -183,12 +185,10 @@ hb.results$lml.list
183185
#> -50858.92
184186
#>
185187
#> $`Depth 1`
186-
#> 1 2 3 4 5 6
187-
#> -2121.8602 -4012.3594 -4237.7634 -3095.1866 -1525.7361 -3180.7573
188-
#> 7 8 9 10 11 12
189-
#> -4015.5022 -2104.5238 -1736.0193 -779.7693 -810.5962 -688.5221
190-
#> 13
191-
#> -163.3203
188+
#> 1 2 3 4 5 6 7
189+
#> -2121.8602 -4012.3594 -4237.7634 -3095.1866 -1525.7361 -3180.7573 -4015.5022
190+
#> 8 9 10 11 12 13
191+
#> -2104.5238 -1736.0193 -779.7693 -810.5962 -688.5221 -163.3203
192192
```
193193

194194
Caculating assignment probabilities

‎cran-comments.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
## Resubmission
22
This is a an updated version. In this version I have:
33

4+
* Fixed an error cause by changes to the ggtree plotting package
5+
6+
## Resubmission
7+
This is a an updated version. In this version I have:
8+
9+
* Fixed a bug that caused the algorithm to stop prematurely on large alignments
10+
11+
## Resubmission
12+
This is a an updated version. In this version I have:
13+
414
* Fixed a minor bug that caused an error when a cluster contained only a single SNP
515
* Added functionality to accept an ape DNAbin object
616

717
## Test environments
8-
* local OS X install, R 3.5.0
18+
* local OS X install, R 3.6.1
919
* ubuntu 14.04 (on travis-ci), R 3.5.0
1020
* win-builder (devel and release)
1121

5.4 KB
Loading
3.57 KB
Loading
-22.2 KB
Loading

‎man/hierBAPS.Rd

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/join_units_2.Rd

+7-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/model_search_parallel.Rd

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/move_units_1.Rd

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/reallocate_units_4.Rd

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/split_clusters_3.Rd

+7-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.