From 985b451cdf46041eaa46afa797a41e5931415135 Mon Sep 17 00:00:00 2001 From: Martin Petr Date: Thu, 21 Apr 2022 23:00:40 +0200 Subject: [PATCH] Remove deprecated functions --- NAMESPACE | 11 --- R/compilation.R | 20 +---- R/deprecate.R | 100 ----------------------- man/boundary.Rd | 32 -------- man/compile.Rd | 66 --------------- man/compile_model.Rd | 8 +- man/dispersal.Rd | 37 --------- man/expand.Rd | 46 ----------- man/explore.Rd | 14 ---- man/geneflow.Rd | 26 ------ man/plot.slendr.Rd | 42 ---------- man/plot_graph.Rd | 14 ---- man/read.Rd | 14 ---- man/sampling.Rd | 30 ------- man/shrink.Rd | 43 ---------- tests/testthat/test-compilation.R | 11 --- vignettes/vignette-01-tutorial.Rmd | 4 +- vignettes/vignette-05-tree-sequences.Rmd | 4 +- vignettes/vignette-08-paper.Rmd | 2 +- 19 files changed, 7 insertions(+), 517 deletions(-) delete mode 100644 man/boundary.Rd delete mode 100644 man/compile.Rd delete mode 100644 man/dispersal.Rd delete mode 100644 man/expand.Rd delete mode 100644 man/explore.Rd delete mode 100644 man/geneflow.Rd delete mode 100644 man/plot.slendr.Rd delete mode 100644 man/plot_graph.Rd delete mode 100644 man/read.Rd delete mode 100644 man/sampling.Rd delete mode 100644 man/shrink.Rd diff --git a/NAMESPACE b/NAMESPACE index 28ed3b61b..7f2e92264 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,6 @@ # Generated by roxygen2: do not edit by hand S3method(as.phylo,slendr_phylo) -S3method(plot,slendr) S3method(print,slendr_map) S3method(print,slendr_model) S3method(print,slendr_pop) @@ -11,38 +10,28 @@ export("%>%") export(animate_model) export(area) export(as.phylo.slendr_phylo) -export(boundary) export(check_env) export(clear_env) -export(compile) export(compile_model) -export(dispersal) export(distance) -export(expand) export(expand_range) -export(explore) export(explore_model) export(gene_flow) -export(geneflow) export(join) export(move) export(msprime) export(overlap) -export(plot_graph) export(plot_map) export(plot_model) export(population) -export(read) export(read_model) export(region) export(reproject) export(resize) -export(sampling) export(schedule_sampling) export(set_dispersal) export(set_range) export(setup_env) -export(shrink) export(shrink_range) export(slim) export(subtract) diff --git a/R/compilation.R b/R/compilation.R index 703b0c8be..f4ea52ac1 100644 --- a/R/compilation.R +++ b/R/compilation.R @@ -34,8 +34,6 @@ #' present? Useful for non-interactive uses. In an interactive mode, the user #' is asked to confirm the deletion manually. #' @param description Optional short description of the model -#' @param dir Deprecated. Use \code{path} instead. -#' @param geneflow Deprecated. Use \code{gene_flow} instead. #' #' @return Compiled \code{slendr_model} model object #' @@ -47,25 +45,9 @@ compile_model <- function(populations, generation_time, path = NULL, resolution gene_flow = list(), overwrite = FALSE, force = FALSE, sim_length = NULL, direction = NULL, slim_script = system.file("scripts", "script.slim", package = "slendr"), - description = "", dir = NULL, geneflow = list()) { + description = "") { if (inherits(populations, "slendr_pop")) populations <- list(populations) - if (!is.null(dir) && is.null(path)) { - warning("The `dir =` argument of `compile_model()` is now deprecated", - " as part\nof cleaning up and unifying the function interfaces across the\n", - "entire package. Please consider moving to `path = ` at some point.", - call. = FALSE) - path <- dir - } - - if (length(geneflow) > 0) { - warning("The `geneflow =` argument of `compile_model()` is now deprecated", - " as part\nof cleaning up and unifying the function interfaces across the\n", - "entire package. Please consider moving to `gene_flow = ` at some point.", - call. = FALSE) - gene_flow <- geneflow - } - if (is.null(path)) path <- tempfile() map <- get_map(populations[[1]]) diff --git a/R/deprecate.R b/R/deprecate.R index d218aad79..e69de29bb 100644 --- a/R/deprecate.R +++ b/R/deprecate.R @@ -1,100 +0,0 @@ -#' Deprecated function -#' @inheritParams expand_range -#' @export -expand <- function(pop, by, end, start, overlap = 0.8, snapshots = NULL, - polygon = NULL, lock = FALSE, verbose = TRUE) { - .Deprecated("expand_range") - expand_range(pop, by, end, start, overlap, snapshots = NULL, - polygon = NULL, lock, verbose) -} - -#' Deprecated function -#' @inheritParams shrink_range -#' @export -shrink <- function(pop, by, end, start, overlap = 0.8, snapshots = NULL, - lock = FALSE, verbose = TRUE) { - .Deprecated("shrink_range") - expand_range(pop, by, end, start, overlap, snapshots = NULL, - polygon = NULL, lock, verbose) -} - -#' Deprecated function -#' @inheritParams plot_model -#' @export -plot_graph <- function(model) .Deprecated("plot_model") - -#' Deprecated function -#' @inheritParams explore_model -#' @export -explore <- function(model) { - .Deprecated("explore_model") - explore_model(model) -} - -#' Deprecated function -#' @inheritParams compile_model -#' @export -compile <- function(populations, generation_time, path = NULL, resolution = NULL, - competition = NULL, mating = NULL, dispersal = NULL, - geneflow = list(), overwrite = FALSE, - sim_length = NULL, direction = NULL, - slim_script = system.file("scripts", "script.slim", package = "slendr"), - description = "", dir = NULL) { - .Deprecated("compile_model") - compile_model( - populations, generation_time, path, resolution, competition, - mating, dispersal, geneflow, overwrite, sim_length, direction, - slim_script, description, dir - ) -} - -#' Deprecated function -#' @inheritParams schedule_sampling -#' @export -sampling <- function(model, times, ..., locations = NULL, strict = FALSE) { - .Deprecated("schedule_sampling") - schedule_sampling(model, times, ..., locations, strict) -} - -#' Deprecated function -#' @inheritParams read_model -#' @export -read <- function(path) { - .Deprecated("read_model") - read_model(path) -} - -#' Deprecated function -#' @inheritParams set_dispersal -#' @export -dispersal <- function(pop, time, competition = NA, mating = NA, dispersal = NA, - dispersal_fun = NULL) { - .Deprecated("set_dispersal") - set_dispersal(pop, time, competition, mating, dispersal, dispersal_fun) -} - -#' Deprecated function -#' @inheritParams set_range -#' @export -boundary <- function(pop, time, center = NULL, radius = NULL, polygon = NULL, lock = FALSE) { - .Deprecated("set_range") - set_range(pop, time, center, radius, polygon, lock) -} - -#' Deprecated function -#' @inheritParams gene_flow -#' @export -geneflow <- function(from, to, rate, start, end, overlap = TRUE) { - .Deprecated("gene_flow") - gene_flow(from, to, rate, start, end, overlap) -} - -#' Deprecated function -#' @inheritParams plot_map -#' @export -plot.slendr <- function(..., time = NULL, geneflows = FALSE, - graticules = "original", - intersect = TRUE, show_map = TRUE, - title = NULL, interpolated_maps = NULL) { - .Deprecated("plot_map") -} diff --git a/man/boundary.Rd b/man/boundary.Rd deleted file mode 100644 index 028f89e52..000000000 --- a/man/boundary.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{boundary} -\alias{boundary} -\title{Deprecated function} -\usage{ -boundary(pop, time, center = NULL, radius = NULL, polygon = NULL, lock = FALSE) -} -\arguments{ -\item{pop}{Object of the class \code{slendr_pop}} - -\item{time}{Time of the change} - -\item{center}{Two-dimensional vector specifying the center of the -circular range} - -\item{radius}{Radius of the circular range} - -\item{polygon}{List of vector pairs, defining corners of the -polygon range (see also the \code{region} argument) or a -geographic region of the class \code{slendr_region} from which -the polygon coordinates will be extracted} - -\item{lock}{Maintain the same density of individuals. If -\code{FALSE} (the default), the number of individuals in the -population will not change. If \code{TRUE}, the number of -individuals simulated will be changed (increased or decreased) -appropriately, to match the new population range area.} -} -\description{ -Deprecated function -} diff --git a/man/compile.Rd b/man/compile.Rd deleted file mode 100644 index 1a2dbfc68..000000000 --- a/man/compile.Rd +++ /dev/null @@ -1,66 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{compile} -\alias{compile} -\title{Deprecated function} -\usage{ -compile( - populations, - generation_time, - path = NULL, - resolution = NULL, - competition = NULL, - mating = NULL, - dispersal = NULL, - geneflow = list(), - overwrite = FALSE, - sim_length = NULL, - direction = NULL, - slim_script = system.file("scripts", "script.slim", package = "slendr"), - description = "", - dir = NULL -) -} -\arguments{ -\item{populations}{Object(s) of the \code{slendr_pop} class (multiple objects -need to be specified in a \code{list})} - -\item{generation_time}{Generation time (in model time units)} - -\item{path}{Output directory for the model configuration files which will be -loaded by the backend SLiM script. If \code{NULL}, model configuration -files will be saved to a temporary directory.} - -\item{resolution}{How many distance units per pixel?} - -\item{competition}{Maximum spatial competition and mating choice -distance} - -\item{mating}{Maximum spatial competition and mating choice -distance} - -\item{dispersal}{Standard deviation of the normal distribution of the -parent-offspring distance} - -\item{geneflow}{Deprecated. Use \code{gene_flow} instead.} - -\item{overwrite}{Completely delete the specified directory, in case it -already exists, and create a new one?} - -\item{sim_length}{Total length of the simulation (required for forward time -models, optional for models specified in backward time units which by -default run to "the present time")} - -\item{direction}{Intended direction of time. Under normal circumstances this -parameter is inferred from the model and does not need to be set manually.} - -\item{slim_script}{Path to a SLiM script to be used for executing the model -(by default, a bundled backend script will be used)} - -\item{description}{Optional short description of the model} - -\item{dir}{Deprecated. Use \code{path} instead.} -} -\description{ -Deprecated function -} diff --git a/man/compile_model.Rd b/man/compile_model.Rd index d578c1452..5a46d5a3d 100644 --- a/man/compile_model.Rd +++ b/man/compile_model.Rd @@ -18,9 +18,7 @@ compile_model( sim_length = NULL, direction = NULL, slim_script = system.file("scripts", "script.slim", package = "slendr"), - description = "", - dir = NULL, - geneflow = list() + description = "" ) } \arguments{ @@ -63,10 +61,6 @@ parameter is inferred from the model and does not need to be set manually.} (by default, a bundled backend script will be used)} \item{description}{Optional short description of the model} - -\item{dir}{Deprecated. Use \code{path} instead.} - -\item{geneflow}{Deprecated. Use \code{gene_flow} instead.} } \value{ Compiled \code{slendr_model} model object diff --git a/man/dispersal.Rd b/man/dispersal.Rd deleted file mode 100644 index a2026ed1b..000000000 --- a/man/dispersal.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{dispersal} -\alias{dispersal} -\title{Deprecated function} -\usage{ -dispersal( - pop, - time, - competition = NA, - mating = NA, - dispersal = NA, - dispersal_fun = NULL -) -} -\arguments{ -\item{pop}{Object of the class \code{slendr_pop}} - -\item{time}{Time of the population size change} - -\item{competition}{Maximum spatial competition and mating -choice distance} - -\item{mating}{Maximum spatial competition and mating -choice distance} - -\item{dispersal}{Standard deviation of the normal distribution of the -distance that offspring disperses from its parent} - -\item{dispersal_fun}{Distribution function governing the dispersal of -offspring. One of "normal", "uniform", "cauchy", "exponential", or -"brownian" (in which vertical and horizontal displacements are drawn from a -normal distribution independently).} -} -\description{ -Deprecated function -} diff --git a/man/expand.Rd b/man/expand.Rd deleted file mode 100644 index b62e7ad74..000000000 --- a/man/expand.Rd +++ /dev/null @@ -1,46 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{expand} -\alias{expand} -\title{Deprecated function} -\usage{ -expand( - pop, - by, - end, - start, - overlap = 0.8, - snapshots = NULL, - polygon = NULL, - lock = FALSE, - verbose = TRUE -) -} -\arguments{ -\item{pop}{Object of the class \code{slendr_pop}} - -\item{by}{How many units of distance to expand by?} - -\item{end}{When does the expansion start/end?} - -\item{start}{When does the expansion start/end?} - -\item{overlap}{Minimum overlap between subsequent spatial boundaries} - -\item{snapshots}{The number of intermediate snapshots (overrides the -\code{overlap} parameter)} - -\item{polygon}{Geographic region to restrict the expansion to} - -\item{lock}{Maintain the same density of individuals. If -\code{FALSE} (the default), the number of individuals in the -population will not change. If \code{TRUE}, the number of -individuals simulated will be changed (increased or decreased) -appropriately, to match the new population range area.} - -\item{verbose}{Report on the progress of generating intermediate spatial -boundaries?} -} -\description{ -Deprecated function -} diff --git a/man/explore.Rd b/man/explore.Rd deleted file mode 100644 index 2bdc57adb..000000000 --- a/man/explore.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{explore} -\alias{explore} -\title{Deprecated function} -\usage{ -explore(model) -} -\arguments{ -\item{model}{Compiled \code{slendr_model} model object} -} -\description{ -Deprecated function -} diff --git a/man/geneflow.Rd b/man/geneflow.Rd deleted file mode 100644 index 6a68115b8..000000000 --- a/man/geneflow.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{geneflow} -\alias{geneflow} -\title{Deprecated function} -\usage{ -geneflow(from, to, rate, start, end, overlap = TRUE) -} -\arguments{ -\item{from}{Objects of the class \code{slendr_pop}} - -\item{to}{Objects of the class \code{slendr_pop}} - -\item{rate}{Scalar value in the range (0, 1] specifying the -proportion of migration over given time period} - -\item{start}{Start and end of the geneflow event} - -\item{end}{Start and end of the geneflow event} - -\item{overlap}{Require spatial overlap between admixing -populations? (default \code{TRUE})} -} -\description{ -Deprecated function -} diff --git a/man/plot.slendr.Rd b/man/plot.slendr.Rd deleted file mode 100644 index bf071f8db..000000000 --- a/man/plot.slendr.Rd +++ /dev/null @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{plot.slendr} -\alias{plot.slendr} -\title{Deprecated function} -\usage{ -\method{plot}{slendr}( - ..., - time = NULL, - geneflows = FALSE, - graticules = "original", - intersect = TRUE, - show_map = TRUE, - title = NULL, - interpolated_maps = NULL -) -} -\arguments{ -\item{...}{Objects of classes \code{slendr_map}, \code{slendr_region}, or -\code{slendr_pop}} - -\item{time}{Plot a concrete time point} - -\item{geneflows}{Indicate geneflow events with an arrow} - -\item{graticules}{Plot graticules in the original Coordinate Reference System -(such as longitude-latitude), or in the internal CRS (such as meters)?} - -\item{intersect}{Intersect the population boundaries against landscape and -other geographic boundaries (default TRUE)?} - -\item{show_map}{Show the underlying world map} - -\item{title}{Title of the plot} - -\item{interpolated_maps}{Interpolated spatial boundaries for all populations -in all time points (this is only used for plotting using the \code{explore} -shiny app)} -} -\description{ -Deprecated function -} diff --git a/man/plot_graph.Rd b/man/plot_graph.Rd deleted file mode 100644 index 25ea7bdae..000000000 --- a/man/plot_graph.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{plot_graph} -\alias{plot_graph} -\title{Deprecated function} -\usage{ -plot_graph(model) -} -\arguments{ -\item{model}{Compiled \code{slendr_model} model object} -} -\description{ -Deprecated function -} diff --git a/man/read.Rd b/man/read.Rd deleted file mode 100644 index 713526c3a..000000000 --- a/man/read.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{read} -\alias{read} -\title{Deprecated function} -\usage{ -read(path) -} -\arguments{ -\item{path}{Directory with all required configuration files} -} -\description{ -Deprecated function -} diff --git a/man/sampling.Rd b/man/sampling.Rd deleted file mode 100644 index 826f02b7f..000000000 --- a/man/sampling.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecate.R -\name{sampling} -\alias{sampling} -\title{Deprecated function} -\usage{ -sampling(model, times, ..., locations = NULL, strict = FALSE) -} -\arguments{ -\item{model}{Object of the class \code{slendr_model}} - -\item{times}{Integer vector of times (in model time units) at which to -schedule remembering of individuals in the tree-sequence} - -\item{...}{Lists of two elements (\code{slendr_pop} population object-% resize(N = 100, time = 50, how = "step") - expect_warning(model <- compile_model( - p, dir = file.path(tempdir(), "dir-rerouted-to-path"), - generation_time = 30, overwrite = TRUE, force = TRUE - ), - "The `dir =` argument of `compile") - expect_true(grepl("dir-rerouted-to-path$", model$path)) -}) - - test_that("deletion in non-interactive modem must be forced", { p <- population(name = "pop", N = 700, time = 100) %>% resize(N = 100, time = 50, how = "step") directory <- file.path(tempdir(), "dir-forced") diff --git a/vignettes/vignette-01-tutorial.Rmd b/vignettes/vignette-01-tutorial.Rmd index 40f5a2008..65810d1cc 100644 --- a/vignettes/vignette-01-tutorial.Rmd +++ b/vignettes/vignette-01-tutorial.Rmd @@ -339,7 +339,7 @@ One thing to note is that by default, the `from` and `to` populations for gene f For example, if you look at the spatial boundaries plotted above, you'll see that the European and African populations don't have any overlap in population ranges. If we try to instruct *slendr* to simulate geneflow between them, we will get an error: ```{r eval = FALSE} -geneflows <- gene_flow(from = eur, to = afr, rate = 0.1, start = 20000, end = 15000) +gf <- gene_flow(from = eur, to = afr, rate = 0.1, start = 20000, end = 15000) ``` Not a sufficient overlap between population ranges of EUR and AFR @@ -379,7 +379,7 @@ model_dir <- paste0(tempfile(), "_tutorial-model") model <- compile_model( populations = list(afr, ooa, ehg, eur, ana, yam), # populations defined above - geneflow = gf, # geneflow events defined above + gene_flow = gf, # gene-flow events defined above generation_time = 30, resolution = 10e3, # resolution in meters per pixel competition = 130e3, mating = 100e3, # spatial interaction in SLiM diff --git a/vignettes/vignette-05-tree-sequences.Rmd b/vignettes/vignette-05-tree-sequences.Rmd index 7aabde063..50fa1927a 100644 --- a/vignettes/vignette-05-tree-sequences.Rmd +++ b/vignettes/vignette-05-tree-sequences.Rmd @@ -232,7 +232,7 @@ tree This means that we have the whole R phylogenetic ecosystem at our disposal to analyze such trees. For instance we can use the powerful package *ggtree* to plot the tree we have just extracted: -```{r, plot_ggtree, eval = Sys.which("slim") != "" && env_present && Sys.getenv("RUNNER_OS") != "macOS" && Sys.getenv("SLENDR_LOCAL") == TRUE} +```{r, plot_ggtree, eval = Sys.which("slim") != "" && env_present && Sys.getenv("RUNNER_OS") != "macOS" && Sys.getenv("R_DEVEL_LOCAL") == TRUE} library(ggtree) ggtree(tree) + @@ -242,7 +242,7 @@ ggtree(tree) + ``` -```{r, plot_apetree, eval = Sys.which("slim") != "" && env_present && Sys.getenv("RUNNER_OS") != "macOS" && Sys.getenv("SLENDR_LOCAL") != TRUE} +```{r, plot_apetree, eval = Sys.which("slim") != "" && env_present && Sys.getenv("RUNNER_OS") != "macOS" && Sys.getenv("R_DEVEL_LOCAL") != TRUE} library(ape) plot(tree) nodelabels() diff --git a/vignettes/vignette-08-paper.Rmd b/vignettes/vignette-08-paper.Rmd index 5d56cf5d4..55886b74c 100644 --- a/vignettes/vignette-08-paper.Rmd +++ b/vignettes/vignette-08-paper.Rmd @@ -466,7 +466,7 @@ ancestors <- ts_ancestors(ts, "EUR_599") ### Plotting code -```{r, figure_ex4, eval = Sys.getenv("SLENDR_LOCAL") == TRUE && eval_chunk && file.exists("~/Documents/postdoc/slendr/slendr_models/ex3/output_slim.trees"), fig.height=9, fig.width=7, class.source = "fold-hide"} +```{r, figure_ex4, eval = Sys.getenv("R_DEVEL_LOCAL") == TRUE && eval_chunk && file.exists("~/Documents/postdoc/slendr/slendr_models/ex3/output_slim.trees"), fig.height=9, fig.width=7, class.source = "fold-hide"} library(ggtree) # prepare annotation table for ggtree linking R phylo node ID (not tskit integer