| Title: | Synchronicity Testing for Event Records |
|---|---|
| Description: | Evaluation of synchronous deposition across different event records using a log-ratio approach, and syncing age-depth models based on the availability of isochrons. Following the methodology of Wils & Ramisch (2026) <doi:10.1038/s41598-026-67943-7>. The synthetic example dataset used in the examples, tests and vignette is distributed separately in the companion data package 'SyncERdata'. |
| Authors: | Katleen Wils [aut, cre] |
| Maintainer: | Katleen Wils <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.0 |
| Built: | 2026-10-09 16:57:23 UTC |
| Source: | https://github.com/katleenwils/syncer |
Single entry point for turning record metadata into rbacon/rplum-ready CSV input files. It
treats record_data as the initial input data: any new synchronized ages are included and
the CSV(s) are rebuilt. The updated record_data (re-keyed to the folder
generation that was written) is returned.
age_model_input( record_data, adjusted_ages = NULL, update_records = FALSE, radiocarbon_sample_names = "sample", lead_sample_names = "210Pb_sample", original_ages = TRUE, base_dir = syncer_base_dir(), verbose = TRUE )age_model_input( record_data, adjusted_ages = NULL, update_records = FALSE, radiocarbon_sample_names = "sample", lead_sample_names = "210Pb_sample", original_ages = TRUE, base_dir = syncer_base_dir(), verbose = TRUE )
record_data |
Named list of record metadata (output from |
adjusted_ages |
Optional output from |
update_records |
Logical; when |
radiocarbon_sample_names |
Character vector of the event label(s) used for your
radiocarbon samples in the input file (default: |
lead_sample_names |
Character vector of the event label(s) used for your Pb-210 (lead)
samples (default: |
original_ages |
Logical or named logical vector indicating whether the new age-depth
models should also use the original ages alongside the synchronized ages
(default: |
base_dir |
Character string specifying the output directory (default:
|
verbose |
Logical; if |
Invisibly, a named list with the same structure as record_data: the record
frames with the new synchronized ages baked in, keyed by the folder generation that was
written (unchanged keys when update_records = TRUE). Assign it and pass it to the
next age_model_input() call.
Assigns a reference age to test horizons that were excluded from secondary synchronization so
they can be used as "older than"/"younger than" constraints in the age-depth
model. Each excluded horizon receives the synchronized age of the horizon
group it belongs to: e.g. an excluded "synchro-test-wrong" layer
takes the age computed for its group "synchro-test". The member-to-group
mapping comes from horizon_groups (as passed to synchronize_ages()).
Exclusions are parsed with the same logic as
synchronize_ages() (named for per-record, unnamed for global).
assign_nonsynchro_age( adjusted_ages, nonsynchro_horizons, event_stats, horizon_groups = NULL, verbose = TRUE )assign_nonsynchro_age( adjusted_ages, nonsynchro_horizons, event_stats, horizon_groups = NULL, verbose = TRUE )
adjusted_ages |
Output from |
nonsynchro_horizons |
Named or unnamed character vector specifying non-synchronized horizons
(same format as in |
event_stats |
Output from |
horizon_groups |
Named list mapping each horizon group to its member labels, as
passed to |
verbose |
Logical; if |
If an excluded horizon has no synchronized age for its group (it was excluded
altogether, so no group age was ever computed), it is skipped with a warning;
compute an age for it separately with synchronize_ages() using the method of
your choice ("mean", "ageofrecord", "Bayesian", ...).
Named list with one element per excluded horizon, each containing a data frame
with columns: record, adjusted_age, adjusted_error.
Combines multiple posterior age distributions using Bayesian product of probability density functions. Uses kernel density estimation to construct PDFs from samples, multiplies densities in log-space to avoid underflow, normalizes using trapezoidal integration, and calculates moment-matched statistics. This is the recommended method for combining ages from multiple records with overlapping distributions.
bayesian_age_combination( samples_list, return_full_pdf = FALSE, n_grid = 2000, bw = "nrd0" )bayesian_age_combination( samples_list, return_full_pdf = FALSE, n_grid = 2000, bw = "nrd0" )
samples_list |
List of numeric vectors containing posterior samples from different records. |
return_full_pdf |
Logical indicating whether to return the full combined PDF (default: FALSE). |
n_grid |
Integer specifying number of grid points for kernel density estimation (default: 2000). |
bw |
Character string or numeric value specifying bandwidth method for KDE (default: "nrd0"). |
List containing:
mean: Numeric mean of the combined distribution
sd: Numeric standard deviation of the combined distribution
pdf: (if return_full_pdf = TRUE) List with x (grid points)
and pdf (density values)
Returns the number of years elapsed since the radiocarbon BP datum (1950),
calculated from the current system date. Used as the default offset/
age_offset argument throughout SyncER to avoid negative age values.
bp_datum()bp_datum()
Integer: current year minus 1950.
Prepares radiocarbon and Pb210 data frames in the format required by the rbacon/rplum age-depth modelling software.
build_age_input( record_data, record_name, radiocarbon_sample_names = "sample", lead_sample_names = "210Pb_sample", adjusted_ages = NULL, original_ages = TRUE )build_age_input( record_data, record_name, radiocarbon_sample_names = "sample", lead_sample_names = "210Pb_sample", adjusted_ages = NULL, original_ages = TRUE )
record_data |
A data frame containing record data with at least columns: |
record_name |
Character string used to identify the record. |
radiocarbon_sample_names |
Character vector of the event label(s) given to the
radiocarbon samples you want to include (default: |
lead_sample_names |
Character vector of the event label(s) given to the Pb-210 (lead)
samples you want to include (default: |
adjusted_ages |
Optional list output from |
original_ages |
Logical or named logical vector indicating whether to include original
radiocarbon ages when |
A named list with elements:
c14: Data frame formatted for rbacon C14 input
pb210: Data frame formatted for rplum containing Pb210 and C14 input, or NULL if no
Pb210 data is present
Performs all age interpolation and computation logic from raw rbacon/rplum .out file content.
compute_event_ages( raw_out_data, record_data, event_types, max_depths, isochrons, test_horizons, instantaneous_event_depths = NULL, thick = NULL, synced = "" )compute_event_ages( raw_out_data, record_data, event_types, max_depths, isochrons, test_horizons, instantaneous_event_depths = NULL, thick = NULL, synced = "" )
raw_out_data |
Named list of character vectors (raw lines from each .out file), one element per record folder. |
record_data |
Named list of data frames representing each record's metadata
(output from |
event_types |
Character vector of all event type names present in your dataset. |
max_depths |
Named vector containing the depths to which the age models are calculated for each record. |
isochrons |
Character vector of deposit names that are known to be synchronous. |
test_horizons |
Character vector of event deposits for which synchronicity should be tested. |
instantaneous_event_depths |
Optional named list of depth intervals classified as instantaneous deposits per record that should not be considered for event-free depths. |
thick |
The rbacon/rplum section thickness; single numeric, named list per record, or NULL
(default), in which case it is derived per record from the model as
|
synced |
Character string suffix to identify synchronized folders (default: ""). |
Named list of data frames, one per processed record folder, containing depth columns plus one column per event with interpolated ages.
Calculates empirically-based validation thresholds and confidence levels from synchronized
age data for use in subsequent synchronicity testing. Calculates the coefficient of variation (CV = sigma/mu) from synchronized ages,
multiplies by user-specified sigma values to generate age difference thresholds, and
converts sigma values to confidence levels using the standard normal distribution.
The age offset is added before calculating CV to ensure consistency accross calculations.
These thresholds can be directly used in verify_synchronicity() for synchronicity testing.
compute_isochron_thresholds( adjusted_ages, sigma_multiplier = 2, age_offset = bp_datum() )compute_isochron_thresholds( adjusted_ages, sigma_multiplier = 2, age_offset = bp_datum() )
adjusted_ages |
Output from |
sigma_multiplier |
Numeric value or named vector giving the user-defined confidence
level on the age interval, expressed as a standard-deviation multiplier (default: |
age_offset |
Numeric offset value that was added to ages to avoid negative values
(default: |
Named list containing:
validation_thresholds: Named numeric vector of age difference thresholds
(as proportions)
confidence_levels: Named numeric vector of corresponding confidence levels
(as proportions)
sigma_values: Named numeric vector of sigma multipliers used per horizon
empirical_cv: Named numeric vector of empirical coefficients of variation
age_offset: The age offset value used during threshold calculation
if (requireNamespace("SyncERdata", quietly = TRUE)) { # Set-up: synchronized ages from the example data of the companion package SyncERdata isochrons <- paste0("isochron", 1:7) event_stats <- process_event_ages(SyncERdata::out_data_ages_synced, isochrons) adjusted_ages <- synchronize_ages(event_stats, horizons = isochrons, verbose = FALSE) # Single sigma for all horizons thresholds <- compute_isochron_thresholds(adjusted_ages, sigma_multiplier = 2) # Different sigma per horizon thresholds <- compute_isochron_thresholds( adjusted_ages, sigma_multiplier = c(horizon1 = 2, horizon2 = 1, horizon3 = 1.5) ) # With custom age offset thresholds <- compute_isochron_thresholds( adjusted_ages, sigma_multiplier = 2, age_offset = 100 ) # Use in verify_synchronicity (its first argument is the result of # compute_synchronicity_values(); the thresholds are passed to that function) synchro <- compute_synchronicity_values( event_stats, event_names = names(thresholds$validation_thresholds), confidence_level = thresholds$confidence_levels, age_difference = thresholds$validation_thresholds ) verify_synchronicity( synchro, event_names = names(thresholds$validation_thresholds) ) }if (requireNamespace("SyncERdata", quietly = TRUE)) { # Set-up: synchronized ages from the example data of the companion package SyncERdata isochrons <- paste0("isochron", 1:7) event_stats <- process_event_ages(SyncERdata::out_data_ages_synced, isochrons) adjusted_ages <- synchronize_ages(event_stats, horizons = isochrons, verbose = FALSE) # Single sigma for all horizons thresholds <- compute_isochron_thresholds(adjusted_ages, sigma_multiplier = 2) # Different sigma per horizon thresholds <- compute_isochron_thresholds( adjusted_ages, sigma_multiplier = c(horizon1 = 2, horizon2 = 1, horizon3 = 1.5) ) # With custom age offset thresholds <- compute_isochron_thresholds( adjusted_ages, sigma_multiplier = 2, age_offset = 100 ) # Use in verify_synchronicity (its first argument is the result of # compute_synchronicity_values(); the thresholds are passed to that function) synchro <- compute_synchronicity_values( event_stats, event_names = names(thresholds$validation_thresholds), confidence_level = thresholds$confidence_levels, age_difference = thresholds$validation_thresholds ) verify_synchronicity( synchro, event_names = names(thresholds$validation_thresholds) ) }
Calculates overall synchronicity scores (i.e. the probability that all horizons are simultaneously synchronous) across multiple records using additive log-ratio (ALR) transformation. Uses the first record alphabetically as reference. The reference record's Monte Carlo resample is drawn once and shared across every non-reference column, since all comparisons are against the same single (uncertain) reference record; each non-reference record is independently resampled, reflecting that their age models are unrelated.
compute_overall_synchronicity( samples_list, conf_level, age_diff_log_bounds, n_samples = 10000, seed = 5128 )compute_overall_synchronicity( samples_list, conf_level, age_diff_log_bounds, n_samples = 10000, seed = 5128 )
samples_list |
Named list of numeric vectors containing posterior age samples, one per record. |
conf_level |
Numeric value specifying the confidence level for the test (e.g., 0.95). |
age_diff_log_bounds |
Two-element numeric vector with log-space age difference bounds. |
n_samples |
Integer number of Monte Carlo draws per record (default: 10000). |
seed |
Integer random seed for reproducibility (default: 5128). |
Named list containing:
overall_score: Numeric value representing the proportion of joint Monte
Carlo draws (rows of the (k-1)-dimensional ALR distribution) for which
every non-reference record is simultaneously within bounds of the shared
reference draw for that row. This is the joint probability that all considered
records are synchronous.
overall_precision: Numeric value representing the smallest age-difference
tolerance (as a proportion) for which overall_score's joint
(all-records-simultaneously) requirement would reach conf_level, or NA
if the distribution is unsuitable
n_records: Integer count of records included in the analysis
ref_record: Character string identifying the reference record used as
denominator in ALR
Performs all pairwise comparisons and overall calculations of synchronicity score and synchronicity precision.
compute_synchronicity_values( event_stats, event_names, confidence_level = 0.95, age_difference = 0.05, horizon_groups = NULL, n_samples = 10000, seed = 5128 )compute_synchronicity_values( event_stats, event_names, confidence_level = 0.95, age_difference = 0.05, horizon_groups = NULL, n_samples = 10000, seed = 5128 )
event_stats |
Output from |
event_names |
Character vector of event names to test. |
confidence_level |
Numeric value or named vector giving the confidence level (a ratio)
at which synchronicity is tested (default: |
age_difference |
Numeric value or named vector giving the maximum age difference between
two records that is still considered synchronous (default:
Supply a named vector to set different values for different horizons; include one unnamed (or last) value to act as the default for any horizon not named. |
horizon_groups |
Named list mapping group names to character vectors of horizon names
that belong to each group (e.g., |
n_samples |
Integer number of Monte Carlo samples drawn per pairwise comparison (default: 10000). |
seed |
Integer random seed for reproducibility (default: 5128). |
Named list with elements:
results: Pairwise log-ratio results
overall_scores: Overall synchronicity scores per horizon group
viz_data: Data frame of visualization inputs (one row per pairwise comparison)
all_scores: Data frame of all pairwise scores
summary: List with total, positives, negatives, min_score, max_score,
positive_pct, negative_pct
Age synchronization function that calculates age for considered isochrons using one of five possible methods.
compute_synchronized_ages( event_stats, method = NULL, horizons = NULL, nonsynchro_horizons = NULL, excluded_records = NULL, age_record = NULL, age_value = NULL, age_error = NULL, age_cc = NULL, offset = bp_datum(), seed = 5128, n_samples = 10000, bayes_plot_opts = list(), horizon_groups = NULL, verbose = TRUE )compute_synchronized_ages( event_stats, method = NULL, horizons = NULL, nonsynchro_horizons = NULL, excluded_records = NULL, age_record = NULL, age_value = NULL, age_error = NULL, age_cc = NULL, offset = bp_datum(), seed = 5128, n_samples = 10000, bayes_plot_opts = list(), horizon_groups = NULL, verbose = TRUE )
event_stats |
List containing processed age data and summaries (output from
|
method |
Character string or named character vector specifying the synchronization
method(s) used to assign a fixed age (and thus set the age difference between records to
zero) for each horizon. Supply a single string to apply one method to every horizon in
|
horizons |
Character vector of the horizon names to synchronize (default: |
nonsynchro_horizons |
Horizons that were tested but are considered not
synchronous, and so should not be age-matched across records (default: |
excluded_records |
Character vector or named list of records to exclude from the pooled
( |
age_record |
Character string naming the record whose age estimate is adopted when
|
age_value |
Numeric value or named vector giving the age(s) to assign when
|
age_error |
Numeric value or named vector of age errors (default: |
age_cc |
Numeric value or named vector of calibration-curve codes used with
|
offset |
Numeric offset correction value (default: |
seed |
Integer random seed for reproducibility (default: 5128). |
n_samples |
Integer number of Monte Carlo samples drawn per record by the methods that resample posterior ages (default: 10000). |
bayes_plot_opts |
Named list of Bayesian plot layout options. Supported keys:
|
horizon_groups |
Named list mapping group names to character vectors of horizon names
that belong to each group (e.g., |
verbose |
Logical; if |
Named list with two elements:
adjusted_ages: Named list of data frames (one per horizon) with columns
record, adjusted_age, adjusted_error, cc
bayesian_plot_data: Named list (one entry per Bayesian horizon) with
raw plot data - pass each element to plot_bayesian_age_combination() to
draw to the console or save a PDF
Wrapper function that reads rbacon/rplum .out files and returns a named list of
processed event ages. Combines read_age_model_output() and
compute_event_ages() into a single call. When reload_existing
is TRUE, the previously exported CSV folder is returned instead.
load_event_ages( folder_path = syncer_input_dir(), record_data, event_types, max_depths, isochrons, test_horizons, synced = "", reload_existing = FALSE, instantaneous_event_depths = NULL, thick = NULL, output_dir = syncer_output_dir(), verbose = TRUE )load_event_ages( folder_path = syncer_input_dir(), record_data, event_types, max_depths, isochrons, test_horizons, synced = "", reload_existing = FALSE, instantaneous_event_depths = NULL, thick = NULL, output_dir = syncer_output_dir(), verbose = TRUE )
folder_path |
Character string giving the parent directory that contains
per-record rbacon/rplum output sub-folders (default: the directory set by |
record_data |
Named list of data frames representing each record's
metadata (output from |
event_types |
Character vector of all event type names present in your dataset. |
max_depths |
Named numeric vector of maximum depths per record. |
isochrons |
Character vector of deposit names known to be synchronous. |
test_horizons |
Character vector of event deposits for which synchronicity should be tested. |
synced |
Character string suffix identifying synchronized output folders
(default: |
reload_existing |
Logical; when |
instantaneous_event_depths |
Optional named list of depth intervals classified as instantaneous deposits per record that should not be considered for event-free depths. |
thick |
The rbacon/rplum section thickness used during age-depth modelling;
single numeric, named list per record, or |
output_dir |
Character string specifying where the previously-exported
|
verbose |
Logical; if |
Named list of data frames, one per processed record, containing depth columns plus one column per event with interpolated ages.
Expands a single horizon_groups definition into the event_types,
isochrons, test_events, isochron_groups, and
test_horizon_groups values consumed by the rest of the SyncER
workflow (load_event_ages(), compute_synchronicity_values(),
synchronize_ages(), etc.). Combine with list2env() to unpack the
result into your script in a single line, e.g.
list2env(load_horizon_names(horizon_groups), environment()).
load_horizon_names(horizon_groups)load_horizon_names(horizon_groups)
horizon_groups |
Named list, one entry per event type present in your records. Each entry is itself a list with:
|
A named list with elements event_types, isochrons,
test_events, isochron_groups, and test_horizon_groups.
Automatically draws the Bayesian posterior combination figure for one horizon group from
the raw data returned by compute_synchronized_ages()$bayesian_plot_data.
Records that contributed to the combined result are drawn as solid lines;
records excluded from the combination (via excluded_records) are
drawn as dashed lines and labelled "(excluded)" in the legend. Prints to the active graphics
device (console) and, when output_dir is supplied, also saves a PDF.
plot_bayesian_age_combination(pd, output_dir = NULL, verbose = TRUE)plot_bayesian_age_combination(pd, output_dir = NULL, verbose = TRUE)
pd |
Named list for a single horizon, as stored in
|
output_dir |
Character string; directory the PDF is saved to. Pass
|
verbose |
Logical; if |
Invisibly returns NULL.
Generates a two-panel visualization for a single event in two records: (1) histogram of log-ratio values with fitted normal distribution & statistics, confidence intervals, and age difference thresholds; (2) age probability density function (PDFs) for both records shown as histograms with frequency gradients.
plot_pairwise_synchronicity_evaluation( Amin, Amax, Bmin, Bmax, ABlr, sheet1_name, sheet2_name, column_name, col1 = NULL, col2 = NULL, age_diff_log_bounds = NULL, conf_log_bounds = NULL, conf_level = 0.95, variant1 = NULL, variant2 = NULL, plot_opts = list() )plot_pairwise_synchronicity_evaluation( Amin, Amax, Bmin, Bmax, ABlr, sheet1_name, sheet2_name, column_name, col1 = NULL, col2 = NULL, age_diff_log_bounds = NULL, conf_log_bounds = NULL, conf_level = 0.95, variant1 = NULL, variant2 = NULL, plot_opts = list() )
Amin |
Numeric minimum age range for record A. |
Amax |
Numeric maximum age range for record A. |
Bmin |
Numeric minimum age range for record B. |
Bmax |
Numeric maximum age range for record B. |
ABlr |
Numeric vector of log-ratio values (log(A/B)). |
sheet1_name |
Character string identifying record A. |
sheet2_name |
Character string identifying record B. |
column_name |
Character string identifying the event/horizon being compared. |
col1 |
Numeric vector of posterior age samples for record 1 (default: NULL). |
col2 |
Numeric vector of posterior age samples for record 2 (default: NULL). |
age_diff_log_bounds |
Two-element numeric vector specifying log-space age difference thresholds (shown as green lines on histogram plot). |
conf_log_bounds |
Two-element numeric vector specifying confidence interval bounds in log-space (shown as blue shading on histogram plot). |
conf_level |
Numeric value specifying the confidence level used (e.g., 0.95). |
variant1 |
Optional character string specifying exact horizon name in record 1 (for generic horizon groups) (default: NULL). |
variant2 |
Optional character string specifying exact horizon name in record 2 (for generic horizon groups) (default: NULL). |
plot_opts |
Named list of plot layout options:
|
No return value. Creates a composite plot with two panels displayed in the current graphics device.
Produces per-horizon PDF files and console visualizations from a
compute_synchronicity_values() result.
plot_synchronicity_evaluation( synchro_result, output_dir = syncer_output_dir(), offset = bp_datum(), synced = "", fig_width = 10, fig_height = 8, plot_opts = list(), verbose = TRUE )plot_synchronicity_evaluation( synchro_result, output_dir = syncer_output_dir(), offset = bp_datum(), synced = "", fig_width = 10, fig_height = 8, plot_opts = list(), verbose = TRUE )
synchro_result |
The list returned by |
output_dir |
Character string specifying the directory the PDF files will be
saved to (default: |
offset |
Numeric offset correction value applied to ages before plotting
(default: |
synced |
Character string appended to PDF file names (default: ""). |
fig_width |
Numeric width of output PDF figures in inches (default: 10). |
fig_height |
Numeric height of output PDF figures in inches (default: 8). |
plot_opts |
Named list of plot layout options:
|
verbose |
Logical; if |
Invisibly returns NULL.
Prints a formatted summary table of the thresholds returned by
compute_isochron_thresholds().
print_validation_summary(thresholds)print_validation_summary(thresholds)
thresholds |
Output list from |
Invisibly returns thresholds (unchanged).
Extracts event-specific age columns from rbacon/rplum output, applies offset correction,
and calculates summary statistics. Filters columns matching event deposit patterns,
applies offset to avoid negative ages for post-1950 deposits, and ensures the record top is at age 0.
This function takes the direct output from load_event_ages() and processes it in memory.
process_event_ages(out_data, event_deposits, offset = bp_datum())process_event_ages(out_data, event_deposits, offset = bp_datum())
out_data |
Named list of data frames or data.tables containing age data
(output from |
event_deposits |
Character vector of event deposit names to extract (typically
|
offset |
Numeric value added to every age so that the age reference point becomes, for
example, the year the (most recent) records were retrieved rather than 1950 AD (default:
|
A named list with two elements:
processed: List of data frames with offset-corrected ages for each record
summaries: List of summary data frames containing min, max, mean, and
sd (sigma) for each event column
Reads a folder of CSV files containing all age information for events, one file per record,
and returns a named list of data frames. This is the inverse operation of
write_age_output_data(), and allows you to reload previously saved results without recalculating or
load age info into SyncER in case the age-depth models were not constructed using rbacon/rplum.
read_age_data(folder_path = syncer_output_dir(), synced = "", verbose = TRUE)read_age_data(folder_path = syncer_output_dir(), synced = "", verbose = TRUE)
folder_path |
Character string specifying the location of the folder to be read
(default: |
synced |
Character string suffix for the input folder name (default: ""); use "_synced" for synchronized data. |
verbose |
Logical; if |
A named list of data frames, where each element corresponds to one record. List names match the CSV file names (without extension).
if (requireNamespace("SyncERdata", quietly = TRUE)) { # Set-up: save the example data of the companion package SyncERdata to a # temporary folder (stands in for "path/to/folder") folder <- tempdir() write_age_output_data(SyncERdata::out_data_ages, folder, verbose = FALSE) write_age_output_data(SyncERdata::out_data_ages_synced, folder, synced = "_synced", verbose = FALSE) # Read non-synchronized data out_data <- read_age_data(folder) # Read synchronized data out_data_synced <- read_age_data(folder, synced = "_synced") # Use with process_event_ages event_stats <- process_event_ages(out_data, event_deposits = c("tephra", "flood")) }if (requireNamespace("SyncERdata", quietly = TRUE)) { # Set-up: save the example data of the companion package SyncERdata to a # temporary folder (stands in for "path/to/folder") folder <- tempdir() write_age_output_data(SyncERdata::out_data_ages, folder, verbose = FALSE) write_age_output_data(SyncERdata::out_data_ages_synced, folder, synced = "_synced", verbose = FALSE) # Read non-synchronized data out_data <- read_age_data(folder) # Read synchronized data out_data_synced <- read_age_data(folder, synced = "_synced") # Use with process_event_ages event_stats <- process_event_ages(out_data, event_deposits = c("tephra", "flood")) }
Reads raw lines from rbacon/rplum .out files for a set of records into a named list.
Call this function to obtain raw age data, then pass the result to compute_event_ages() for computation of event ages,
and finally call write_age_output_data() to save the processed ages in your folder.
read_age_model_output( folder_path = syncer_input_dir(), synced = "", max_depths = NULL, instantaneous_event_depths = NULL, verbose = TRUE )read_age_model_output( folder_path = syncer_input_dir(), synced = "", max_depths = NULL, instantaneous_event_depths = NULL, verbose = TRUE )
folder_path |
Character string giving the parent directory that contains
the per-record rbacon/rplum output sub-folders (default: the directory set by |
synced |
Character string suffix used to identify synchronized output folders
(default: |
max_depths |
Named numeric vector of original core depths (cm), used only for
progress reporting. Pass |
instantaneous_event_depths |
Optional named list of excluded depth intervals per record, used only for progress reporting. |
verbose |
Logical; if |
Named list of character vectors (one element per folder / record), where each
element contains the raw text lines of the corresponding .out file.
Loads age input dates (radiocarbon and/or 210Pb) and event depths of all records from a folder of
CSV files and calculates maximum depths and sedimentation rates for each record. The function reads
every .csv file in the folder, where each file represents one sediment record. For records
missing required columns ('depth' or 'C14_age'), warnings are issued and NA values are returned.
read_record_data( folder_path = syncer_input_dir(), file_name = "record_data_input" )read_record_data( folder_path = syncer_input_dir(), file_name = "record_data_input" )
folder_path |
Character string specifying the path to the folder containing your input file
(default: the directory set by |
file_name |
Character string specifying the name of the subfolder (inside |
A named list with three elements:
record_data: Named list of data frames, one per record (each CSV file becomes one element)
max_depths: Named numeric vector containing the maximum depth value for each record
sedrates: Named numeric vector containing an estimated sedimentation rate for each record
(calculated as oldest C14 age divided by its depth)
Optional first step of a SyncER script: choose the folder SyncER should work in
(holding your record_data_input folder and the age-depth model folders, and receiving all
output in a SyncER_outputs subfolder). The choice is remembered for the rest of the R session
(via options(SyncER.wd = ...)) and used as the default location by the other SyncER
functions, so you only need to set it once, at the top of your script. If the folder does not
exist yet, it is created. Your R working directory (getwd()) is never changed.
If you never call this function, input is read from the current working directory and output is
written to a per-session temporary directory (see syncer_output_dir), so
SyncER never writes to your file space without being asked to.
syncer_setup(wd = getOption("SyncER.wd"), verbose = TRUE)syncer_setup(wd = getOption("SyncER.wd"), verbose = TRUE)
wd |
Character string giving the directory SyncER should use. If
omitted, first checks |
verbose |
Logical; if |
Invisibly returns the path to the SyncER_outputs directory.
# Use a temporary directory (never write to your own file space in examples) old <- options(SyncER.wd = getOption("SyncER.wd")) syncer_setup(wd = tempdir()) options(old) # restore the previous setting# Use a temporary directory (never write to your own file space in examples) old <- options(SyncER.wd = getOption("SyncER.wd")) syncer_setup(wd = tempdir()) options(old) # restore the previous setting
Calls compute_synchronized_ages() and saves Bayesian combination plots to PDF if used as a matching method.
synchronize_ages( event_stats, output_dir = syncer_output_dir(), method = NULL, horizons = NULL, nonsynchro_horizons = NULL, excluded_records = NULL, age_record = NULL, age_value = NULL, age_error = NULL, age_cc = NULL, offset = bp_datum(), seed = 5128, n_samples = 10000, bayes_plot_opts = list(), horizon_groups = NULL, verbose = TRUE )synchronize_ages( event_stats, output_dir = syncer_output_dir(), method = NULL, horizons = NULL, nonsynchro_horizons = NULL, excluded_records = NULL, age_record = NULL, age_value = NULL, age_error = NULL, age_cc = NULL, offset = bp_datum(), seed = 5128, n_samples = 10000, bayes_plot_opts = list(), horizon_groups = NULL, verbose = TRUE )
event_stats |
List containing processed age data and summaries (output from
|
output_dir |
Character string specifying the directory Bayesian plot PDFs will be
saved to (default: |
method |
Character string or named character vector specifying the synchronization
method(s) used to assign a fixed age (and thus set the age difference between records to
zero) for each horizon. Supply a single string to apply one method to every horizon in
|
horizons |
Character vector of the horizon names to synchronize (default: |
nonsynchro_horizons |
Horizons that were tested but are considered not
synchronous, and so should not be age-matched across records (default: |
excluded_records |
Character vector or named list of records to exclude from the pooled
( |
age_record |
Character string naming the record whose age estimate is adopted when
|
age_value |
Numeric value or named vector giving the age(s) to assign when
|
age_error |
Numeric value or named vector of age errors (default: |
age_cc |
Numeric value or named vector of calibration-curve codes used with
|
offset |
Numeric offset correction value (default: |
seed |
Integer random seed for reproducibility (default: 5128). |
n_samples |
Integer number of Monte Carlo samples drawn per record by the methods that resample posterior ages (default: 10000). |
bayes_plot_opts |
Named list of Bayesian plot layout options passed to
|
horizon_groups |
Named list mapping group names to character vectors of horizon names
that belong to each group (e.g., |
verbose |
Logical; if |
Named list of synchronized ages (one element per horizon), as returned
by compute_synchronized_ages()$adjusted_ages.
Saves a CSV of horizon statistics, prints a summary to the console,
and produces per-horizon visualizations of the age PDFs and log-ratio distributions.
Call compute_synchronicity_values() first and pass its result here.
verify_synchronicity( synchro_result, event_names, output_dir = syncer_output_dir(), group_name = NULL, synced = "", isochron = FALSE, offset = bp_datum(), fig_width = 10, fig_height = 8, plot_opts = list(), verbose = TRUE )verify_synchronicity( synchro_result, event_names, output_dir = syncer_output_dir(), group_name = NULL, synced = "", isochron = FALSE, offset = bp_datum(), fig_width = 10, fig_height = 8, plot_opts = list(), verbose = TRUE )
synchro_result |
The list returned by |
event_names |
Character vector of event names being tested. Falls back to
naming the CSV file when |
output_dir |
Character string specifying the directory the statistics CSV will be
saved to (default: |
group_name |
Character string used to name the CSV file (as
|
synced |
Character string appended to output filenames (default: |
isochron |
Logical; when |
offset |
Numeric offset correction value passed to |
fig_width |
Numeric width of output PDF figures in inches (default: 10). |
fig_height |
Numeric height of output PDF figures in inches (default: 8). |
plot_opts |
Named list of plot layout options:
|
verbose |
Logical; if |
Invisibly returns synchro_result unchanged.
Each record's age information (including event ages) is written to a separate CSV file inside an output folder, with file names matching the list element names, and each row represents a single MCMC simulation.
write_age_output_data( out_data, folder_path = syncer_output_dir(), synced = "", verbose = TRUE )write_age_output_data( out_data, folder_path = syncer_output_dir(), synced = "", verbose = TRUE )
out_data |
Named list of data frames where each element will become a separate CSV file. |
folder_path |
Character string specifying the location where the output folder should be saved
(default: |
synced |
Character string suffix for the output folder name (default: ""); use "_synced" for synchronized data. |
verbose |
Logical; if |
No return value. Writes one CSV file per record and prints a success message with the folder path.