Skip to content

Commit

Permalink
Add option not to draw gene-flow arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
bodkan committed Jun 21, 2023
1 parent 339d388 commit 104aa63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions R/visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ sort_splits <- function(model) {
#' @param sizes Should population size changes be visualized?
#' @param proportions Should gene flow proportions be visualized (\code{FALSE}
#' by default to prevent cluttering and overplotting)
#' @param gene_flow Should gene-flow arrows be visualized (default \code{TRUE}).
#' @param log Should the y-axis be plotted on a log scale? Useful for models
#' over very long time-scales.
#'
Expand All @@ -275,7 +276,7 @@ sort_splits <- function(model) {
#' geom_polygon geom_label scale_y_continuous scale_color_discrete scale_fill_discrete
#' labs geom_segment arrow
#' @export
plot_model <- function(model, sizes = TRUE, proportions = FALSE, log = FALSE) {
plot_model <- function(model, sizes = TRUE, proportions = FALSE, gene_flow = TRUE, log = FALSE) {
populations <- model$populations

log10_ydelta <- 0.001
Expand Down Expand Up @@ -415,7 +416,7 @@ plot_model <- function(model, sizes = TRUE, proportions = FALSE, log = FALSE) {

# generate a table of gene flow events to be used for plotting gene flow
# arrows
if (!is.null(model$geneflow)) {
if (!is.null(model$geneflow) && gene_flow) {
gene_flow <- model$geneflow %>%
dplyr::mutate(
x = purrr::map_dbl(from, ~ centers[centers$pop == .x, ]$center),
Expand Down
10 changes: 9 additions & 1 deletion man/plot_model.Rd

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

0 comments on commit 104aa63

Please sign in to comment.