Skip to contents

RRatepol 1.4.0

RRatepol 1.4.0 makes the package easier to use, its results reproducible, and its computation more robust.

  • User experience: messages, warnings, and errors are rewritten in one clear style, figures and the website follow the visual identity of the package, all help pages have runnable examples, and a new article explains parallel computation and HPC.
  • Reproducibility: randomisation runs give the same results on any number of cores, a new seed argument makes a single call reproducible, and new Monte Carlo errors and check_rand() show whether enough runs were used.
  • Stability: parallel computation uses the cores that the session may use, also on HPC clusters, and settings and inputs that made functions fail are now handled.

Three changes affect the results of some calls; they are summarised first. Corrections of the smoothing windows and of the documentation of the method are listed last, under Bug fixes.

Before you update

Results that change

  • Calls with random bin selection (bin_selection = "random" with working_units = "bins" or "MW") or with rarefaction (standardise = TRUE) give different values than RRatepol 1.3.0 for the same seed, because each randomisation run now has its own random-number stream (see Reproducibility). The values differ within the variability between randomisation runs, not systematically.
  • smooth_method = "grim": RoC changes for samples near the end of a sequence (see Bug fixes).
  • smooth_method = "m.avg", "age.w", or "grim" with smooth_n_points of 3, 7, 11, and so on, and smooth_method = "grim" with smooth_n_max of 7, 11, 15, and so on (see Bug fixes). The default values (5 and 9) are not affected.
  • All other calls give the same results as RRatepol 1.3.0. To reproduce results of an earlier version, install that version from GitHub, for example remotes::install_github("HOPE-UIB-BIO/R-Ratepol-package@v1.3.0").

Code that may need adapting

  • estimate_roc() returns four new columns (see Reproducibility), and detect_peak_points() now returns all columns of its input with Peak added last. Code that relies on the exact number or position of columns may need adapting.
  • estimate_roc() has a new argument seed, placed after use_parallel. Calls that pass interest_threshold, time_standardisation, verbose, or silent by position need adapting.
  • Errors are now rlang_error conditions from cli::cli_abort() instead of assertError conditions from assertthat, and their texts have changed. Code that catches RRatepol errors by class or matches their text needs adapting.
  • Some inputs that were accepted before now give an error (see Stability).
  • New dependencies: cli and parallelly. assertthat is no longer a dependency.

User experience

