Skip to content

Commit

Permalink
feat: treeview() outputs either .rds or .html for all interactive trees
Browse files Browse the repository at this point in the history
  • Loading branch information
russHyde committed Dec 6, 2022
1 parent 61a5e85 commit a687316
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 12 additions & 3 deletions R/treeview.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
#' @param lineages A set of lineage names which will be used to subdivide outputs in scatter plots.
#' @param output_dir Outputs will be saved in this directory. Will create the directory if it does
#' not exist.
#' @param output_format Scalar string (either \code{rds} or \code{html}). Which file format
#' should the interactive plots be placed? For \code{rds}, the default, a \code{ggtree} or
#' \code{ggplot2} object will be placed in an \code{rds} file. For \code{html}, an
#' \code{htmlwidget} will be placed in a \code{html} file.
#' @param heatmap_width,heatmap_lab_offset Width and label-offset parameters for the constructed
#' heatmap.
#'
#' @importFrom rlang .data
#'
#' @return A ggtree plot
#' @return A \code{ggtree} plot.
#'
#' @export

Expand All @@ -25,8 +29,11 @@ treeview <- function(e0,
mutations = c("S:A222V", "S:Y145H", "N:Q9L", "S:E484K"),
lineages = c("AY\\.9", "AY\\.43", "AY\\.4\\.2"),
output_dir = "treeview",
output_format = c("rds", "html"),
heatmap_width = .075,
heatmap_lab_offset = -6) {
output_format <- match.arg(output_format)

# require logistic growth rate, prevent non-empty
branch_cols <- unique(c(
"logistic_growth_rate",
Expand Down Expand Up @@ -244,7 +251,8 @@ treeview <- function(e0,
lgr_trees,
branch_col = "logistic_growth_rate",
n_leaves = n_leaves,
output_dir = output_dir
output_dir = output_dir,
output_format = output_format
)

for (branch_col in setdiff(branch_cols, c("logistic_growth_rate"))) {
Expand All @@ -256,7 +264,8 @@ treeview <- function(e0,
tree_list,
branch_col = branch_col,
n_leaves = n_leaves,
output_dir = output_dir
output_dir = output_dir,
output_format = output_format
)
}
})
Expand Down
8 changes: 7 additions & 1 deletion man/treeview.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a687316

Please sign in to comment.