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
seedargument makes a single call reproducible, and new Monte Carlo errors andcheck_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"withworking_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"withsmooth_n_pointsof 3, 7, 11, and so on, andsmooth_method = "grim"withsmooth_n_maxof 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), anddetect_peak_points()now returns all columns of its input withPeakadded last. Code that relies on the exact number or position of columns may need adapting. -
estimate_roc()has a new argumentseed, placed afteruse_parallel. Calls that passinterest_threshold,time_standardisation,verbose, orsilentby position need adapting. - Errors are now
rlang_errorconditions fromcli::cli_abort()instead ofassertErrorconditions fromassertthat, 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:
cliandparallelly.assertthatis 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_uncertaintynot used withrand = 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 raisingrand. They are still R warnings, sosuppressWarnings()works as before. - Errors say what an argument must be and, for a single value, which value was given, for example “
smooth_n_pointsmust 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, soRscriptruns,R CMD check, rendered documents, and the log files of HPC jobs no longer contain long runs of redrawn bars. A bar type chosen withpbapply::pboptions(type = ...)is used as it is.silent = TRUEstill shows no bar. -
detect_peak_points()has a new last argument,silent = FALSE(#141), which suppresses its warnings about RoC values of zero orNA(see Stability).plot_roc(silent = TRUE)no longer warns aboutNAinROC, 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. Withtheme_default = TRUE, the figure has no package styling: it uses the ggplot2 theme of the session (the ggplot2 default, or the theme set withggplot2::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_paralleland 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
seedin 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(), andexample_datanow cover all main options (#135): age uncertainty, smoothing, binning and moving windows, rarefaction, all dissimilarity coefficients, randomisation withseedanduse_parallel, all peak-detection methods, modifying the figure, the pilot run withcheck_rand(), and an analysis of all four sequences ofexample_data. Most examples were never run byR CMD checkbefore (\dontrun{}); all are now in\donttest{}, whichR CMD check --as-cranand--run-donttestrun, so they are checked. - The documentation of the output of
estimate_roc()is corrected:ROC_upandROC_dware the 97.5 % and 2.5 % quantiles across runs (not the 95th quantile),Ageis the median age, and the columnsWorking_UnitandROC_dware now described. - The documentation of
example_datadescribes 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 withworking_units = "bins"or"MW", or rarefaction withstandardise = TRUE), each run now has its own random-number stream, created from the generator of the main session (#126).set.seed()beforeestimate_roc()therefore gives identical results for any value ofuse_parallel(one core or many) and ofsilent. 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_uncertaintyare unchanged; the random draws inside each run (bin selection and rarefaction ton_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 argumentseed(#133). With a seed (for exampleseed = 900723), all random draws of the call (the age sequences drawn fromage_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 ofuse_parallelandsilent, and it leaves the random-number generator of the session unchanged. In a session with R’s default generator,seed = xgives the same results asset.seed(x)before a call withseed = NULL. The defaultseed = NULLkeeps 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, andROC_mc_error,ROC_up_mc_error, andROC_dw_mc_error, the Monte Carlo standard errors ofROC,ROC_up, andROC_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 ofestimate_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 withPeakadded as the last column, as its documentation already stated. Previously it kept onlyWorking_Unit,Age,ROC,ROC_up,ROC_dw, andPeak, so its output lost the Monte Carlo error columns and could not be passed tocheck_rand().
Stability
Parallel computation and HPC
-
estimate_roc():use_parallel = TRUEnow uses the cores available to the R session, as reported byparallelly::availableCores(), instead of all cores of the machine fromparallel::detectCores()(#121). On an HPC node, in a container, or with the optionmc.coresset, 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 exampleuse_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 ofpbapplyfor the rest of the session (#121). Previously it set them to a timer after every call and, withsilent = 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()withrand = NULL(the default) no longer fails with “argument is of length zero” whenage_uncertaintyis supplied, whenbin_selection = "random"(the default) is used withworking_units = "bins"or"MW", or whenstandardise = TRUE(#128). This affected RRatepol 1.3.0 too.rand = NULLnow runs a single run and, with random bin selection orstandardise = TRUE, warns about the low number of runs. Withage_uncertainty, it warns that the age uncertainty is not used, because the single run uses the point ages. The documentation ofrandandage_uncertaintynow says so. -
detect_peak_points()withsel_method = "trend_linear","trend_non_linear","GAM_deriv", or"SNI", andplot_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 withsmooth_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()andplot_roc()now handle RoC values ofNA(#138). Before, a singleNAinROCgavePeak = NAin every row withsel_method = "threshold","trend_linear", or"trend_non_linear", and an error with"SNI"and with the trend lines ofplot_roc(). Rows whose RoC isNAare now skipped with a warning, whichsilent = TRUEsuppresses: all five methods detect peaks from the remaining rows, and the skipped rows getPeak = NA.plot_roc()draws its trend lines and the median line oftrend = "threshold"from the remaining rows. Results for RoC sequences withoutNAdo not change.
Stricter input checks
-
estimate_roc()andplot_roc()give an error whensilent(orverboseofestimate_roc()) is not a singleTRUEorFALSE; before,estimate_roc()acceptedNA, and an invalidsilentinplot_roc()hid its warning without an error. -
estimate_roc()gives an error whenstandardiseortranform_to_proportionsisNA; before,NAwas accepted and acted asFALSE. -
estimate_roc()gives an error whensmooth_n_pointsis not a positive whole number, orsmooth_n_max(withsmooth_method = "grim") is not a whole number (#151); before, values such as4.5or-1passed the check that the number is odd.
Bug fixes
-
estimate_roc()withsmooth_method = "m.avg","age.w", or"grim": the smoothing window of a sample now holdssmooth_n_pointssamples, as documented: the sample and(smooth_n_points - 1) / 2samples on each side (#151). Before, the number of samples on each side wassmooth_n_points / 2rounded with R’sround(), which rounds halves to the even number, sosmooth_n_points = 3gave windows of 5 samples andsmooth_n_points = 7gave 9. Results change forsmooth_n_pointsof 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 tosmooth_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 forsmooth_n_maxof 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 ofsmooth_n_pointsandsmooth_methodand the Package description article now say exactly which samples the windows hold, and that for"shep",smooth_n_pointsonly 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()withsmooth_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 withsmooth_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 ofexample_data. This affected RRatepol 1.3.0 too. The internal check of the maximum window size is corrected as well; it could have allowedsmooth_n_max + 1samples only with an evensmooth_n_max, which is not allowed, so this correction changes no results. The documentation ofsmooth_methodand 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 whenROC_dw, the 2.5 % quantile of RoC across runs (the lower bound of its 95 % interval), lies above the median of allROCvalues, 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.Radded 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.yamlworkflow uploads coverage results to Codecov on every push -
R-CMD-check.yamlupdated to currentr-lib/actionsconventions -
testthat(≥ 3.0.0) added toSuggests
Removed runtime dependencies
-
RUtilpol(GitHub-only) andusethisremoved fromImports -
Remotes:field removed; package is now installable from CRAN without any GitHub dependency
New internal utilities
-
R/util_internal.R: drop-in replacements for allRUtilpolhelpers used in this package -
R/util_search_parameter.R: Grimm-smoothing window-growth logic extracted intoutil_search_parameter()(#96)
New silent argument
-
silent = FALSEadded toestimate_roc()and all functions that produce console output; whenTRUE, suppresses all messages and warnings without affectingverbose(#109)
Bug fixes
-
extract_data(): fix NULL column names in age-uncertainty matrix (#48); fix inverted sort condition that left unsorted age data unsorted (#49); fix NA-detection condition that silently passed NA age rows downstream (#50) -
reduce_data(): add two-way sample alignment so community, age, and age-uncertainty stay in sync when NA age rows are dropped (#52) -
prepare_data(): remove orphanedresobject that caused an error insidepurrr::map()(#55) -
estimate_dissimilarity_coefficient(): fix copy-paste error where"chisq"calledvegan::vegdist(method = "chord")(#56) -
subset_samples(): drop empty-bin rows instead of leaving NA-filled template rows in the result (#61) -
detect_peak_points(): adapt to renamedgratia::derivatives()columns (.lower_cireplaceslower) and switch from deprecatednewdatatodataargument (#69) -
check_data(): exclude NAs from summary statistics and report NA counts per column (#43, #47) -
smooth_community_data(): add assertions for logical parameters andsmooth_n_pointsbounds; raise informative errors forshepwith ≤ 2 points (#51, #83) -
plot_roc(): fix wrong object name (sequence_01→sequence_02) in function example (#106)
Input validation — new assertions
- assertions added across all exported functions to catch invalid, empty, or mismatched inputs before they cause cryptic downstream errors
-
extract_data(): additional pre- and post-processing checks (#81) -
reduce_data(): NULL/empty input guards;intersect()-based sample alignment fixes all-zero row handling (#82, #37) -
prepare_data(): NULL/empty guards;bin_sizeassertion skipped whenworking_units = "levels"(#84, #79) -
make_bins():working_unitsmust be a single value (#85) -
run_iteration(): logical-parameter assertions;time_standardisationmust not be0orNA; standardisation-failure error is now unconditional (#86, #62) -
subset_samples():bin_selectionmust be"first","random", orNULL(#87) -
reduce_data_simple(): empty-input guard; logical-parameter assertions (#88) -
subset_community(): empty-input guard (#89) -
standardise_community_data(): guard againstn_individuals = 0; message when minimum count is used as default (#90) -
transform_into_proportions(): empty-input guard; single-valuesel_methodcheck (#91) -
make_trend(): single-valuesel_methodcheck; return value coerced to numeric vector, fixing"non_linear"returning an array (#92, #78) -
detect_sni(): NA checks onCharDatacolumns 2 and 3 (#93) -
plot_roc():peaksmust be a single non-NAvalue; warning whenROCcontains NAs (#94) -
estimate_roc(): single-value and logical checks forstandardise,tranform_to_proportions,verbose,interest_threshold, anduse_parallel(#95)
Documentation and site
- Roxygen2 updated from 7.2.3 → 7.3.3; all
man/*.Rdfiles regenerated -
pkgdownsite rebuilt; reference index and article pages updated -
quartoadded toSuggeststo 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.0
Name uniformity
- In order to make all (exported) functions easier to use (use verbs, snake_style,…), rename all functions and their argument. For back-compatibility, the original functions and arguments are kept but flagged as deprecated. More details here.
- main exported function name change:
- rename
fc_estimate_RoC()toestimate_roc()(#23) - rename
fc_plot_RoC_sequence()toplot_roc()(#24) - rename
fc_detect_peak_points()todetect_peak_points()(#25) - rename all internal functions (#26)
- rename
- Update README (#27)
RRatepol 1.1.0
utility functions Internal checks
- change
util_*functions to useRUtilpolpackage
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
veganpackage to calculate all dissimilarities except of standardised euclidean.
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
RRatepol 0.5.6
README
- Figures are now saved in the new folder (
manfolder) with the new names. - cosmetics changes in the code (spaces, new lines, etc)