Messages, warnings, and errors

  • Progress messages, warnings, and errors now use the {cli} package (#134). They are rewritten in one style, with argument, function, and column names marked up, numbers highlighted, and long texts wrapped at the console width; spelling and grammar errors of the old texts are corrected.
  • Warnings start with a symbol: a red cross when a function changed or ignored part of the input (missing values replaced by 0, samples with missing ages removed, age_uncertainty not used with rand = NULL, the conversion to proportions switched off for a single taxon, RoC values of zero replaced for fitting a trend), and a yellow ! for advice, such as raising rand. They are still R warnings, so suppressWarnings() works as before.
  • Errors say what an argument must be and, for a single value, which value was given, for example “smooth_n_points must be odd, not 4.”, and name the function in which the check failed.
  • estimate_roc(verbose = TRUE) names the conversion to proportions and the dissimilarity coefficient once, before the randomisation runs start; before, every run printed them, mixed with the progress bar. Time stamps are printed to the second, and the run time follows the final message in brackets. The data summary says “Age uncertainty: not provided.” when no age uncertainty is given.
  • The progress bar of the randomisation runs in estimate_roc() follows the progress-bar setting of the session, pbapply::pboptions() (#154). By default, this is a timer bar in interactive sessions and no bar otherwise, so Rscript runs, R CMD check, rendered documents, and the log files of HPC jobs no longer contain long runs of redrawn bars. A bar type chosen with pbapply::pboptions(type = ...) is used as it is. silent = TRUE still shows no bar.
  • detect_peak_points() has a new last argument, silent = FALSE (#141), which suppresses its warnings about RoC values of zero or NA (see Stability). plot_roc(silent = TRUE) no longer warns about NA in ROC, as its documentation already stated for all console output.

Figures

  • plot_roc() has a new look that follows the RRatepol logo (#143): the RoC line is grey, peak points are red with a white outline instead of green, and the trend or threshold line is a darker blue. The values, axes, and layers of the figure do not change. The new colours stay distinct for readers with colour-vision deficiency, for whom the green peak points were hard to see on the grey line.
  • plot_roc() has a new last argument, theme_default = FALSE. With theme_default = TRUE, the figure has no package styling: it uses the ggplot2 theme of the session (the ggplot2 default, or the theme set with ggplot2::theme_set()) and the default ggplot2 colours of all layers, with a see-through uncertainty envelope, and it has no age grid lines, so it can be styled freely.

Website and articles

  • The package website uses the colours and fonts of the logo: a black navigation bar, red accents, and the JetBrains Mono and IBM Plex Sans typefaces.
  • New article Parallel computation and HPC (#125): when parallel computation pays off, with a benchmark; how to choose use_parallel and the number of runs; how to get reproducible parallel results; memory use; and example Slurm job scripts for one record on one node and for many records with a job array.
  • The README and the Workflow example article set seed in their examples, so their results can be reproduced.
  • The README is rewritten as a front page for the package: a figure of RoC with peak points at the top, a list of key features, a summary of what is new in this version, installation of a tagged version, a formatted citation, a guide to the articles and workshop materials, and a new example that checks the number of randomisation runs with check_rand(). The description of the settings of the first example is corrected.

Help pages

  • The examples of estimate_roc(), detect_peak_points(), plot_roc(), check_rand(), and example_data now cover all main options (#135): age uncertainty, smoothing, binning and moving windows, rarefaction, all dissimilarity coefficients, randomisation with seed and use_parallel, all peak-detection methods, modifying the figure, the pilot run with check_rand(), and an analysis of all four sequences of example_data. Most examples were never run by R CMD check before (\dontrun{}); all are now in \donttest{}, which R CMD check --as-cran and --run-donttest run, so they are checked.
  • The documentation of the output of estimate_roc() is corrected: ROC_up and ROC_dw are the 97.5 % and 2.5 % quantiles across runs (not the 95th quantile), Age is the median age, and the columns Working_Unit and ROC_dw are now described.
  • The documentation of example_data describes it as a tibble with one row per sequence.

Reproducibility

Reproducible randomisation runs

  • estimate_roc(): when the randomisation runs draw random numbers (random bin selection with working_units = "bins" or "MW", or rarefaction with standardise = TRUE), each run now has its own random-number stream, created from the generator of the main session (#126). set.seed() before estimate_roc() therefore gives identical results for any value of use_parallel (one core or many) and of silent. Previously, parallel workers were not seeded, so parallel results could not be reproduced at all.
  • For the same seed, such calls give different values than in RRatepol 1.3.0, also on a single core. The age sequences drawn from age_uncertainty are unchanged; the random draws inside each run (bin selection and rarefaction to n_individuals) differ. The differences are those between two sets of randomisation runs: summaries move within their randomisation variability, not systematically. Such calls also leave the random-number generator in a different state than 1.3.0 did, so in a loop over several records the age sequences of the second and later records change too.
  • All other calls, including those whose only randomisation is the age sequences drawn from age_uncertainty, give the same results as in RRatepol 1.3.0 for the same seed and leave the random-number generator in the same state.
  • estimate_roc() has a new argument seed (#133). With a seed (for example seed = 900723), all random draws of the call (the age sequences drawn from age_uncertainty, random bin selection, and rarefaction) come from a generator seeded with that number. The call then gives the same results in any R session, whatever random draws came before it, for any value of use_parallel and silent, and it leaves the random-number generator of the session unchanged. In a session with R’s default generator, seed = x gives the same results as set.seed(x) before a call with seed = NULL. The default seed = NULL keeps the behaviour described above.

Choosing the number of runs

  • estimate_roc() returns four new columns (#130): n_runs, the number of randomisation runs with a RoC value for each Working Unit, and ROC_mc_error, ROC_up_mc_error, and ROC_dw_mc_error, the Monte Carlo standard errors of ROC, ROC_up, and ROC_dw, that is, how much these values vary between calls with different seeds. They are estimated as the exact bootstrap standard errors of the order statistics nearest to the median and quantiles across runs (Maritz and Jarrett, 1978), which draw no random numbers. The values of the existing columns do not change.
  • New function check_rand() recommends the number of randomisation runs (rand) from the output of estimate_roc(): the number at which the Monte Carlo error is below a tolerance (by default 10 % of the width of the 95 % interval) in 90 % of the Working Units. The article Parallel computation and HPC shows how to use it with a pilot of 100 runs.
  • With 100 runs or more and silent = FALSE, estimate_roc() warns when the runs used are fewer than those needed to meet this tolerance in 90 % of the Working Units, and gives the recommended number of runs. The warnings for fewer than 100 runs remain.
  • detect_peak_points() now returns all columns of its input with Peak added as the last column, as its documentation already stated. Previously it kept only Working_Unit, Age, ROC, ROC_up, ROC_dw, and Peak, so its output lost the Monte Carlo error columns and could not be passed to check_rand().

Stability

Parallel computation and HPC

  • estimate_roc(): use_parallel = TRUE now uses the cores available to the R session, as reported by parallelly::availableCores(), instead of all cores of the machine from parallel::detectCores() (#121). On an HPC node, in a container, or with the option mc.cores set, it no longer starts more workers than the job is allowed to use, and it no longer fails where the number of cores cannot be detected. With a single available core, it runs without a cluster.
  • A numeric use_parallel (for example use_parallel = 4) now runs on that many cores; previously it silently ran on a single core (#118). Negative values give an informative error.
  • Parallel workers no longer load tidyverse, which is not a dependency, so parallel runs no longer fail where it is not installed. The cluster is stopped also when a run fails.
  • estimate_roc() no longer changes the progress-bar settings of pbapply for the rest of the session (#121). Previously it set them to a timer after every call and, with silent = TRUE, left progress bars switched off when a run failed. The settings of the session are now restored after every call.

Settings and inputs that made functions fail

  • estimate_roc() with rand = NULL (the default) no longer fails with “argument is of length zero” when age_uncertainty is supplied, when bin_selection = "random" (the default) is used with working_units = "bins" or "MW", or when standardise = TRUE (#128). This affected RRatepol 1.3.0 too. rand = NULL now runs a single run and, with random bin selection or standardise = TRUE, warns about the low number of runs. With age_uncertainty, it warns that the age uncertainty is not used, because the single run uses the point ages. The documentation of rand and age_uncertainty now says so.
  • detect_peak_points() with sel_method = "trend_linear", "trend_non_linear", "GAM_deriv", or "SNI", and plot_roc() with a trend line, no longer fail with “y must be strictly positive for a Gamma density” when the RoC sequence contains values of zero (#77). RoC is zero between two Working Units with identical composition, which can happen after smoothing, for example with smooth_method = "grim". The trends assume a Gamma distribution, which is defined only for values above zero, so for fitting the trend only, values of zero are replaced by half of the smallest RoC value above zero, with a warning; peaks are still detected from the original values. Results for RoC sequences without zeros do not change. This affected RRatepol 1.3.0 too.
  • detect_peak_points() and plot_roc() now handle RoC values of NA (#138). Before, a single NA in ROC gave Peak = NA in every row with sel_method = "threshold", "trend_linear", or "trend_non_linear", and an error with "SNI" and with the trend lines of plot_roc(). Rows whose RoC is NA are now skipped with a warning, which silent = TRUE suppresses: all five methods detect peaks from the remaining rows, and the skipped rows get Peak = NA. plot_roc() draws its trend lines and the median line of trend = "threshold" from the remaining rows. Results for RoC sequences without NA do not change.

Stricter input checks

  • estimate_roc() and plot_roc() give an error when silent (or verbose of estimate_roc()) is not a single TRUE or FALSE; before, estimate_roc() accepted NA, and an invalid silent in plot_roc() hid its warning without an error.
  • estimate_roc() gives an error when standardise or tranform_to_proportions is NA; before, NA was accepted and acted as FALSE.
  • estimate_roc() gives an error when smooth_n_points is not a positive whole number, or smooth_n_max (with smooth_method = "grim") is not a whole number (#151); before, values such as 4.5 or -1 passed the check that the number is odd.

Bug fixes

  • estimate_roc() with smooth_method = "m.avg", "age.w", or "grim": the smoothing window of a sample now holds smooth_n_points samples, as documented: the sample and (smooth_n_points - 1) / 2 samples on each side (#151). Before, the number of samples on each side was smooth_n_points / 2 rounded with R’s round(), which rounds halves to the even number, so smooth_n_points = 3 gave windows of 5 samples and smooth_n_points = 7 gave 9. Results change for smooth_n_points of 3, 7, 11, and so on (3 more than a multiple of 4); they do not change for 5, 9, 13, and so on, which includes the default 5. With "grim", the same correction applies to smooth_n_max, which sets how many samples at the start of the sequence have a window that starts at the first sample, so results also change for smooth_n_max of 7, 11, 15, and so on, but not for the default 9. This affected RRatepol 1.3.0 too. smooth_method = "shep" does not change. The documentation of smooth_n_points and smooth_method and the Package description article now say exactly which samples the windows hold, and that for "shep", smooth_n_points only sets how many samples at each end of the sequence are left unsmoothed; the article said it set the number of points of the filter, which is always 5.
  • estimate_roc() with smooth_method = "grim": the smoothing window of a sample can now be widened to include the last sample of the sequence (#140). Before, only the windows of the last few samples, which start at the end of the sequence, included the last sample. Results with smooth_method = "grim" change for samples near the end of a sequence. With the default settings, RoC changes in 2 of the 488 Working Units of the four records of example_data. This affected RRatepol 1.3.0 too. The internal check of the maximum window size is corrected as well; it could have allowed smooth_n_max + 1 samples only with an even smooth_n_max, which is not allowed, so this correction changes no results. The documentation of smooth_method and the Package description article now describe how the window grows, and that neighbouring samples can share a window, so that the RoC between them is zero.
  • The documentation of detect_peak_points(sel_method = "threshold") is corrected (#131). A point is a peak when ROC_dw, the 2.5 % quantile of RoC across runs (the lower bound of its 95 % interval), lies above the median of all ROC values, that is, when its whole 95 % interval lies above the median. The documentation and the Package description article said the 95th quantile. The code is unchanged, so results do not change.

RRatepol 1.3.0

Complete unit test suite

  • tests/testthat/ created from scratch (~3 000 lines across 19 test files, one per function)
  • shared helper-fixtures.R added for reusable test data
  • every function now has tests for valid input, invalid input with informative errors, and edge cases

CI and test coverage

  • new test-coverage.yaml workflow uploads coverage results to Codecov on every push
  • R-CMD-check.yaml updated to current r-lib/actions conventions
  • testthat (≥ 3.0.0) added to Suggests

Removed runtime dependencies

  • RUtilpol (GitHub-only) and usethis removed from Imports
  • Remotes: field removed; package is now installable from CRAN without any GitHub dependency

New internal utilities

  • R/util_internal.R: drop-in replacements for all RUtilpol helpers used in this package
  • R/util_search_parameter.R: Grimm-smoothing window-growth logic extracted into util_search_parameter() (#96)

New silent argument

  • silent = FALSE added to estimate_roc() and all functions that produce console output; when TRUE, suppresses all messages and warnings without affecting verbose (#109)

Bug fixes

Input validation — new assertions

Documentation and site

  • Roxygen2 updated from 7.2.3 → 7.3.3; all man/*.Rd files regenerated
  • pkgdown site rebuilt; reference index and article pages updated
  • quarto added to Suggests to support vignette rendering

New contributor

  • Friederike Wolke (@FriedaRosa) added as contributor (ctb) for authoring the test suite and filing the issues that drove this release (#60)

RRatepol 1.2.3

  • fix an issue with subsetting the uncertainty matrix to correctly align with the rest of the data (thanks to Giacomo Galli for reporting the bug)
  • replace all not a basic ASCII character in documentation

RRatepol 1.2.2

  • add more information about additional resources and workshops
  • use {neotoma2} from CRAN
  • fix an issue with a case, where the age difference between samples is zero. The zeros are replaced by arbitrary 0.1.

RRatepol 1.2.1

Uncertainty sampling

  • fix an issue with an error message for a large number of iterations in sampling age-sequence

RRatepol 1.2.0

Name uniformity

RRatepol 1.1.0

neotoma -> neotoma2

  • update the vignette to use neotoma2 package (neotoma was deprecated)

utility functions Internal checks

Function references

  • remove several functions references by flagging them as internal

Bug fixes

  • correctly not transform to proportions when selected by a user.

Other

  • within select() replace .data$foo with "foo" (suggested in tidyselect)
  • replace 1:length(... with seq_along

RRatepol 1.0.0

General

  • package has been re-factored (most internal processes have been updated)
  • several arguments of functions have been changed and marked with lifecycle
  • add several more checks while data sourcing

Dissimilarity calculation

  • use vegan package to calculate all dissimilarities except of standardised euclidean.

parallel computation

  • use the pbapply package
  • data for iteration is prepared separately
  • added progress bar

example data

  • names for example columns as been adjusted to avoid using .

RRatepol 0.6.1

Dissimilarity calculation

  • use vegan package to calculate Gower and Bray-Curtis (new) dissimilarity

Univariate RoC estimation

  • fix issues when using only single-taxon dataset

Code cosmetics changes

  • TRUE/FALSE written as full
  • all arguments are written for each function
  • spelling fixes

RRatepol 0.6.0

Overhaul change of the estimation of RoC

  • RoC score is now returned in units selected by user (time_standardisation)
  • Method of sample selection from bin is now optional (bin_selection)
  • RoC is estimated only for subsequent bins (only_subsequent == TRUE)
  • Bins are now created form the beginning of the core (instead of 0)

Console outputs

  • General overhaul of console outputs presented to user while running RRatepol
  • more information and warning messages are presented with each run

doParallel

have been curated by you during the last years packages doSNOW and snow are replaced by doParallel

  • progress bar for randomisation is currently not present

Other

  • Added various checks for correct argument selection
  • all hyphens are replaced with dashes (–) in the whole package
  • examples are wrapped into dontrun

RRatepol 0.5.6

README

  • Figures are now saved in the new folder (man folder) with the new names.
  • cosmetics changes in the code (spaces, new lines, etc)

Vignette

  • stop using pre-saved data
  • decrease the i_multiplier to 0.5 to speed up the vignette building
  • change the treads arguments in fc_estimate_RoC to FALSE so the vignette can be build in machines without multiple cores.
  • rename r chunks to remove empty spaces in names

Other

  • remove RRatepol namespace inside package for internal functions
  • fix couple of typos in function descriptions
  • add cran-comments

RRatepol 0.5.5

  • sample.id or sample_id can be used in as the sample identification
  • RRatepol::fc_plot_RoC_sequence: fix typo in argument age_threshold
  • citation(package = “RRatepol”) now show correct citation
  • update the Figure in README file